WSL 环境中安装 HBase(前置条件 Hadoop 已安装并正在运行)

本文介绍了在WSL环境中安装HBase的详细步骤。


主要内容包括:

1)安装前需确保Hadoop、Java和SSH已正确配置;

2)通过清华镜像下载HBase并解压至/usr/local目录;

3)配置环境变量和核心配置文件hbase-site.xml;

4)启动HBase并验证进程。


文章特别解决了XML配置文件格式错误导致的启动问题,最终通过jps命令确认HMaster和HRegionServer进程正常运行,并通过HBase Shell进行基础验证。


整个过程依托已有的Hadoop环境,为大数据生态系统的搭建提供了完整指导。

WSL 环境中安装 HBase


HBase 是大数据生态中的重要组件,它提供面向海量数据的实时读写能力。


你之前已经在 WSL 里装好了 Hadoop,现在安装 HBase 会非常顺畅。因为 HBase 可以运行在 HDFS 之上,正好与你现有的环境完美衔接。


在 WSL 环境中安装 HBase 是完全可行的。下面我为你准备一个详细的安装和配置步骤。


📋 安装前准备

在开始之前,请确认以下几点:

  1. Hadoop 已安装并正在运行 :HBase 需要 HDFS 作为底层存储。你可以用 jps 命令检查一下,看输出结果中是否包含 NameNodeDataNode 这两个进程。

  2. Java 环境已配置 :用 java -version 检查一下,确保是 Java 8。

  3. SSH 服务已启动 :用 sudo service ssh status 确认一下 SSH 是激活状态。

bash 复制代码
mumu@MuJinqiu:~$ jps
577275 Jps
mumu@MuJinqiu:~$ start-all.sh
WARNING: Attempting to start all Apache Hadoop daemons as mumu in 10 seconds.
WARNING: This is not a recommended production deployment configuration.
WARNING: Use CTRL-C to abort.
Starting namenodes on [localhost]
Starting datanodes
Starting secondary namenodes [MuJinqiu]
Starting resourcemanager
Starting nodemanagers
mumu@MuJinqiu:~$ jps
578264 DataNode
578745 ResourceManager
579418 Jps
578970 NodeManager
578092 NameNode
578519 SecondaryNameNode
mumu@MuJinqiu:~$ sudo service ssh status
[sudo] password for mumu:
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/usr/lib/systemd/system/ssh.service; disabled; preset: enabled)
     Active: active (running) since Wed 2026-05-27 10:14:52 CST; 2 days ago
TriggeredBy: ● ssh.socket
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 1870 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 1872 (sshd)
      Tasks: 1 (limit: 19181)
     Memory: 2.5M (peak: 23.0M)
        CPU: 173ms
     CGroup: /system.slice/ssh.service
             └─1872 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

May 27 10:15:14 MuJinqiu sshd[2002]: pam_unix(sshd:session): session opened for user mumu(uid=1000) by mumu(uid=0)
May 29 16:56:28 MuJinqiu sshd[578020]: Accepted publickey for mumu from 127.0.0.1 port 37504 ssh2: ED25519 SHA256:RzhuqzaoT+2uf1JxD+ipZtB87ougxSn4dT8rg>
May 29 16:56:28 MuJinqiu sshd[578020]: pam_unix(sshd:session): session opened for user mumu(uid=1000) by mumu(uid=0)
May 29 16:56:31 MuJinqiu sshd[578020]: pam_unix(sshd:session): session closed for user mumu
May 29 16:56:31 MuJinqiu sshd[578199]: Accepted publickey for mumu from 127.0.0.1 port 37520 ssh2: ED25519 SHA256:RzhuqzaoT+2uf1JxD+ipZtB87ougxSn4dT8rg>
May 29 16:56:31 MuJinqiu sshd[578199]: pam_unix(sshd:session): session opened for user mumu(uid=1000) by mumu(uid=0)
May 29 16:56:33 MuJinqiu sshd[578459]: Accepted publickey for mumu from 127.0.0.1 port 51636 ssh2: ED25519 SHA256:RzhuqzaoT+2uf1JxD+ipZtB87ougxSn4dT8rg>
May 29 16:56:33 MuJinqiu sshd[578459]: pam_unix(sshd:session): session opened for user mumu(uid=1000) by mumu(uid=0)
May 29 16:56:39 MuJinqiu sshd[578827]: Accepted publickey for mumu from 127.0.0.1 port 46500 ssh2: ED25519 SHA256:RzhuqzaoT+2uf1JxD+ipZtB87ougxSn4dT8rg>
May 29 16:56:39 MuJinqiu sshd[578827]: pam_unix(sshd:session): session opened for user mumu(uid=1000) by mumu(uid=0)
lines 1-24/24 (END)

