我的開發專案

我的部落格

最新協作平台活動

Wei-Yu, Chen 's Note‎ > ‎HBase‎ > ‎

HBase 0.20 叢集安裝

要求:

  • Java 1.6.x,或以後.
  • 只能搭配於 Hadoop 0.20.x.本篇預設已經先安裝並啟動好Hadoop叢集
 java 安裝所在 /usr/lib/jvm/java-6-sun
 Hadoop 的安裝家目錄
 /opt/hadoop
 Hadoop 的工作目錄
 /var/hadoop/hadoop-${user.name}

  • 叢集安裝HBase 從 0.20 後需要搭配 ZooKeeper
    • ZooKeeper 也有兩種啟動模式,一種是自己架設Zookeeper 並設定Hbase用於其上;另一種是使用HBase自帶的Zookeeper,本篇使用HBase自帶的方法
  • 叢集內的電腦需先運行 sudo ntpdate time.stdtime.gov.tw,
  • 本篇假設有兩台電腦:vpro 與 dx7200 。請先設定兩台能ssh 登入自己與對方機器並免輸入密碼
    • 注意:/etc/hostname 與 /etc/hosts 兩檔內的主機名稱需要一致,包括大小寫,以免設定quoram host 時混淆而發生錯誤

資料夾設定


 hbase 安裝家目錄  /opt/hbase
 hbase metadata 目錄
 /var/hadoop/hbase-${user.name}
 hbase 的 資料儲存目錄
 /var/hadoop/hbase-data
 hbase 在 hdfs上工作目錄
 hdfs://secuse.nchc.org.tw:9000/hbase


叢集安裝與設定步驟

先安裝第一台叢: vpro


1. 將hbase 解壓縮於 /opt ,並輸入以下指令

$ wget http://ftp.twaren.net/Unix/Web/apache/hadoop/hbase/hbase-0.20.2/hbase-0.20.2.tar.gz
$ sudo tar -zxvf hbase-*.tar.gz -C /opt/

$ sudo ln -sf /opt/hbase-0.20.2 /opt/hbase
$ sudo chown -R $USER:$USER /opt/hbase

2. 將下面內容加入到 /opt/hbase/conf/hbase-env.sh

/opt/hbase/conf/hbase-env.sh

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export HADOOP_CONF_DIR=/opt/hadoop/conf
export HBASE_HOME=/opt/hbase
export HBASE_LOG_DIR=/var/hadoop/hbase-logs
export HBASE_PID_DIR=/var/hadoop/hbase-pids
export HBASE_MANAGES_ZK=true
export HBASE_CLASSPATH=$HBASE_CLASSPATH:/opt/hadoop/conf


3. 設定 /opt/hbase/conf/hbase-site.xml

/opt/hbase/conf/hbase-site.xml

<configuration>
 <property>
    <name>hbase.rootdir</name>
    <value>hdfs://secuse.nchc.org.tw:9000/hbase</value>
    <description>The directory shared by region servers.
    </description>
  </property>
  <property>
    <name>hbase.tmp.dir</name>
    <value>/var/hadoop/hbase-${user.name}</value>
    <description>Temporary directory on the local filesystem.</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.zookeeper.property.clientPort</name>
      <value>2222</value>
      <description>Property from ZooKeeper's config zoo.cfg.
      </description>
    </property>
    <property>
      <name>hbase.zookeeper.quorum</name>
      <value>vpro,dx7200</value>
      <description>Comma separated list of servers in the ZooKeeper Quorum.
      </description>
    </property>
    <property>
      <name>hbase.zookeeper.property.dataDir</name>
      <value>/var/hadoop/hbase-data</value>
    </property>
</configuration>



4. 將 hadoop的設定放到 hbase 內

$ cd /opt/hbase/conf
$ cp /opt/hadoop/conf/core-site.xml ./
$ cp /opt/hadoop/conf/hdfs-site.xml ./
$ cp /opt/hadoop/conf/mapred-site.xml ./


5. 設定 /opt/hbase/conf/regionservers

vpro
dx7200


再安裝第二台電腦: dx7200

1. 複製第一台電腦的所有設定到此台機器內,因此於第二台電腦下指令

