环境:
操作系统Centos 5.5 64-bit
三台节点
ip 主机名
172.16.48.201 sg201
172.16.48.202 sg202
172.16.48.203 sg203
三点节点上已经布署好hadoop集群并正常启动
1.下载并解压hbase-0.94.0.tar.gz到/opt下
2.修改 hbase-env.sh ,hbase-site.xml,regionservers 这三个配置文件如下:
#hbase-env.sh需要注意的地方是 ZooKeeper的配置。这与 hbase-env.sh 文件相关,文件中 HBASE_MANAGES_ZK 环境变量用来设置是使用hbase默认自带的 Zookeeper还是使用独立的ZooKeeper。HBASE_MANAGES_ZK=false 时使用独立的,为true时使用默认自带的。
export HBASE_OPTS="-XX:+UseConcMarkSweepGC"
export JAVA_HOME=/usr/java/jdk1.7.0_05
export HBASE_HOME=/opt/hbase-0.94.0
export HADOOP_HOME=/opt/hadoop-1.0.3
export PATH=$PATH:/opt/hbase-0.94.0/bin
export HBASE_MANAGES_ZK=true
#hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>r
<value>hdfs://sg201:9000/hbase</value> //必须与你的hadoop主机名,端口号一致;Hbase该项并不识别机器IP,只能使用机器hostname才行
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>sg201,sg202,sg203</value> //hbase.zookeeper.quorum 的个数必须是奇数
</property>
<property>
<name>hbase.master</name>
<value>192.16.48.201:60000</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>60000</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2222</value> //必须与zookeeper的配置文件zoo.cfg里的配置项clientport一致
</property>
</configuration>
#regionservers3.将文件分发到集群其它节点上,启动hbase并检查是否成功
sg202
sg203
在HMaster即Namenode (sg201)启动HBase数据库(Hadoop集群必须已经启动)。 启动命令:
bin/start-hbase.sh
启动信息如下图
[root@sg201 hbase-0.94.0]# bin/start-hbase.sh在HMaster上用jps命令查看
root@sg201's password: sg203: starting zookeeper, logging to /opt/hbase-0.94.0/logs/hbase-root-zookeeper-sg203.out
sg202: starting zookeeper, logging to /opt/hbase-0.94.0/logs/hbase-root-zookeeper-sg202.out
sg201: Permission denied, please try again.
root@sg201's password:
sg201: starting zookeeper, logging to /opt/hbase-0.94.0/logs/hbase-root-zookeeper-sg201.out
starting master, logging to /opt/hbase-0.94.0/logs/hbase-root-master-sg201.out
sg202: starting regionserver, logging to /opt/hbase-0.94.0/logs/hbase-root-regionserver-sg202.out
sg203: starting regionserver, logging to /opt/hbase-0.94.0/logs/hbase-root-regionserver-sg203.out
[root@sg201 conf]# jps在datanode上用jps命令查看
12560 NameNode
30611 Jps
12861 JobTracker
26302 HQuorumPeer
28715 HMaster
12755 SecondaryNameNode
[root@sg202 logs]# jps
8194 Jps
1020 DataNode
1147 TaskTracker
7376 HQuorumPeer
7583 HRegionServer
然后输入如下命令进入hbase的命令行管理界面:?
1 | bin/hbase shell |
在hbase shell下 输入list,如下所示,列举你当前数据库的名称,如下图所示。如果你的Hbase没配置成功会抛出java错误。
[root@sg201 hbase-0.94.0]# bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.0, r1332822, Tue May 1 21:43:54 UTC 2012
hbase(main):001:0> list
TABLE
member
people
2 row(s) in 0.3980 seconds
我们也可以通过WEB页面来管理查看HBase数据库。
HMaster:http://172.16.48.201:60010/master.jsp
4.安装过程中碰到的问题及解决方法
问题1: 启动hbase时报错
[root@sg201 hbase-0.94.0]# bin/start-hbase.sh
root@sg201's password: sg203: starting zookeeper, logging to /opt/hbase-0.94.0/logs/hbase-root-zookeeper-sg203.out
sg202: starting zookeeper, logging to /opt/hbase-0.94.0/logs/hbase-root-zookeeper-sg202.out
sg203: SLF4J: Class path contains multiple SLF4J bindings.
sg203: SLF4J: Found binding in [jar:file:/opt/hbase-0.94.0/lib/slf4j-log4j12-
1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
sg203: SLF4J: Found binding in [jar:file:/opt/hadoop-1.0.3/lib/slf4j-log4j12-
1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
sg203: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
sg202: SLF4J: Class path contains multiple SLF4J bindings.
sg202: SLF4J: Found binding in [jar:file:/opt/hbase-0.94.0/lib/slf4j-log4j12-
1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
sg202: SLF4J: Found binding in [jar:file:/opt/hadoop-1.0.3/lib/slf4j-log4j12-
1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
sg202: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
解决方法:移除三台节点/opt/hbase-0.94.0/lib目录下的slf4j-log4j12-1.5.8.jar文件 参考:http://blog.csdn.net/yangxiaofei616/article/details/7381921
问题2: sg202的HRegionServer启动失败
解决方法:是由于这三点节点的系统时间不一致相差超过集群的检查时间30s
参考:http://blog.csdn.net/dajuezhao/article/details/6881631