解決基於Hadoop3.1.3下 HMaster啓動不起來(Hadoop 3.1.3 + HBase 2.2.4 )

背景

最近在搭建基於Hadoop 3的分佈式框架。
在安裝完成配置後HBase 2.2.4, HMaster啓動不起來,報錯內容如下:

2020-07-05 00:08:25,250 ERROR [master/hadoop130:16000:becomeActiveMaster] master.HMaster: ***** ABORTING master hadoop130,16000,1593878901091: Unhandled exception. Starting shutdown. *****
java.lang.IllegalStateException: The procedure WAL relies on the ability to hsync for proper operation during component failures, but the underlying filesystem does not support doing so. Please check the config value of 'hbase.procedure.store.wal.use.hsync' to set the desired level of robustness and ensure the config value of 'hbase.wal.dir' points to a FileSystem mount that can provide it.
        at org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore.rollWriter(WALProcedureStore.java:1092)
        at org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore.recoverLease(WALProcedureStore.java:424)
        at org.apache.hadoop.hbase.procedure2.ProcedureExecutor.init(ProcedureExecutor.java:586)
        at org.apache.hadoop.hbase.master.HMaster.createProcedureExecutor(HMaster.java:1522)
        at org.apache.hadoop.hbase.master.HMaster.finishActiveMasterInitialization(HMaster.java:937)
        at org.apache.hadoop.hbase.master.HMaster.startActiveMasterManager(HMaster.java:2114)
        at org.apache.hadoop.hbase.master.HMaster.lambda$run$0(HMaster.java:579)
        at java.lang.Thread.run(Thread.java:748)

分析

網上好多文章說配置hbase.unsafe.stream.capability.enforce=false就能解決,但根據我查閱官方文檔說使用HDFS,需要將hbase.unsafe.stream.capability.enforce設置爲true,因爲hbase.unsafe.stream.capability.enforce=false存在丟失數據的風險,不能用於生產環境。

在【2.3. Pseudo-Distributed Local Install】小節下,說使用HDFS需要將hbase.unsafe.stream.capability.enforce設置爲true

In this example, HDFS is running on the localhost at port 8020. Be sure to either remove the entry for hbase.unsafe.stream.capability.enforce or set it to true.

通過查閱官方文檔,在【Building Apache HBase】下,有一句話說HBase默認是基於Hadoop 2.x進行編譯的。

158.1.3. Building against various hadoop versions.

HBase supports building against Apache Hadoop versions: 2.y and 3.y (early release artifacts). By default we build against Hadoop 2.x.

如果我們需要使用Hadoop 3.x + HBase,則需要自己編譯。

參考

  1. HBase 2.2.2 on Hadoop 3.2.1源碼編譯
  2. hbase-error-illegalstateexception-when-starting-master-hsync

源碼編譯HBase

步驟

  1. 使用安裝Java 1.8 的機器
  2. 安裝Maven
  3. 下載HBase源碼與編譯
  4. 安裝

安裝Maven

# 下載Maven 3.6.3
$ cd /opt/software
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
$ tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /opt/module/
 
# 配置環境變量
$ sudo vi /etc/profile.d/env.sh
#=================================
# MAVEN
M2_HOME=/opt/module/apache-maven-3.6.3
export PATH=$M2_HOME/bin:$PATH
#=================================
 
$ source /etc/profile.d/env.sh
$ mvn -v
 
# 配置阿里雲倉庫
$ sudo vi /opt/module/apache-maven-3.6.3/conf/settings.xml
#=================================
<mirrors>
    <mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>central</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
</mirrors>
#=================================

下載HBase源碼與編譯

# 下載HBase源碼
$ cd /opt/software
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.2.4/hbase-2.2.4-src.tar.gz 

$ tar -zxvf hbase-2.2.4-src.tar.gz
$ cd hbase-2.2.4

# 打包編譯
$ mvn clean package -DskipTests assembly:single -Dhadoop.profile=3.0 -Dhadoop-three.version=3.1.3

編譯完成後的安裝包在 hbase-assembly/target 目錄下

安裝HBase

# 源碼編譯完成後,打開目錄
$ cd /opt/software/hbase-2.2.4/hbase-assembly/target
$ cp hbase-2.2.4-bin.tar.gz /opt/software/
$ cd /opt/software/
$ tar -zxvf hbase-2.2.4-bin.tar.gz -C /opt/module/

# 配置hbase-env.sh
$ cd /opt/module/hbase-2.2.4/conf
$ vi hbase-env.sh
#===================================
export JAVA_HOME=/opt/module/java/jdk1.8.0_241
export HBASE_MANAGES_ZK=false
#===================================

# 修改配置hbase-site.xml
$ vi hbase-site.xml
#===================================
<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://hadoop130:9000/hbase</value>
  </property>
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>hadoop130,hadoop131,hadoop132</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/opt/module/apache-zookeeper-3.5.8-bin/zkData</value>
  </property>
</configuration>
#===================================

# 配置regionservers
$ vi regionservers
#===================================
hadoop130
hadoop131
hadoop132
#===================================

# 軟連接
$ ln -s /opt/module/hadoop-3.1.3/etc/hadoop/core-site.xml /opt/module/hbase-2.2.4/conf/core-site.xml
$ ln -s /opt/module/hadoop-3.1.3/etc/hadoop/hdfs-site.xml /opt/module/hbase-2.2.4/conf/hdfs-site.xml

# 配置環境變量
$ sudo vi /etc/profile.d/env.sh
#===================================
# HBASE
export HBASE_HOME=/opt/module/hbase-2.2.4
export PATH=$PATH:$HBASE_HOME/bin
#===================================

#配置生效
$ source /etc/profile.d/env.sh

# 分發HBase
$ cd /opt/module/
$ xsync hbase-2.2.4/

# 確保啓動Hadoop和Zookeeper
# 啓動HBASE
$ start-hbase.sh

# 查看
$ jps
72721 NameNode
72912 DataNode
75602 Jps
73220 NodeManager
74967 HMaster
73526 QuorumPeerMain
75145 HRegionServer
73391 JobHistoryServer

大功告成!

編譯的HBase資源包

hbase-2.2.4-bin-for-hadoop3.tar.gz

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章