✅ Hadoop 已成功启动(NameNode、DataNode 等进程都在)

✅ SSH 服务正常运行

现在可以开始安装 HBase 了。


📦 第一步:下载与解压

打开你的 MobaXterm,连接到 WSL 终端,按以下步骤操作:

下载 HBase :在终端用 wget 下载

bash 复制代码
cd ~

# 使用清华大学镜像下载(推荐)
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/hbase-2.5.13-bin.tar.gz

这里有巨坑!!!版本不兼容,安装到最后了,告诉你版本不兼容。


找到原因了!日志最后有一个关键的 Netty 错误java.lang.IllegalArgumentException: object is not an instance of declaring class)。这是 HBase 2.5.13 与 Hadoop 3.3.6 之间的一个已知兼容性问题,与 Netty 版本冲突有关。


晴天霹雳,还得删了重装。


使用较旧但兼容性更好的 HBase 版本(推荐)

HBase 2.5.13 和 Hadoop 3.3.6 组合容易出现这个问题。建议降级到 HBase 2.4.x 系列,该系列经过更充分的测试,与 Hadoop 3 兼容更稳定。

解压并移动到 /usr/local 目录

bash 复制代码
# 1. 解压
tar -zxvf hbase-2.5.13-bin.tar.gz

# 2. 移动到 /usr/local
# 将解压后的文件夹移动到 /usr/local 目录下,并重命名为 hbase
sudo mv hbase-2.5.13 /usr/local/hbase

# 3. 修改所有者(把 mumu 换成你的用户名)
# 修改文件夹的所有者,方便后续操作 (把 mumu 换成你的 WSL 用户名)
sudo chown -R mumu:mumu /usr/local/hbase

# 4. 配置环境变量
echo '# HBase Configuration' >> ~/.bashrc
echo 'export HBASE_HOME=/usr/local/hbase' >> ~/.bashrc
echo 'export PATH=$PATH:$HBASE_HOME/bin' >> ~/.bashrc
source ~/.bashrc

# 5. 验证
hbase version

重新加载配置,使配置生效。

bash 复制代码
source ~/.bashrc
bash 复制代码
mumu@MuJinqiu:~$ cd ~
wget https://dlcdn.apache.org/hbase/stable/hbase-2.6.2-bin.tar.gz
--2026-05-29 17:00:36--  https://dlcdn.apache.org/hbase/stable/hbase-2.6.2-bin.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2026-05-29 17:00:37 ERROR 404: Not Found.

mumu@MuJinqiu:~$

看到 404 Not Found 错误,说明这个 HBase 版本在官方源上已经不存在了。从搜索结果看,当前最新的稳定版本是 2.5.13 ,而不是 2.6.2。

bash 复制代码
mumu@MuJinqiu:~$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/hbase-2.5.13-bin.tar.gz
--2026-05-29 17:02:35--  https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/hbase-2.5.13-bin.tar.gz
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 341915534 (326M) [application/octet-stream]
Saving to: 'hbase-2.5.13-bin.tar.gz'

hbase-2.5.13-bin.tar.gz               100%[=========================================================================>] 326.08M  9.81MB/s    in 40s

2026-05-29 17:03:18 (8.10 MB/s) - 'hbase-2.5.13-bin.tar.gz' saved [341915534/341915534]

mumu@MuJinqiu:~$

下载成功!326MB 的文件 40 秒就下完了,速度很快。

继续解压和安装

