下载和版本选择
当前我下载的是2.0.4的稳定版,这也是当前公司集群布置的版本,靠谱!现在很多公司还在用0.9x/1.x版本,2.x版本相对来说无论是稳定性还是性能都有了较大提升,如果不是为了考虑兼容,直接下载2.x版本即可。
安装Java环境
- 不再赘述
解压安装包
如下命令 tar -zxf hbase-2.0.4-bin.tar.gz
bin
CHANGES.md
conf
docs
hbase-webapps
LEGAL
lib
LICENSE.txt
NOTICE.txt
README.txt
RELEASENOTES.md
其中
- bin为启动停止脚本
- conf为配置文件
- lib为相关依赖jar包
配置
conf/hbase-env.sh中打开注释,如下设置JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.17
conf/hbase-site.xml中如下设置数据存储位置
<configuration>
//Here you have to set the path where you want HBase to store its files.
<property>
<name>hbase.rootdir</name>
<value>file:/home/wenzhou/data/hbase</value>
</property>
//Here you have to set the path where you want HBase to store its built in zookeeper files.
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/wenzhou/data/zookeeper</value>
</property>
</configuration>
这里hbase.rootdir指定数据存储位置,我们这里只是单机安装测试,实际集群部署指定为hdfs://xxx:port即可;单机部署时只需要hbase.zookeeper.property.dataDir指定zookeeper位置来讲分布式的zookeeper数据保存到本地。
正式使用分布式zookeeper协调的的话,还需要指定分布式属性和zookeeper集群位置,如下
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>test1.dfs.shbt.qihoo.net,test2.dfs.shbt.qihoo.net</value>
</property>
开启和测试
bin/start-hbase.sh开启hbase服务,bin/stop-hbase.sh停止hbase服务。此时可以直接如下运行shell命令行,操作hbase。
bin/hbase shell
输入list 显示所有可用表
推荐文档
- https://www.yiibai.com/hbase 快速学习hbase安装和命令
- 《hbase实战》 学习hbase基本原理和编程接口
- 《hbase权威指南》 深入理解hbase,了解设计思想
原创,转载请注明来自