HBase安装

来源:互联网 发布:linux bash是什么 编辑:程序博客网 时间:2024/06/05 18:50
HBase有单机模式、模拟分布式模式、以及全分布式模式安装方式。

首先下载HBase的稳定版,http://apache.fayea.com/hbase/stable/,这里下载1.2.6版本的bin文件,可以直接使用,不用重新编译,下载之后放到与hadoop目录相同的目录下,这里是/usr/local/目录。
1、单机配置Hbase
1 设置JAVA_HOME变量,打开hbase-env.sh文件,编辑JAVA_HOME变量到当前Java路径
这里写图片描述
2 编辑hbase-site.xml文件,对Hbase进行配置,设置数据目录到合适的位置,配置信息如下:

<configuration>
//Here you have to set the path where you want HBase to store its files.
<property>
<name>hbase.rootdir</name>
<value>file:/home/hadoop/HBase/HFiles</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/hadoop/zookeeper</value>
</property>
</configuration>

简单的两步HBase就配置完成了,可以通过start-hbase.sh脚本启动HBase,查看HBase是否配置成功。
这里写图片描述
提示Java虚拟机有问题,这里根据的意思是由于我们使用的是Java1.8版本,所以需要移除PermSize和MaxPermSize的支持,修改HBase配置文件,注释掉以下两行,再启动,就正常了。
这里写图片描述
将HBase的bin路径添加到PATH,以免每次启动都需要进入Hbase根目录去启动,在当前用户.bashrc文件下添加如下配置:
这里写图片描述
运行start-hbase.sh命令来启动Hbase即可。
2、模拟分布式安装Hbase
1 首先停掉启动的Hbase,修改hbase-site.xml文件,添加以下属性:

<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>

更改hbase.rootdir运行方式,使用hdfs:// URL语法,更改如下:

<property>
<name>>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>

然后重新启动HBase,启动时输出:
这里写图片描述
这时可以看到HBase创建目录到HDFS中,使用hadoop fs -ls /hbase命令查看时,会提示/hbase目录不存在,那么问题出在哪里呢?通过搜索,在stackoverflow找到了答案,意思是说,其实你的目录已经存在了,只是你使用这个命令看不到,需要使用hadoop fs -ls / 或者 hadoop fs -ls hdfs://localhost:9000/ 来查看hadoop的目录。这时,使用命令一次查看目录,就可以看到hbase在hdfs中的路径位置了:
这里写图片描述
到这里,HBase的单机模式和模拟分布式安装就介绍完了。