Hbase(一)【入门安装及高可用】
一.Zookeeper正常部署
Zookeeper集群的正常部署并启动
二.Hadoop正常部署
Hadoop集群的正常部署并启动
三.Hbase部署
1.下载
下载地址:https://hbase.apache.org/downloads.html
2.解压
当前安装版本为hbase-2.0.5,将Hbase解压至指定目录,改名为hbase
tar -zxvf hbase-2.0.5-bin.tar.gz -C /opt/module
mv /opt/module/hbase-2.0.5 /opt/module/hbase
3.相关配置
1)配置环境变量
修改my_env.sh
sudo vim /etc/profile.d/my_env.sh
添加以下内容
#HBASE_HOME
export HBASE_HOME=/opt/module/hbase
export PATH=$PATH:$HBASE_HOME/bin
source一下
source /etc/profile
将my_env.sh分发其他节点,都source一下
xsync /etc/profile.d/my_env.sh
source /etc/profile
2)修改hbase-env.sh
修改/hbase/conf/hbase-env.sh添加以下内容
export HBASE_MANAGES_ZK=false
3)修改hbase-site.xml
修改成以下内容
hbase.rootdir: 在hdfs的数据存储路径
hbase.zookeeper.quorum: zookeeper集群节点
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop102:8020/HBase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>hadoop102,hadoop103,hadoop104</value>
</property>
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
4)修改regionservers文件
Hregionserver节点配置,添加以下内容
hadoop102
hadoop103
hadoop104
4.分发文件
xsync hbase/
5.启动、关闭
方式一:群起
[hadoop@hadoop102 hbase]$ bin/start-hbase.sh
对应的停止服务:
[hadoop@hadoop102 hbase]$ bin/stop-hbase.sh
方式二:各节点单独启动
[hadoop@hadoop102 hbase]$ bin/hbase-daemon.sh start master
[hadoop@hadoop102 hbase]$ bin/hbase-daemon.sh start regionserver
注:在哪个节点启动master,哪个节点就是Hmaster。
提示:如果集群之间的节点时间不同步,会导致regionserver无法启动,抛出ClockOutOfSyncException异常。
修复方法
a、同步时间服务
b、属性:hbase.master.maxclockskew设置更大的值
<property>
<name>hbase.master.maxclockskew</name>
<value>180000</value>
<description>Time difference of regionserver from master</description>
</property>
6.验证
启动hbase(先启动zookeeper和hdfs)
[hadoop@hadoop102 ~]$ start-hbase.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hbase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
running master, logging to /opt/module/hbase/logs/hbase-atguigu-master-hadoop102.out
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/module/hbase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hadoop104: running regionserver, logging to /opt/module/hbase/logs/hbase-atguigu-regionserver-hadoop104.out
hadoop103: running regionserver, logging to /opt/module/hbase/logs/hbase-atguigu-regionserver-hadoop103.out
hadoop102: running regionserver, logging to /opt/module/hbase/logs/hbase-atguigu-regionserver-hadoop102.out
hadoop103: running master, logging to /opt/module/hbase/logs/hbase-atguigu-master-hadoop103.out
jps看一下
[hadoop@hadoop102 ~]$ myjps
================ hadoop102 =====================
3364 NameNode
3497 DataNode
24106 Jps
3117 QuorumPeerMain
23678 HRegionServer
23487 HMaster
================ hadoop103 =====================
2024 DataNode
1882 QuorumPeerMain
11037 HRegionServer
11533 Jps
================ hadoop104 =====================
9536 Jps
1879 QuorumPeerMain
9290 HRegionServer
2124 SecondaryNameNode
2014 DataNode
四.HMaster的高可用
目的:增加hadoop103作为Hmaster的备用节点
1)在hadoop102关闭hbase集群
stop-hbase.sh
2)在%hbase_home%/conf 下增加backup-masters文件
vim hbase/conf/backup-masters
添加以下内容
hadoop103
3)将backup-masters文件分发至其他节点
xsync hbase/conf/backup-masters
4)在hadoop102启动集群
start-hbase.sh
5)观察web页面:
6)验证
kill掉hadoop102的hmaster
[hadoop@hadoop102 module]$ jps
3364 NameNode
3497 DataNode
3117 QuorumPeerMain
23678 HRegionServer
23487 HMaster
24239 Jps
[hadoop@hadoop102 module]$ kill -9 23487
观察hadoop103