轉:http://www.tech126.com/hadoop-hbase/
基于現有的Hadoop集群,來搭建Hbase的環境
整個過程還是比較簡單的
1. 下載Hbase源碼,并解壓
cp hbase-0.20.6.tar.gz /opt/hadoop/
cd /opt/hadoop/
tar zxvf hbase-0.20.6.tar.gz
ln -s hbase-0.20.6 hbase
2.修改hbase-env.sh,加入java環境,并修改log位置
export JAVA_HOME=/opt/java/jdk
export HBASE_LOG_DIR=/opt/log/hbase
export HBASE_MANAGES_ZK=true
3. 修改hbase-site.xml,配置hbase
<property>
<name>hbase.rootdir</name>
<value>hdfs://zw-hadoop-master:9000/hbase</value>
<description>The directory shared by region servers.</description>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
<description>The mode the cluster will be in. Possible values are
false: standalone and pseudo-distributed setups with managed Zookeeper
true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)
</description>
</property>
<property>
<name>hbase.master</name>
<value>hdfs://zw-hadoop-master:60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>zw-hadoop-slave225,zw-hadoop-slave226,zw-hadoop-slave227</value>
<description>Comma separated list of servers in the ZooKeeper Quorum. For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com". By default this is set to localhost for local and pseudo-distributed modes of operation. For a fully-distributed setup, this should be set to a full list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh this is the list of servers which we will start/stop ZooKeeper on.
</description>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/log/zookeeper</value>
<description>Property from ZooKeeper's config zoo.cfg.
The directory where the snapshot is stored.
</description>
</property>
幾個配置的說明:
- hbase.rootdir設置hbase在hdfs上的目錄,主機名為hdfs的namenode節點所在的主機
- hbase.cluster.distributed設置為true,表明是完全分布式的hbase集群
- hbase.master設置hbase的master主機名和端口
- hbase.zookeeper.quorum設置zookeeper的主機,官方推薦設置為3,5,7比較好
4. 編輯regionservers文件,設置regionservers的服務器,和hadoop的slaves一樣即可
5. 啟動Hbase
/opt/sohuhadoop/hbase/bin/start-hbase.sh
/opt/sohuhadoop/hbase/bin/stop-hbase.sh
Hbase默認只有一個Master,我們可以也啟動多個Master:
/opt/sohuhadoop/hbase/bin/hbase-daemon.sh start master
不過,其它的Master并不會工作,只有當主Master down掉后
其它的Master才會選擇接管Master的工作
Hbase也有一個簡單的web界面,來查看其狀態
http://10.10.71.1:60010/master.jsp
http://10.10.71.1:60030/regionserver.jsp
http://10.10.71.1:60010/zk.jsp