搭建高可用的hbase集群
紧接着搭建好的高可用hadoop集群基础上搭建靠可用的hbase集群
集群部署示意图 5台机子 (2台HMaster 3台regionservers)
weekend112 HMaster
weekend113 HMaster
weekend114 regionservers
weekend114 regionservers
weekend114 regionservers
第一步、上传hbase安装包并解压
第二步、配置hbase,要修改3个文件(首先zk集群已经安装好了)
注意:首先要把hadoop的hdfs-site.xml和core-site.xml 放到hbase/conf下
然后修改hbase-env.sh
export JAVA_HOME=/usr/java/jdk1.7.0_55
//告诉hbase使用外部的zk
export HBASE_MANAGES_ZK=false
修改hbase-site.xml文件
vim hbase-site.xml
<configuration>
<!-- 指定hbase在HDFS上存储的路径 -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://ns1/hbase</value>
</property>
<!-- 指定hbase是分布式的 -->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!-- 指定zk的地址,多个用“,”分割 -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>weekend114:2181,weekend115:2181,weekend116:2181</value>
</property>
</configuration>
指定regionservers
vim regionservers
远程复制到其他机子
scp -r ~/app/hbase-0.96.2-hadoop2/ weekend113:/home/zzq/app/
scp -r ~/app/hbase-0.96.2-hadoop2/ weekend114:/home/zzq/app/
scp -r ~/app/hbase-0.96.2-hadoop2/ weekend115:/home/zzq/app/
scp -r ~/app/hbase-0.96.2-hadoop2/ weekend116:/home/zzq/app/
第三步、启动hbase (要先启动hdfs)
现在weekend112使用start-hbase.sh启动HMaster,regionserver
在weekend113启动master
打开web网页
高可用的hbase就搭建好了。可以把主HMaster进程kill掉就能看是否能自动切换了。
第四步、使用hbase shell客户端
[zzq@weekend112 hbase-0.96.2-hadoop2]$ ./bin/hbase shell
创建表:
create 'mygirls' , {NAME => 'base_info' ,VERSION => 3 },{NAME => 'extra_info'}
hbase(main):006:0> describe 'mygirls'
DESCRIPTION ENABLED
'mygirls', {NAME => 'base_info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => ' true
ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERS
IONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '6
5536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'extra_info', DATA_
BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIO
NS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP
_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACH
E => 'true'}
1 row(s) in 0.3140 seconds
新增数据
hbase(main):008:0> put 'mygirls' , '0001' ,'base_info:name','zhangsan'
0 row(s) in 0.8770 seconds
hbase(main):009:0> put 'mygirls' , '0001' ,'base_info:age','18'
0 row(s) in 0.0320 seconds
hbase(main):011:0> get 'mygirls' , '0001'
COLUMN CELL
base_info:age timestamp=1480504779191, value=18
base_info:name timestamp=1480504705706, value=zhangsan
2 row(s) in 0.1570 seconds
好,这样就测试成功了。