Files
www.colben.cn/content/post/hbase.md
2026-03-27 20:02:15 +08:00

131 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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
```