CentOS Hbase-1.2.0 安裝配置

c-xuan發表於2018-01-24

本篇介紹在四個節點的叢集中安裝Hbase,Hbase依賴於zookeeper,Hbase的安裝包內自帶zookeeper,本篇將配置使用單獨安裝的zookeeper。最後啟動時遇到Master is initializingerror telling master we are up的異常,通過修改hosts檔案得以解決。

安裝環境

  • 虛擬機器:VMware Workstation 12 Player
  • Linux版本:CentOS release 6.4 (Final)
  • hadoop版本:hadoop-2.6.0-cdh5.7.6
  • zookeeper版本:zookeeper-3.4.5-cdh5.7.6
  • hbase版本:hbase-1.2.0-cdh5.7.6
  • 叢集節點:
    • master:192.168.137.11 記憶體1G
    • slave1:192.168.137.12 記憶體512M
    • slave2:192.168.137.13 記憶體512M
    • slave3:192.168.137.14 記憶體512M
  • 前提:java已安裝,Hadoop已安裝,zookeeper已安裝,已配置ssh綿密登入,停掉防火牆等。

zookeeper安裝請參考CentOS上zookeeper叢集模式安裝配置,本篇將在四個節點上安裝Hbase,master作為HMaster,其他slave節點作為HRegionServer。

上傳安裝包

將下載的hbase-1.2.0-cdh5.7.6.tar.gz安裝包上傳到CentOS指定目錄,例如/opt
上傳方法很多,這裡在SecureCRT用rz命令。

解壓縮安裝包:

tar -zxf hbase-1.2.0-cdh5.7.6.tar.gz

重新命名資料夾:

mv hbase-1.2.0-cdh5.7.6 hbase

配置

修改環境變數:

vi /etc/profile
新增
export HBASE_HOME=/opt/hbase
export PATH=$HBASE_HOME/bin:$PATH

修改hbase配置檔案hbase-env.sh:

[root@slave1 conf]# pwd
/opt/hbase/conf
[root@slave1 conf]# vi hbase-env.sh

檔案中去掉一下兩行註釋並修改
export JAVA_HOME=/opt/jdk
export HBASE_MANAGES_ZK=false

因為zookeeper用的是單獨安裝的,不是hbase自帶的,所以上面配置為false.

修改conf檔案下的hbase配置檔案hbase-site.xml。

節點中間的內容是空的,增加如下配置:

<configuration>
        <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.zookeeper.quorum</name>
                <value>master,slave1,slave2,slave3</value>
        </property>
        <property>
                <name>hbase.zookeeper.property.dataDir</name>
                <value>/opt/zookeeper</value>
        </property>
</configuration>

修改conf資料夾下的regionservers檔案:

[root@slave1 conf]# vi regionservers 
slave1
slave2
slave3

複製安裝包到其他節點

[root@slave1 conf]# scp -rq /opt/hbase / root@slave1:/opt
[root@slave1 conf]# scp -rq /opt/hbase / root@slave2:/opt
[root@slave1 conf]# scp -rq /opt/hbase / root@slave3:/opt

啟動執行

HBase的啟動順序為:HDFS->Zookeeper->HBase,所以先保證hadoop和zookeeper已經啟動。

[root@master bin]# /opt/hbase/bin/start-hbase.sh
starting master, logging to /opt/hbase/bin/../logs/hbase-root-master-master.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave2: starting regionserver, logging to /opt/hbase/logs/hbase-root-regionserver-slave2.out
slave3: starting regionserver, logging to /opt/hbase/logs/hbase-root-regionserver-slave3.out
slave1: starting regionserver, logging to /opt/hbase/logs/hbase-root-regionserver-slave1.out
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

master節點上可看到如下程式:

[root@master bin]# jps
3089 Jps
2696 QuorumPeerMain
2520 SecondaryNameNode
2858 HMaster
2365 NameNode

slave節點上可看到如下程式:

[root@slave1 opt]# jps
2258 QuorumPeerMain
2339 HRegionServer
2154 DataNode
2506 Jps

如果沒有問題,那麼通過hbase shell檢視狀態可看到:

[root@master logs]# /opt/hbase/bin/hbase shell
2018-01-24 17:38:50,902 INFO  [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
2018-01-24 17:38:53,829 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hbase/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.0-cdh5.7.6, rUnknown, Tue Feb 21 15:18:14 PST 2017

hbase(main):001:0> status
1 active master, 0 backup masters, 3 servers, 0 dead, 0.6667 average load

我第一次檢視報錯:Master is initializing.

異常處理

雖然上面看到相關程式都已啟動,但是進入hbase shell後檢視狀態報錯:

[root@master bin]# /opt/hbase/bin/hbase shell
2018-01-24 16:40:15,994 INFO  [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
2018-01-24 16:40:18,484 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hbase/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.0-cdh5.7.6, rUnknown, Tue Feb 21 15:18:14 PST 2017

hbase(main):001:0> status

ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing
        at org.apache.hadoop.hbase.master.HMaster.checkInitialized(HMaster.java:2316)
        at org.apache.hadoop.hbase.master.MasterRpcServices.getClusterStatus(MasterRpcServices.java:783)
        at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java:55652)
        at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2170)
        at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:109)
        at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:133)
        at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:108)
        at java.lang.Thread.run(Thread.java:748)

檢視master節點的hbase目錄下的logs日誌檔案hbase-root-master-master.log,發現以下這段總在重複。

2018-01-24 17:29:32,752 INFO  [master:60000.activeMasterManager] master.ServerManager: Waiting for region servers count to settle; currently checked in 0, slept for 529904 ms, expecting minimum of 1, maximum of 2147483647, timeout of 4500 ms, interval of 1500 ms.

檢視slave節點的hbase目錄下的logs日誌檔案hbase-root-regionserver-slave1.log,發現如下一段異常:

2018-01-24 17:21:52,093 WARN  [regionserver/localhost/127.0.0.1:60020] regionserver.HRegionServer: error telling master we are up
com.google.protobuf.ServiceException: java.net.SocketException: Invalid argument
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:240)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient$BlockingRpcChannelImplementation.callBlockingMethod(AbstractRpcClient.java:336)
    at org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos$RegionServerStatusService$BlockingStub.regionServerStartup(RegionServerStatusProtos.java:8982)
    at org.apache.hadoop.hbase.regionserver.HRegionServer.reportForDuty(HRegionServer.java:2300)
    at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:914)
    at java.lang.Thread.run(Thread.java:748)

經過百度,發現slave節點上的/etc/hosts檔案含有這樣一行:

127.0.0.1   localhost slave2 slave2 localhost4 localhost4.localdomain4

改為如下再啟動hbase就正常了:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

相關文章