上一篇介绍了hbase 2.1 环境搭建–独立模式 Standalone Mode独立模式的安装,本文介绍hbase 2.1.X的完全分布式部署 Advanced - Fully Distributed
使用Hadoop 2.8.5 完全分布式HA高可用安装(二)–环境搭建中配置的Hadoop环境。
注意:除了上述配置以外,线上环境最好配置 NTP;并且设置【文件和进程数限制(ulimit)】需要设置的大一些。
hbase规划:
机器名称 | Master | ZooKeeper | RegionServer |
---|---|---|---|
node1 | yes | yes | no |
node2 | backup | yes | no |
node3 | no | yes | yes |
node4 | no | no | yes |
首先将hbase上传到4台机器的/data/program/目录下.
我们规划了node3和node4配置regionserver,所以:
在node1上修改/data/program/hbase-2.1.5/conf/regionservers
:
node3
node4
然后在conf下新建backup-masters 文件,该文件是master的备机,内容是node2。
[root@node1 conf]# cat backup-masters
node2
hbase.rootdir
hdfs://node2:9000/hbase
hbase.cluster.distributed
true
hbase.zookeeper.quorum
node1,node2,node3
hbase.zookeeper.property.dataDir
/opt/zookeeper/data
hbase.tmp.dir
/opt/hbase/data
hbase.regionserver.wal.codec
org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec
hbase.coprocessor.master.classes
org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint
hbase.master.loadbalancer.class
org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer
修改以下内容:
export JAVA_HOME=/data/program/jdk1.8.0_91
# 不适用hbase自带的zk
export HBASE_MANAGES_ZK=false
将所有配置同步到其他3台机器上,保证4台机器的所有配置相同。
我们在node1机器上启动
进入安装目录/data/program/hbase-2.1.5/bin
。执行./start-hbase.sh
命令:
[root@node1 bin]# ./start-hbase.sh
running master, logging to /data/program/hbase-2.1.5/bin/../logs/hbase-root-master-node1.out
node3: running regionserver, logging to /data/program/hbase-2.1.5/bin/../logs/hbase-root-regionserver-node3.out
node4: running regionserver, logging to /data/program/hbase-2.1.5/bin/../logs/hbase-root-regionserver-node4.out
node2: running master, logging to /data/program/hbase-2.1.5/bin/../logs/hbase-root-master-node2.out
jps查看进程:
[root@node1 bin]# jps
5447 NameNode
45400 HMaster
4010 QuorumPeerMain
45562 Jps
5741 DFSZKFailoverController
[root@node2 conf]# jps
3842 QuorumPeerMain
4933 NameNode
5081 JournalNode
44665 Jps
44618 HMaster
5003 DataNode
5215 DFSZKFailoverController
[root@node1 conf]# jps
3809 QuorumPeerMain
43602 HRegionServer
42745 JournalNode
42668 DataNode
43711 Jps
[root@node4 ~]# jps
43669 Jps
43559 HRegionServer
4536 JournalNode
4459 DataNode
可以看到,node1和node2上有HMaster进程(一主一备),node3和node4上有HRegionServer进程。
status
查看状态:
hbase(main):001:0> status
1 active master, 1 backup masters, 2 servers, 0 dead, 22.0000 average load
进入http://node1:16010/master-status
房屋控制台:
在任意一台机器上执行./hbase shell
命令进入shell:
[root@node4 bin]# ./hbase shell
2019-07-18 17:17:53,121 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.5, r0ba7cc01a13dbb7fec8e6c5d599fc8b4936bae61, Tue May 28 22:25:02 UTC 2019
Took 0.0043 seconds
hbase(main):001:0> create 'test', 'cf'
Created table test
Took 3.7511 seconds
=> Hbase::Table - test
hbase(main):003:0> list 'test'
TABLE
test
1 row(s)
Took 0.0670 seconds
=> ["test"]
hbase(main):002:0> put 'test', 'row1', 'cf:a', 'value1'
Took 0.3924 seconds
hbase(main):003:0> put 'test', 'row2', 'cf:b', 'value2'
Took 0.0292 seconds
hbase(main):004:0> put 'test', 'row3', 'cf:c', 'value3'
Took 0.0113 seconds
hbase(main):004:0> scan 'test'
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1563441734398, value=value1
row2 column=cf:b, timestamp=1563441738877, value=value2
row3 column=cf:c, timestamp=1563441741609, value=value3
3 row(s)
Took 0.3300 seconds
hbase(main):005:0>
OK,至此完全分布式搭建完成。