安装HBase
tar -zxvf hbase-1.2.5.tar.gz
配置环境变量
cd hbase-1.2.5
vi conf/hbase-env.sh:
export HBASE_MANAGES_ZK=false # 禁止Hbase管理zookeeper,意味着你要先手动启动zookeeper集群
export JAVA_HOME=/opt/jdk1.8.0_131
HBase配置文件
vi conf/hbase-site.xml:
<configuration>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://mycluster/hbase</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>c7003:2181,c7004:2181,c7005:2181</value>
</property>
</configuration>
mycluster是你的Hadoop集群名称
vi conf/regionservers:
c7001
c7002
c7003
vi conf/backup-masters:
c7003
启动HBase集群
bin/start-hbase.sh
访问 http://c7001:16010/ 可以查看hbase集群信息
如果需要停止集群,执行bin/stop-hbase.sh
验证集群
bin/hbase shell list create 'test', 'cf' list 'test' put 'test', 'row1', 'cf:a', 'value1' put 'test', 'row2', 'cf:b', 'value2' put 'test', 'row3', 'cf:c', 'value3' put 'test', 'row4', 'cf:d', 'value4' scan 'test' get 'test', 'row1' disable 'test' enable 'test'
如果HBase启动报错,检查你是否已经有其他zookeeper在运行或者zookeeper是否正常工作。
查看HDFS里的hbase目录内容:
hdfs dfs -ls /hbase