安装HBase之前需要先安装Hadoop,因为HBase是运行在Hadoop集群上的。安装Hadoop可以参照http://www.cnblogs.com/stGeekpower/p/3307289.html

一、安装准备及环境说明

运行在http://www.cnblogs.com/stGeekpower/p/3307289.html中的三台机器上hbase1作为master,hbase2、3作为region server。

HBase的版本为0.94.11-security,下载地址http://mirror.cc.columbia.edu/pub/software/apache/hbase/stable/hbase-0.94.11-security.tar.gz

二、安装操作

下载后,先解压,然后进入conf目录,编辑配置:

1、修改hbase-site.xml配置文件,在configuration里添加

<property>
    <name>hbase.rootdir</name>
    <value>hdfs://hbase1:9000/hbase</value>
</property>
<property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
</property>
<property>
      <name>hbase.zookeeper.quorum</name>
      <value>hbase1,hbase2,hbase3</value>
</property><property>
      <name>hbase.zookeeper.property.dataDir</name>
      <value>/home/songtao/zookeeper_data</value>
</property>
<property>
    <name>hbase.master.info.bindAddress</name>
    <value>hbase1</value>
    <description>The bind address for the HBase Master web UI
    </description>
</property>

2、修改hbase-env.sh文件,加入:

export JAVA_HOME=/home/songtao/jdk1.6.0_35
export HBASE_MANAGES_ZK=true

3、编辑regionservers文件,添加两个RegionServer:

hbase2
hbase3

4、配置另外两台

将hbase安装文件拷贝到另两台机器:

$ scp -r hbase-0.94.11-security hbase2:/home/songtao/
$ scp -r hbase-0.94.11-security hbase3:/home/songtao/

三、运行&停止HBase

运行HBase之前必须先开启Hadoop,允许和停止命令如下:

sh /home/songtao/hbase-0.94.11-security/bin/start-hbase.sh
sh /home/songtao/hbase-0.94.11-security/bin/stop-hbase.sh

运行后会看到如下几个进程,hadoop、hbase相关,两个图分别是master和regionserver

image

image

四、测试

1、进入hbase shell,用status命令查看集群状态,如下:

image

2、建一个测试表:

hbase(main):005:0> create 't1','f1'

image

3、登录另外两台机器查看数据是否能查到:

查看hdfs,t1已经生成:

image

进入hbase shell 查询:

image

4、另外可以通过web页面查看集群状态等(需要设置好本地hosts):

http://hbase1:60010

五、配置过程中遇见的各种问题

在成功配置好集群后进入shell遇见了各种问题,在此不详细叙述,可以参考http://samwalt.iteye.com/blog/1099348文章中提到的解决方法解决。

需要注意的是hadoop临时文件、防火墙、文件访问权限、hdfs的格式化、hosts设置、zookeeper数据清空等问题。

posted on 2013-09-08 13:24  码农是一种职业  阅读(2245)  评论(0编辑  收藏  举报