Hbase分散式安裝

wangmm0218發表於2014-04-18

前提

hbase 安裝的先決條件是先安裝好hadoop,zookeeper,因為我們使用獨立的zookeeper叢集。

Hadoop安裝參考:"hadoop1.1.2分散式環境搭建"  點選開啟連結

Zookeeper安裝參考:"zookeeper分散式安裝點選開啟連結

 

準備工作

伺服器資訊:

   

上傳hbase包

將hbase上傳到icity0伺服器的/home/hadoop/目錄中,解壓並且重新命名為hbase。如圖操作所示:

 

配置hbase對jdk,hadoop的依賴

進入hbase下面的conf目錄,

vi hbase-env.sh

 

此檔案中增加如下部分:

export JAVA_HOME=/usr/java/jdk1.7.0_09

export HBASE_MANAGES_ZK=false //告訴hbase不使用自帶的zookeeper

export HBASE_HOME=/home/hadoop/hbase 

export HADOOP_HOME=/home/hadoop/hadoop  //hadoop home目錄。

 

 

配置 hbase-site.xml檔案

編輯hbase-site.xml檔案,增加如下內容:

 

<property>

       <name>hbase.hregion.memstore.flush.size</name>

       <value>5242880</value>

      <description>

       Maximum desired file size for an HRegion.  If filesize exceeds

       value + (value / 2), the HRegion is split in two.  Default: 256M.

 

       Keep the maximum filesize small so we splitmore often in tests.

     </description>

 </property> 

 <property>

       <name>hbase.hregion.max.filesize</name>se.hregion.memstore.flush.size

       <value>20971520</value>

      <description>

       Maximum desired file size for anHRegion.  If filesize exceeds

       value + (value / 2), the HRegion is split in two.  Default: 256M.

 

      Keep the maximum filesize small so we split more often in tests.

     </description>

 </property>

   <property>

     <name>hbase.zookeeper.property.clientPort</name>

     <value>2181</value>

     <description>Property from ZooKeeper's config zoo.cfg.

     The port at which the clients will connect.

     </description>

   </property>

   <property>

     <name>hbase.zookeeper.quorum</name>

     <value>icity0,icity1,icity2</value>

     <description>Comma separated list of servers in the ZooKeeperQuorum.

     For example,"host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".

     By default this is set to localhost for local and pseudo-distributedmodes

     of operation. For a fully-distributed setup, this should be set to afull

     list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set inhbase-env.sh

     this is the list of servers which we will start/stop ZooKeeper on.

     </description>

  </property>

  <property>

     <name>zookeeper.session.timeout</name>

     <value>1200000</value>

     <description>Property from ZooKeeper's config zoo.cfg.

     The directory where the snapshot is stored.

     </description>

   </property>

  <property>

   <name>hbase.rootdir</name>

   <value>hdfs://icity0:9000/hbasedir</value>

 </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 (seehbase-env.sh)

  </description>

  </property>

 <property>

    <name>hbase.master</name>

   <value>icity0:60000</value>

  </property>

  <property>

 <name>dfs.replication</name>

 <value>2</value>

 </property>

 

注:dfs.replication這個引數的配置根據實際需要修改,如果需要複製5份,就填5.如果不配置,在hadoop-site.xml中也為配置的話,其預設複製3份。

配置regionservers檔案

 

編輯regionservers檔案,增加如下內容,見圖:

 

複製habase整個目錄

複製habase整個目錄到icity2,icity3伺服器。

 

 

 

配置環境變數

修改hadoop使用者的.bash_profile檔案。增加如下部分,如圖所示:

vi .bash_profile

 

是環境變數生效:

source .bash_profile

 

將上面的配置檔案scp到icity1 icity2伺服器上,然後source .bash_profile

 

啟動habase

經過上面配置完後,可以通過bin/start-hbase.sh命令啟動hbase叢集。注意啟動hbase前,先要啟動hadoop和zookeeper叢集。

啟動hbase

bin/start-hbase.sh

 

啟動報錯:

 

由於之前在編輯regionservers檔案是未將localhost刪除,而是#localhost了。故先停止hbase後,將所有伺服器上的regionservers 檔案中的#localhost刪除掉,重新啟動hbase。

 

啟動成功日誌及程式:

mastericity0

Icity1 jps檢視:

 

啟動成功後,可以通過http://localhost:60010檢視hbase的管理頁面,如圖所示:

 

關閉hbase

bin/stop-hbase.sh

 

hbase shell

 

通過hbase shell 進入shell操作介面:

 

更多詳細操作參考官方文件。

相關文章