解决基于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

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