bash 复制代码
mumu@MuJinqiu:~$ sudo mv hbase-2.5.13 /usr/local/hbase
mumu@MuJinqiu:~$ sudo chown -R mumu:mumu /usr/local/hbase
mumu@MuJinqiu:~$ echo '# HBase Configuration' >> ~/.bashrc
echo 'export HBASE_HOME=/usr/local/hbase' >> ~/.bashrc
echo 'export PATH=$PATH:$HBASE_HOME/bin' >> ~/.bashrc
source ~/.bashrc
mumu@MuJinqiu:~$
mumu@MuJinqiu:~$ hbase version
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
HBase 2.5.13
Source code repository git://buildbox.localdomain/home/apurtell/tmp/RM/hbase revision=6bdecfeb172bb0c19a94b6639546500fd7b3bb65
Compiled by apurtell on Mon Nov  3 17:06:55 PST 2025
From source with checksum 663340d9331b0a3eb413dc534718ff6cdc94df3a448e5b011d12d492e01a5a4dba633c8cd7e54c9b9fcf543ef409bc00faa0e0d037add7e2d3e0f726092b9dda
mumu@MuJinqiu:~$

✅ HBase 安装成功!hbase version 显示了版本信息(2.5.13)。

关于那些 SLF4J 警告:这是因为 Hadoop 和 HBase 各带了不同的日志实现,不影响使用,可以忽略。


现在配置 HBase
修改文件夹的所有者,方便后续操作 (把 mumu 换成你的 WSL 用户名)这步没看懂,直接用的sudo chown -R mumu:mumu /usr/local/hbase


你那样做是对的

命令 含义
sudo chown -R mumu:mumu /usr/local/hbase /usr/local/hbase 目录及其所有子文件的所有者(owner)和所属组(group)都设置为 mumu

因为你的 WSL 用户名就是 mumu(从终端提示符 mumu@MuJinqiu 可以看出),所以直接用 mumu:mumu 是正确的。


验证一下

bash 复制代码
ls -la /usr/local/hbase

你应该看到第一列显示 mumu mumu,表示所有者和组都是 mumu


⚙️ 第二步:配置环境变量

为了方便在任何地方都能执行 HBase 命令,我们来配置一下系统变量。

bash 复制代码
# 编辑 .bashrc 文件
nano ~/.bashrc

在文件的末尾,添加上面的这两行:

bash 复制代码
# HBase Configuration
export HBASE_HOME=/usr/local/hbase
export PATH=$PATH:$HBASE_HOME/bin

保存后退出,然后让它立即生效:

bash 复制代码
source ~/.bashrc

🛠️ 第三步:核心配置

接下来,我们需要修改 HBase 的几个核心配置文件。

  1. 配置 hbase-env.sh (Java 环境)

    bash 复制代码
    nano $HBASE_HOME/conf/hbase-env.sh

    在文件中找到 # export JAVA_HOME=/usr/java/jdk1.8.0/ 这一行,把它前面的 # 去掉,然后改成你电脑上 Java 8 的实际路径。

    bash 复制代码
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

    另外,再确认或添加下面这一行,让它使用 HBase 自带的 ZooKeeper:

    bash 复制代码
    export HBASE_MANAGES_ZK=true
  2. 配置 hbase-site.xml (核心运行参数)

    这个文件是关键,它决定了 HBase 如何运行。我们先清空它,再写入新的配置。

    bash 复制代码
    nano $HBASE_HOME/conf/hbase-site.xml

    把下面这段配置完整地复制到文件里并保存。这里我们配置的是单机伪分布式模式,数据将存储在 HDFS 上。

    XML 复制代码
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    <configuration>
        <property>
            <name>hbase.rootdir</name>
            <value>hdfs://localhost:9000/hbase</value>
        </property>
        <property>
            <name>hbase.cluster.distributed</name>
            <value>true</value>
        </property>
        <property>
            <name>hbase.zookeeper.property.dataDir</name>
            <value>/usr/local/hbase/zookeeper</value>
        </property>
        <property>
            <name>hbase.unsafe.stream.capability.enforce</name>
            <value>false</value>
        </property>
    </configuration>

🚀 第四步:启动与验证

在启动 HBase 之前,记得要先确保你的 Hadoop 是启动状态

启动 HBase

