This commit is contained in:
colben
2026-03-27 20:02:15 +08:00
parent 36cef0e15b
commit 7b32a7edd6
4 changed files with 143 additions and 7 deletions

130
content/post/hbase.md Normal file
View File

@@ -0,0 +1,130 @@
---
title: "hbase 部署"
date: 2023-05-23T18:00:00+08:00
lastmod: 2025-12-01T10:00:00+08:00
keywords: []
tags: ["hadoop", "hbase"]
categories: ["hadoop"]
---
## 环境
操作系统 | 主机名 | 地址 | 运行组件
---- | ---- | ---- | ----
Rocky9 | hbase-m30 | 192.168.8.30/24 | hbase Master
Rocky9 | hbase-bm31 | 192.168.8.31/24 | hbase Backup Master
Rocky9 | hbase-rs32 | 192.168.8.32/24 | hbase Rigion Server
Rocky9 | hbase-rs33 | 192.168.8.33/24 | hbase Rigion Server
## 前提
- [已部署好 hadoop 2.10](/post/hdp2)
- [已部署好 zookeeper 3.4 以上版本](/post/zk-install)
## 服务器初始配置
- 在**全部主机**上执行如下操作
- 禁用防火墙
- 禁用 selinux
- 配置时间同步
- 配置主机名解析
```bash
echo "192.168.8.1 hdp-nn" >> /etc/hosts
echo "192.168.8.2 hdp-snn" >> /etc/hosts
echo "192.168.8.3 hdp-dn" >> /etc/hosts
echo "192.168.8.10 hdp-slave10" >> /etc/hosts
echo "192.168.8.11 hdp-slave11" >> /etc/hosts
echo "192.168.8.30 hbase-m30" >> /etc/hosts
echo "192.168.8.31 hbase-bm31" >> /etc/hosts
echo "192.168.8.32 hbase-region32" >> /etc/hosts
echo "192.168.8.33 hbase-region33" >> /etc/hosts
```
## ssh 免密登录
- 配置 **hbase-m30** 可以 ssh 免密登录 hbase-m30、hbase-bm31 和 hbase-rsXX
```bash
# 在 hbase-m30 上执行如下操作
ssh-copy-id hbase-m30
ssh-copy-id hbase-bm31
ssh-copy-id hbase-rs32
ssh-copy-id hbase-rs33
```
## 复制 jdk 和 hadoop 环境
- 在**全部主机**上执行如下操作
- 从 **hdp-nn** 复制 jdk 和 hadoop 环境
```bash
scp -r hdp-nn:/opt/{jdk,hdp} /opt/
scp hdp-nn:/etc/profile.d/{jdk,hdp}.sh /etc/profile.d/
source /etc/profile.d/jdk.sh
source /etc/profile.d/hdp.sh
```
## 部署 hbase 环境
- 在**全部主机**上执行如下操作
- 下载 hbase 2.5.13 部署包,解压
```bash
curl -LO https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.5.13/hbase-2.5.13-bin.tar.gz
tar zxf hbase-2.5.13-bin.tar.gz
mv hbase-2.5.13 /opt/hbase
```
- 配置环境变量
```bash
echo 'export HBASE_HOME=/opt/hbase' > /etc/profile.d/hbase.sh
echo 'export PATH=$HBASE_HOME/bin:$PATH' >> /etc/profile.d/hbase.sh
source /etc/profile.d/hbase.sh
```
### 修改 hbase-env.sh
- 编辑 $HBASE_HOME/conf/hbase-env.sh指定如下三个环境变量
```bash
export JAVA_HOME=/opt/jdk
export HBASE_CLASSPATH=$HADOOP_HOME/etc/hadoop
export HBASE_MANAGES_ZK=false
```
### 创建 hbase-site.xml
- 清空 $HBASE_HOME/conf/hbase-site.xml添加如下内容
```xml
<configuration>
<property>
<!-- 指定分布式 -->
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<!-- 指定要用的 hdfs 地址和目录 -->
<name>hbase.rootdir</name>
<value>hdfs://hdp-nn-21:8020/hbase</value>
</property>
<property>
<!-- 指定要连接的 zookeeper 节点 -->
<name>hbase.zookeeper.quorum</name>
<value>zk1,zk2,zk3</value>
</property>
</configuration>
```
### 修改 regionservers
- 清空 $HBASE_HOME/conf/regionservers添加如下内容
```
hbase-rs32
hbase-rs33
```
### 创建 backup-masters
- 创建 $HBASE_HOME/conf/backup-masters添加如下内容
```
hbase-bm31
```
## 启动 hbase
- 在 **hbase-m30** 上启动 hbase 集群
```bash
start-hbase.sh
```
## 客户端连接
- 本地直接进入 hbase shell
```bash
hbase shell
```

View File

@@ -230,7 +230,7 @@ Rocky9 | hdp-slave11 | 192.168.8.11/24 | /data/hdp-dn | Datanode, NodeManager
### 修改 slaves
- 编辑 $HADOOP_HOME/etc/hadoop/slaves替换成全部的 slave 主机,参考内容如下
```txt
```
hdp-slave10
hdp-slave11
```

View File

@@ -14,6 +14,10 @@ Rocky8 | 编译服务器 | - | 编译工具
Rocky9 | hive-hs20 | 192.168.8.20/24 | Hive Server, Tez
Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0, Tez
## 前提
- [已部署好 hadoop 2.10](/post/hdp2)
- [已部署好 hive 2.3.10](/post/hive2)
## 准备 protoc 2.5.0 环境
- 在**编译服务器**上执行如下操作
- 下载源码,解压

View File

@@ -11,7 +11,11 @@ categories: ["hadoop"]
操作系统 | 主机名 | 地址 | 运行组件
---- | ---- | ---- | ----
Rocky9 | hive-hs20 | 192.168.8.20/24 | Hive Server
Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore
## 前提
- [已部署好 hadoop 2.10](/post/hdp2)
- [已部署好 mysql 8](/post/mysql-install/#安装-mysql84-通用二进制包)
## 服务器初始配置
- 在**全部主机**上执行如下操作
@@ -30,9 +34,7 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
```
## 创建 mysql 数据库
- 在 **hive-ms21** 上执行如下操作
- 部署 mysql8.0,略过
- 创建用户及其数据库,参考 sql 如下
- 在 **mysql** 创建用户及其数据库,参考 sql 如下
```sql
create user hive@'%' identified by 'Hive_1234';
create database hive default charset utf8mb4;
@@ -41,7 +43,7 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
## 复制 jdk 和 hadoop 环境
- 在**全部主机**上执行如下操作
- 从 hdp-nn 复制 jdk 和 hadoop 环境
- 从 **hdp-nn** 复制 jdk 和 hadoop 环境
```bash
scp -r hdp-nn:/opt/{jdk,hdp} /opt/
scp hdp-nn:/etc/profile.d/{jdk,hdp}.sh /etc/profile.d/
@@ -86,7 +88,7 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
<property>
<!-- mysql 地址 -->
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hive-ms21:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
<value>jdbc:mysql://mysql-ip:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
</property>
<property>
<!-- mysql 驱动 -->