$ cd /opt/
$ sudo scp -R vpro:/opt/hbase ./
$ sudo chown $USER:$USER ./hbase


若你的環境還有第三台...第n台


請參考安裝第二台的方法,但在這之前,需要確定你的regionservers 與 hbase.zookeeper.quorum 的值滿足你叢集環境

執行方法

在執行以下動作之前,請先確定已啟動hadoop叢集。可用瀏覽器連到 50030 與 50070 port

啟動 hbase

於第一台電腦 ( vpro )電腦啟動hbase 叢集

$/opt/hbase/bin/start-hbase.sh

若沒有出現錯誤訊息,則代表成功,完整的程序可用  jps 來看。在第一台電腦上執行 jps 可以看到

$ jps
8790 HQuorumPeer
9078 HRegionServer
6598 NameNode
8868 HMaster
6897 JobTracker
6785 DataNode
7075 TaskTracker
21658 Jps

在第二台電腦上面執行jps可以看到

29186 Jps
17358 DataNode
17501 SecondaryNameNode
18617 HQuorumPeer
18772 HRegionServer
17644 TaskTracker

確定完整啟動 hbase 叢集,可以用瀏覽器連到 60010 port來檢視叢集環境,

 

Master: vpro:60000

Local logs, Thread Dump, Log Level


Master Attributes

Attribute NameValueDescription
HBase Version0.20.2, r834515HBase version and svn revision
HBase CompiledTue Nov 10 10:23:36 PST 2009, jdcryansWhen HBase version was compiled and by whom
Hadoop VersionUnknown, rUnknownHadoop version and svn revision
Hadoop CompiledUnknown, UnknownWhen Hadoop version was compiled and by whom
HBase Root Directoryhdfs://secuse.nchc.org.tw:9000/hbaseLocation of HBase home directory
Load average1.0Average number of regions per regionserver. Naive computation.
Regions On FS2Number of regions on FileSystem. Rough count.
Zookeeper Quorumdx7200:2222,vpro:2222Addresses of all registered ZK servers. For more, see zk dump.

Catalog Tables

TableDescription
-ROOT-The -ROOT- table holds references to all .META. regions.
.META.The .META. table holds references to all User Table regions

User Tables

Region Servers


AddressStart CodeLoad
dx7200:600301260783379077requests=0, regions=1, usedHeap=28, maxHeap=996
vpro:600301260783377613requests=0, regions=1, usedHeap=28, maxHeap=993
Total: servers: 2 requests=0, regions=2

Load is requests per second and count of regions loaded



執行 hbase

任一台電腦皆可執行以下指令,來測試hbase功能

$/opt/hbase/bin/hbase shell
hbase> # Type "help" to see shell help screen
hbase> help
hbase> # To create a table named "mylittletable" with a column family of "mylittlecolumnfamily", type
hbase> create "mylittletable", "mylittlecolumnfamily"
hbase> # To see the schema for you just created "mylittletable" table and its single "mylittlecolumnfamily", type
hbase> describe "mylittletable"
hbase> # To add a row whose id is "x", to the column "mylittlecolumnfamily:x" with a value of 'x', do
hbase> put "mylittletable", "x"
hbase> # To get the cell just added, do
hbase> get "mylittletable", "x"
hbase> # To scan you new table, do
hbase> scan "mylittletable"

停止 hbase

$/opt/hbase/bin/stop-hbase.sh

注意

  • 使用hbase自帶的 Zookeeper 已經整合了一些調整,因此省了不少麻煩,如自動設定 myid ,自動將叢集內電腦啟動Zookeeper ,並且將 原本 Zookeeper 要設定於 zoo.cfg 的設定值整合到 hbase-site.conf 內
  • /opt/hbase/conf/hbase-site.xml 內 hbase.zookeeper.quorum 的值需要與 hostname, hosts 內的 名稱一模一樣,否則會有錯
  • 有遇到錯誤訊息,可以參考 官方的錯誤排除網頁 http://wiki.apache.org/hadoop/Hbase/Troubleshooting
  • 遇到錯誤要重來,請確實注意幾點
    • 停掉 hbase 的服務,但不需停止hadoop
    • 刪除hdfs上得hbase工作目錄  bin/hadoop fs -rmr /hbase  


HBase Logo