bash 复制代码
start-hbase.sh
bash 复制代码
mumu@MuJinqiu:/usr/local/hbase/conf$ start-hbase.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
2026-05-29T17:26:23,461 ERROR [main] conf.Configuration: error parsing conf hbase-site.xml
com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
 at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:701) ~[woodstox-core-5.3.0.jar:5.3.0]
        at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5590) ~[woodstox-core-5.3.0.jar:5.3.0]
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2791) ~[woodstox-core-5.3.0.jar:5.3.0]
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1121) ~[woodstox-core-5.3.0.jar:5.3.0]
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2847) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2781) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.loadProps(Configuration.java:2654) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2636) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.get(Configuration.java:1100) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:1154) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1559) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:71) ~[hbase-common-2.5.13.jar:2.5.13]
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:117) ~[hbase-common-2.5.13.jar:2.5.13]
        at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:131) ~[hbase-common-2.5.13.jar:2.5.13]
        at org.apache.hadoop.hbase.util.HBaseConfTool.main(HBaseConfTool.java:36) ~[hbase-server-2.5.13.jar:2.5.13]
Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
 at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:3015)
        at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2781)
        at org.apache.hadoop.conf.Configuration.loadProps(Configuration.java:2654)
        at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2636)
        at org.apache.hadoop.conf.Configuration.get(Configuration.java:1100)
        at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:1154)
        at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1559)
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:71)
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:117)
        at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:131)
        at org.apache.hadoop.hbase.util.HBaseConfTool.main(HBaseConfTool.java:36)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
 at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:701)
        at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5590)
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2791)
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1121)
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2847)
        ... 10 more
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
2026-05-29T17:26:24,301 ERROR [main] conf.Configuration: error parsing conf hbase-site.xml
com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
 at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:701) ~[woodstox-core-5.3.0.jar:5.3.0]
        at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5590) ~[woodstox-core-5.3.0.jar:5.3.0]
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2791) ~[woodstox-core-5.3.0.jar:5.3.0]
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1121) ~[woodstox-core-5.3.0.jar:5.3.0]
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2847) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2781) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.loadProps(Configuration.java:2654) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2636) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.get(Configuration.java:1100) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:1154) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1559) ~[hadoop-common-2.10.2.jar:?]
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:71) ~[hbase-common-2.5.13.jar:2.5.13]
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:117) ~[hbase-common-2.5.13.jar:2.5.13]
        at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:131) ~[hbase-common-2.5.13.jar:2.5.13]
        at org.apache.hadoop.hbase.zookeeper.ZKServerTool.main(ZKServerTool.java:60) ~[hbase-zookeeper-2.5.13.jar:2.5.13]
Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
 at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:3015)
        at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2781)
        at org.apache.hadoop.conf.Configuration.loadProps(Configuration.java:2654)
        at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2636)
        at org.apache.hadoop.conf.Configuration.get(Configuration.java:1100)
        at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:1154)
        at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1559)
        at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:71)
        at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:117)
        at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:131)
        at org.apache.hadoop.hbase.zookeeper.ZKServerTool.main(ZKServerTool.java:60)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
 at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
        at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:701)
        at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5590)
        at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2791)
        at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1121)
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2847)
        ... 10 more
running master, logging to /usr/local/hbase/logs/hbase-mumu-master-MuJinqiu.out
/usr/local/hbase/bin/hbase-daemon.sh: line 92: kill: (592323) - No such process

file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
: running regionserver, logging to /usr/local/hbase/logs/hbase-mumu-regionserver-MuJinqiu.out
: /usr/local/hbase/bin/hbase-daemon.sh: line 92: kill: (592534) - No such process
:
: file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
: SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
: Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <configuration>
:  at [row,col,system-id]: [20,0,"file:/usr/local/hbase/conf/hbase-site.xml"]
:       at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:3015)
:       at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2781)
mumu@MuJinqiu:/usr/local/hbase/conf$

错误很明确:hbase-site.xml 文件格式有问题 ------ XML 标签没有正确关闭。

从错误信息 Unexpected EOF; was expecting a close tag for element <configuration> 可以看出,文件在第 20 行左右被截断了,缺少 </configuration> 结束标签。


重新编辑 hbase-site.xml 文件


重新启动 HBase

bash 复制代码
# 先停止可能残留的进程
stop-hbase.sh

# 清理 HDFS 中的旧数据(如果之前启动过)
hdfs dfs -rm -r /hbase

