Co2y's Blog

利用docker搭建hbase完全分布式集群

hbase分布式集群依赖于hadoop的HDFS,故首先搭建hadoop分布式环境。这里推荐:

1
https://github.com/kiwenlau/hadoop-cluster-docker

启动hadoop集群

1
./start-hadoop.sh

之后,考虑到hadoop与hbase版本的兼容性(具体可google)这里使用hbase-0.98-0.13-hadoop2,在master上:

1
2
3
wget http://mirrors.hust.edu.cn/apache/hbase/0.98.13/hbase-0.98.13-hadoop2-bin.tar.gz
tar -zxvf hbase-0.98.13-hadoop2-bin.tar.gz
cd hbase-0.98.13-hadoop2

修改conf/hbase-site.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<property>
<name>hbase.rootdir</name>
<value>hdfs://master.kiwenlau.com:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master</name>
<value>hdfs://master.kiwenlau.com:60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master.kiwenlau.com,slave1.kiwenlau.com,slave2.kiwenlau.com</value>
</property>

修改conf/regionservers

1
2
3
master.kiwenlau.com
slave1.kiwenlau.com
slave2.kiwenlau.com

修改conf/hbase-env.sh

1
export HBASE_MANAGES_ZK=true

scp到slave1和slave2上,也可使用docker -v挂载host上的同一hbase目录

1
2
scp -r /root/hbase-0.98.13-hadoop2 root@slave1:/root/hbase-0.98.13-hadoop2
scp -r /root/hbase-0.98.13-hadoop2 root@slave2:/root/hbase-0.98.13-hadoop2

启动hbase

1
root@master:~/hbase-0.98.13-hadoop2# bin/start-hbase.sh

测试hbase

1
2
3
root@master:~/hbase-0.98.13-hadoop2# bin/hbase shell
hbase(main):001:0> status
3 servers, 0 dead, 0.6667 average load

成功!