---
title: "HBase分布式安装手册 "
author: "thomas0988"
date: "2011-12-31T09:12:45Z"
tags: []
categories: ["开源软件"]
slug: "hbase"
draft: false
lastmod: "2011-12-31T09:12:45Z"
id: 1331157
url: "https://thomas0988.iteye.com/blog/1331157"
---

一、安装准备

> 1、下载HBASE 0.20.5版本：[http://www.apache.org/dist/hbase/hbase-0.20.5/](http://www.apache.org/dist/hbase/hbase-0.20.5/ "http://www.apache.org/dist/hbase/hbase-0.20.5/")
> 
> 2、JDK版本：jdk-6u20-linux-i586.bin
> 
> 3、操作系统：Linux s132 2.6.9-78.8AXS2smp #1 SMP Tue Dec 16 02:42:55 EST 2008 x86\_64 x86\_64 x86\_64 GNU/Linux
> 
> 4、默认前提是安装完hadoop 0.20.2版本：
> 
>     192.168.3.131 namenode
> 
>     192.168.3.132 datanode
> 
>     192.168.3.133 datanode

二、操作步骤（默认在namenode上进行）

> 1、拷贝以上文件到Linux的“/root”目录下。同时新建目录“/jz”。
> 
> 2、安装JDK，此步省略...
> 
> 3、解压hbase到/jz目录下。tar -zxvf hbase-0.20.5.tar.gz -C /jz
> 
> 4、修改/jz/hbase-0.20.5/conf/hbase-env.sh文件。指定本地的JDK安装路径：
> 
> ```
> export JAVA_HOME=/usr/java/jdk1.6.0_20
> ```
> 
> ```
> 5、修改/jz/hbase-0.20.5/conf/hbase-site.xml。内容如下：
> ```
> 
> ```
> <configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://m131:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master.port</name>
<value>60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>m131,s132,s133</value>
</property>
</configuration>

> ```
> 
> ```
> 6、修改/jz/hbase-0.20.5/conf/regionservers文件(同hadoop的slaves文件内容相同)，内容如下：
> ```
> 
> ```
> s132
s133
> ```
> 
> ```
> 7、 将 “/jz/hbase-0.20.5” 目录分别拷贝到192.168.3.132和192.168.3.133下。
> ```
> 
> ```
> 8、修改/etc/profile文件，在文件末尾加上环境变量：
> ```
> 
> ```
> export HBASE_HOME=/jz/hbase-0.20.5
export PATH=$PATH:$HBASE_HOME/bin
> ```
> 
> ```
> 将文件拷贝到192.168.3.132和192.168.3.133对应的目录下，分别在各个控制台输入：source /etc/profile，使之生效。
> ```
> 
> ```
> 9、修改/etc/hosts文件，如下：
> ```
> 
> ```
> # Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
192.168.3.131 m131
192.168.3.132 s132
192.168.3.133 s133
> ```
> 
> ```
> 然后将文件拷贝到192.168.3.132和192.168.3.133对应的目录下
> ```

```
三、启动HBase
```

> ```
> 1、通过shell脚本启动hbase。
> ```
> 
> ```
> sh /jz/hbase-0.20.5/bin/start-hbase.sh
> ```
> 
> ```
> 2、进入/jz/hbase-0.20.5/bin目录，执行hbsae shell命令，进入hbase控制台，显示如下。
> ```
> 
> ```
> [root@m131 conf]# hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Version: 0.20.5, r956266, Sat Jun 19 12:25:12 PDT 2010
hbase(main):001:0> 
> ```
> 
> 3、在hbase控制台输入list命令，如果正常执行，表示hbase启动成功。如下：2
> 
> ```
> hbase(main):001:0> list
0 row(s) in 0.0610 seconds
hbase(main):002:0> 
> ```
> 
> ```
> ４、WEB查看hbase
> ```
> 
> 查看Master [http://192.168.3.131:60010/master.jsp](http://192.168.3.131:60010/master.jsp) 查看Region Server [http://192.168.3.132:60030/regionserver.jsp](http://192.168.3.132:60030/regionserver.jsp) 查看ZK Tree [http://192.168.3.131:60010/zk.jsp](http://192.168.3.131:60010/zk.jsp)
> 
> ```
>  
> ```

四、一些异常的和注意事项

> 1、安装hbase 0.20.5版本自带了zookeeper-3.2.2，所以不需要单独安装zookeeper。
> 
> 2、hbase默认通过zookeeper管理，配置项在/jz/hbase-0.20.5/conf/hbase-env.sh文件中：
> 
> ```
> # Tell HBase whether it should manage it's own instance of Zookeeper or not.
# export HBASE_MANAGES_ZK=true
> ```
> 
> 如果需要采用自带安装的zookeeper，可以将注释取消，把true修改为false。否则启动hbase的时候将会提示地址被占用。不过不影响hbase正常使用。
> 
> 3、通过shell控制台想hbase插入中文数据将会报错，这是由于hbase中只是存放字节，采用程序将汉字改为字节录入即可。
> 
> 4、在hbase脚本中执行shell命令，如果出现以下错误，表示hbase中有节点不能正常运行。
> 
> ```
> NativeException: org.apache.hadoop.hbase.client.RetriesExhaustedException: Trying to contact region server 192.168.3.139:60020 for region .META.,,1, row '', but failed after 7 attempts.
> ```
> 
> ```
> 5、有疑问或是写的不对的地方欢迎大家发邮件交流：dajuezhao@gmail.com
> ```

[http://www.blogjava.net/ivanwan/archive/2011/01/21/343345.html](http://www.blogjava.net/ivanwan/archive/2011/01/21/343345.html)