# 重新启动
start-hbase.sh

# 查看进程
jps | grep -E "HMaster|HRegionServer"

# 进入 Shell 测试
hbase shell

bash 复制代码
mumu@MuJinqiu:/usr/local/hbase/conf$ cd $HBASE_HOME/conf
nano hbase-site.xml
mumu@MuJinqiu:/usr/local/hbase/conf$ stop-hbase.sh
no hbase master found
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ED25519 key fingerprint is SHA256:EXoO7pR7FmoSrrNjWh7Vi42x5btDZXBvUFF38+saN24.
This host key is known by the following other names/addresses:
    ~/.ssh/known_hosts:4: [hashed name]
    ~/.ssh/known_hosts:7: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])?

SSH 连接确认提示。输入 yes 然后回车。


为什么会出现这个提示?

这是因为 stop-hbase.sh 脚本尝试通过 SSH 连接到 127.0.0.1(本机)来停止 HBase 进程,但这是第一次连接,SSH 需要确认并保存主机密钥。输入 yes 后,这个提示就不会再出现了。


bash 复制代码
mumu@MuJinqiu:/usr/local/hbase/conf$ jps | grep -E "HMaster|HRegionServer"
596801 HMaster
597010 HRegionServer
mumu@MuJinqiu:/usr/local/hbase/conf$

🎉 HBase 启动成功!

你已经看到了 HMasterHRegionServer 两个进程,说明 HBase 正在运行。


现在进入 HBase Shell 测试

bash 复制代码
hbase shell

进入后(提示符变成 hbase:001:0>),执行:

text

bash 复制代码
list

应该显示:

text

复制代码
TABLE
0 row(s)
Took 0.xxxx seconds

验证进程

输入 jps 命令,如果看到了 HMasterHRegionServer 这两个进程,就表示 HBase 已经成功启动啦!

打开 HBase Shell

这是最直接的验证方式,也是你之后使用 HBase 的主要入口。

bash 复制代码
hbase shell

当命令提示符变成 hbase:001:0> 的时候,就说明安装全部完成了。

bash 复制代码
hbase:001:0> list
TABLE

ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet
        at org.apache.hadoop.hbase.master.HMaster.checkServiceStarted(HMaster.java:3230)
        at org.apache.hadoop.hbase.master.MasterRpcServices.isMasterRunning(MasterRpcServices.java:1164)
        at org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java)
        at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:415)
        at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:124)
        at org.apache.hadoop.hbase.ipc.RpcHandler.run(RpcHandler.java:102)
        at org.apache.hadoop.hbase.ipc.RpcHandler.run(RpcHandler.java:82)

For usage try 'help "list"'

Took 8.8584 seconds
hbase:002:0>

这个错误 ServerNotRunningYetException 表示 HBase Master 虽然进程在,但还没有完全启动就绪,无法接受请求。


这通常是 HBase 在初始化或等待底层依赖时出现的问题。


解决步骤:等待 1-2 分钟再试

HBase 首次启动需要时间初始化 ZooKeeper 和 HDFS 连接。


先退出 Shell:

text

复制代码
exit

等待 1-2 分钟后,重新进入 Shell 测试:

bash

复制代码
hbase shell

进入后执行:

text

复制代码
status

如果显示 1 active master, 0 backup masters, 1 servers, 0 dead, ... 说明正常了,再执行 list

bash 复制代码
hbase:002:0> ^C
hbase:002:0> exit
mumu@MuJinqiu:/usr/local/hbase/conf$ cd ~
mumu@MuJinqiu:~$ jps
578264 DataNode
578745 ResourceManager
578970 NodeManager
578092 NameNode
600140 Jps
596654 HQuorumPeer
596801 HMaster
597010 HRegionServer
578519 SecondaryNameNode
mumu@MuJinqiu:~$ hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.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.apache.logging.slf4j.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.5.13, r6bdecfeb172bb0c19a94b6639546500fd7b3bb65, Mon Nov  3 17:06:55 PST 2025
Took 0.0007 seconds
hbase:001:0> list
TABLE

ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet
        at org.apache.hadoop.hbase.master.HMaster.checkServiceStarted(HMaster.java:3230)
        at org.apache.hadoop.hbase.master.MasterRpcServices.isMasterRunning(MasterRpcServices.java:1164)
        at org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java)
        at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:415)
        at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:124)
        at org.apache.hadoop.hbase.ipc.RpcHandler.run(RpcHandler.java:102)
        at org.apache.hadoop.hbase.ipc.RpcHandler.run(RpcHandler.java:82)

For usage try 'help "list"'

Took 8.7909 seconds
hbase:002:0>

问题还在。从 jps 输出中多了一个 HQuorumPeer 进程,这表示 HBase 正在使用自己自带的 ZooKeeper。但核心问题仍然是 Master 服务没有完全就绪。


我们需要看一下日志,找到具体原因。同时,我们可以进行一次彻底的环境重置。


查看错误日志

请在终端执行以下命令,查看 HBase Master 的日志,找出启动失败的具体原因(请重点关注 ERRORWARN 信息):

bash

bash 复制代码
tail -100 /usr/local/hbase/logs/hbase-mumu-master-*.log

请将输出的最后 30 行左右的日志内容贴出来,这样我们就能知道是 HDFS 连接问题、ZooKeeper 问题,还是其他配置问题了。


后续省略吧,因为每个人遇到的情况不一样,没有参考价值了。


🎉 安装完成检查清单

步骤 命令/验证方法 预期结果
环境变量 echo $HBASE_HOME 显示 /usr/local/hbase
进程 jps 能看到 HMaster, HRegionServer 进程
Shell hbase shell 进入 hbase:001:0> 交互界面
基础操作 在 Shell 中输入 list 列出所有表,通常是空列表或系统表

试方案一(降级到 2.4.18)

我们开始执行方案一,降级到稳定版本 HBase 2.4.18。请按照以下步骤操作:

巨坑无比!!!这个版本也不兼容


找到根本原因了!java.lang.NullPointerException 导致 HMaster 启动失败。


这是一个兼容性问题,通常是因为 HBase 2.4.18 和 Hadoop 3.3.6 之间的某些 API 不匹配。


解决方案

由于时间已经花费很多,且这是版本兼容性问题,我建议:

使用 Docker 安装 HBase(最省事的方案)

Docker 可以避免 WSL2 环境下的版本兼容和网络问题。

bash 复制代码
# 1. 安装 Docker(如果还没装)
sudo apt update
sudo apt install docker.io -y
sudo service docker start
sudo usermod -aG docker $USER

# 2. 退出并重新登录 WSL(或重启终端)
exit
# 重新连接 MobaXterm

# 3. 拉取并运行 HBase Docker 镜像
docker run -d -p 2181:2181 -p 8080:8080 -p 8085:8085 -p 9090:9090 -p 9095:9095 -p 16000:16000 -p 16010:16010 -p 16201:16201 -p 16301:16301 \
  --name hbase \
  harisekhon/hbase:2.4.9

# 4. 等待 30 秒
sleep 30

# 5. 进入 HBase Shell
docker exec -it hbase hbase shell
list
方案 优点 缺点
Docker 一键运行,无需解决兼容性问题 需要学习 Docker 基本命令
HBase 2.3.7 原生 WSL 安装 可能仍有兼容性问题
暂时不装 HBase 节省时间 跳过这个组件

暂时放弃,不装了。


第一步:停止 HBase 并清理旧文件

bash 复制代码
# 1. 停止当前 HBase(如果还在运行)
stop-hbase.sh

# 2. 等待几秒确认进程已停止
sleep 3

# 3. 删除旧的 HBase 安装目录
sudo rm -rf /usr/local/hbase

# 4. 清理 HDFS 中的 HBase 数据
hdfs dfs -rm -r /hbase

第二步:下载并安装 HBase 2.4.18

bash 复制代码
# 1. 进入用户目录
cd ~

# 2. 使用清华大学镜像下载
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.4.18/hbase-2.4.18-bin.tar.gz

# 3. 解压
tar -zxvf hbase-2.4.18-bin.tar.gz

# 4. 移动到 /usr/local
sudo mv hbase-2.4.18 /usr/local/hbase

# 5. 修改所有者
sudo chown -R mumu:mumu /usr/local/hbase

第三步:配置 HBase

配置 hbase-env.sh

bash 复制代码
cd $HBASE_HOME/conf

# 编辑 Java 环境配置
nano hbase-env.sh

hbase-env.sh 末尾添加配置

bash 复制代码
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export HBASE_MANAGES_ZK=true

保存退出(Ctrl+XY → 回车)

配置 hbase-site.xml

bash 复制代码
# 清空并重新写入
> hbase-site.xml
nano hbase-site.xml

删除所有内容,完整粘贴以下配置:

xml

XML 复制代码
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://localhost:9000/hbase</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>/usr/local/hbase/zookeeper</value>
    </property>
    <property>
        <name>hbase.unsafe.stream.capability.enforce</name>
        <value>false</value>
    </property>
</configuration>

保存退出。

hbase环境变量还需要配置吗


不需要额外配置 。你已经在 ~/.bashrc 中配置过 HBASE_HOMEPATH,那些就是环境变量。

刚才在 hbase-env.sh 中添加的 JAVA_HOME 是 HBase 内部启动时使用的,两者不同:

配置文件 作用 你的状态
~/.bashrc 终端中执行 hbase 命令时能找到程序 ✅ 已配置
hbase-env.sh HBase 服务启动时指定用哪个 Java ⏳ 刚已添加

验证一下环境变量

bash 复制代码
# 检查 HBASE_HOME 是否正确
echo $HBASE_HOME
# 应该显示 /usr/local/hbase

# 检查 PATH 是否包含 HBase
echo $PATH | grep hbase
# 应该显示 /usr/local/hbase/bin

# 检查 hbase 命令是否可用
which hbase
# 应该显示 /usr/local/hbase/bin/hbase

如果上面都有输出,说明环境变量配置正确,可以启动 HBase 了。


第四步:启动并验证

bash 复制代码
# 1. 启动 HBase
start-hbase.sh

# 2. 等待 30 秒让服务初始化
sleep 30

# 3. 查看进程(应该看到 HMaster 和 HRegionServer)
jps | grep -E "HMaster|HRegionServer"

# 4. 进入 HBase Shell
hbase shell

进入 Shell 后(提示符变为 hbase:001:0>),执行:

text

复制代码
status 'simple'

如果显示类似 1 active master, 1 servers, ... 说明正常。

然后执行:

text

复制代码
list

应该显示 0 row(s)(没有报错)。


第五步:简单测试

在 HBase Shell 中继续执行:

text

复制代码
# 创建一张测试表
create 'test', 'cf'

# 插入一条数据
put 'test', 'row1', 'cf:name', 'Alice'

# 查询数据
get 'test', 'row1'

# 查看所有表
list

# 退出
exit

如果启动失败

查看日志:

bash

复制代码
tail -50 /usr/local/hbase/logs/hbase-mumu-master-*.log

把最后 30 行发给我。


现在开始执行第一步,把每一步的结果发给我,特别是 start-hbase.shhbase shell 的输出。

相关推荐
BAGAE6 天前
星链卫星数据获取:从太空安全到实时通信的技术革命
网络·数据结构·数据库·算法·云计算·hbase
JAVA面经实录9179 天前
HBase 知识点梳理(文档型 NoSQL)
大数据·数据库·nosql数据库·hbase
大大大大晴天11 天前
Flink-HBase生产问题排查:NoClassDefFoundError
flink·hbase
大大大大晴天️11 天前
Flink-HBase生产问题排查:NoClassDefFoundError
大数据·flink·hbase
muddjsv16 天前
HBase与Hadoop:基于什么开发?深度剖析与架构图
数据库·hadoop·hbase
muddjsv16 天前
HBase 与 Hadoop 安装与上手使用全指导
数据库·hadoop·hbase
段一凡-华北理工大学17 天前
工业领域的Hadoop架构学习~系列文章09:HBase列式数据库
数据库·人工智能·hadoop·架构·hbase·高炉炼铁·高炉炼铁智能化
muddjsv17 天前
Hadoop 与 HBase 深度剖析:从架构原理到实战应用
hadoop·架构·hbase
Irene199118 天前
(AI总结版)Docker + HBase 安装全过程总结(WSL2 + Win11)
docker·hbase
Irene199118 天前
Win11 安装 Docker Desktop 并配置 WSL 使用 Hbase
docker·hbase