HBase 完全分布式 安裝配置


需要環境:

      OS:      CentOS 5.5   (可以根據自己的需要來使用Linux環境)

      JDK:     1.6.0_32      (JDK 1.6版本的最新版本)

      hadoop:   Hadoop 1.0.3(目前Hadoop穩定的最新版本)

      hbase:    HBase 0.92.1(目前HBase穩定的最新版本,至少跟Hadoop1.0.3是兼容的)

(本文講述的是使用hbase自帶的zookeeper,所以沒有下載安裝zookeeper)

HBase作為架構在Hadoop上的一個BigTable,不得不說它有很大的應用空間,如下是安裝配置過程。(前提是已經在集群上正常部署Hadoop,並可以正常啟動和停止)

1. 下載並加壓HBase 0.92.1版本 

tar zxvf hbase-0.92.1.tar.gz

2. 修改配置文件

在修改之前,看到很多帖子說HBase配置中的master、slave等最好用主機名而不是ip地址,沒嘗試使用ip地址是怎樣的結果,不過使用主機名是可以運行起來的。不過注意,要在/etc/hosts中添加相對應的主機名的ip地址的匹配。

注:HBASE_MANAGES_ZK=true 表示要使用hbase自帶的zk來進行管理,沒有使用單獨的zk

  • conf/hbase-env.sh

  • conf/hbase-site.xml
<property> 
<name>hbase.rootdir</name> 
<value>hdfs://master:9000/hbase</value> 
</property> 
<property> 
<name>hbase.cluster.distributed</name> 
<value>true</value> 
</property> 
<property> 
<name>hbase.master</name> 
<value>hdfs://master:9002</value> 
</property> 

...

<property> 
<name>hbase.zookeeper.quorum</name> 
<value>slave1,slave2,slave3</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>/usr/hadoop/zookeeper</value> 
<description>Property from ZooKeeper's config zoo.cfg. The directory where the snapshot is stored. </description> 
</property>

默認的hbase-site.xml里面沒有屬性設置的,但是在"hbase-0.92.1\src\packages\conf-pseudo"這個路徑下有hbase-site.xml這個文件,雖然這個路徑是偽分布式的,但是在這個hbase-site.xml文件中的hbase.cluster.distributed屬性中的值是true。不知道為什么 HBase的設置是這樣的。不管怎樣,拿來進行了上述修改。

    • hbase.rootdir                                     設置hbase在hdfs上的目錄,主機名為hdfs的namenode節點所在的主機 
    • hbase.cluster.distributed                     設置為true,表明是完全分布式的hbase集群 
    • hbase.master                                     設置hbase的master主機名和端口 
    • hbase.zookeeper.quorum                    設置zookeeper的主機,建議使用單數
    • hbase.zookeeper.property.dataDir        設置zookeeper的數據路徑
  • 再修改Hadoop hdfs-site.xml下的一個屬性值。(記得其他的datanode也要進行修改)
<property> 
<name>dfs.datanode.max.xcievers</name> 
<value>4096</value> 
</property>

該參數限制了datanode所允許同時執行的發送和接受任務的數量,缺省為256,hadoop-defaults.xml中通常不設置這個參數。這個限制看來實際有些偏小,高負載下,DFSClient 在put數據的時候會報 could not read from stream 的 Exception。

An Hadoop HDFS datanode has an upper bound on the number of files that it will serve at any one time. The upper bound parameter is called xcievers (yes, this is misspelled). 

Not having this configuration in place makes for strange looking failures. Eventually you'll see a complain in the datanode logs complaining about the xcievers exceeded, but on the run up to this one manifestation is complaint about missing blocks. For example: 10/12/08 20:10:31 INFO hdfs.DFSClient: Could not obtain block blk_XXXXXXXXXXXXXXXXXXXXXX_YYYYYYYY from any node: java.io.IOException: No live nodes contain current block. Will get new block locations from namenode and retry...

3. 修改conf/regionservers 

將所有的datanode添加到這個文件,類似與hadoop中slaves文件,如下是我添加的內容:

slave1

slave2

slave3

4. 拷貝hbase到所有的節點

tar zcvf hbase-0.92.1.tar.gz hbase-0.92.1

scp hbase-0.92.1.tar.gz hadoop@192.168.0.3:~/

scp hdfs-site.xml hadoop@192.168.0.3:~/

然后進行相應的解壓、替換即可。

其他datanode節點按照相同的操作即可。

5. 啟動

bin/start-hbase.sh(注:首先至少要執行bin/start-dfs.sh啟動hdfs)

bin/hbase shell

如果正常啟動,在master和regionserver上應該有如下的jps信息

 master

 regionserver

6. web查看信息

http://master:60010/master.jsp 查看連點信息

http://master:60030/regionserver.jsp 查看regionserver信息 

http://master:60010/zk.jsp 查看zookeeper信息 

7. 測試數據

這部分沒有截圖,不過如果出現5中所展示的jps信息即可以進行正常的使用。操作如下:

bin/hbase shell
---
hbase(main):003:0> create 'test', 'cf' 0 row(s) in 1.2200 seconds hbase(main):003:0> list
TABLE test
1 row(s) in 0.0550 seconds hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1' 0 row(s) in 0.0560 seconds hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2' 0 row(s) in 0.0370 seconds hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3' 0 row(s) in 0.0450 seconds
hbase(main):008:0> get 'test', 'row1' 
COLUMN CELL 
cf:a timestamp=1288380727188, value=value1 
1 row(s) in 0.0400 seconds
hbase(main):012:0> disable 'test' 
0 row(s) in 1.0930 seconds 
hbase(main):013:0> drop 'test' 
0 row(s) in 0.0770 seconds
hbase(main):014:0> exit


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM