一开始尝试安装的是HBase 2.1.4 但是安装后部分功能无法启动。
从官网上下载hbase-2.0.5-bin.tar.gz文件后进行解压
[hadoop@localhost local]$ sudo tar -zxf /home/hadoop/下载/hbase-2.0.5-bin.tar.gz -C /usr/local
将解压的文件更名为hbase
[hadoop@localhost local]$ sudo mv /usr/local/hbase-2.0.5 /usr/local/hbase
配置环境变量
[hadoop@localhost ~]$ vim ~/.bashrc
# HBase Environment Variables
export HBASE_HOME=/usr/local/hbase
export PATH=$HBASE_HOME/bin:$PATH
export PATH=$HBASE_HOME/lib:$PATH
执行生效
[hadoop@localhost ~]$ source ~/.bashrc
添加HBase权限
将hbase下的所有文件的所有者改为hadoop
[hadoop@localhost ~]$ cd /usr/local/
[hadoop@localhost local]$ sudo chown -R hadoop ./hbase
查看安装结果
[hadoop@localhost hbase]$ hbase version
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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 2.0.5
Source code repository git://dd7c519a402b/opt/hbase-rm/output/hbase revision=76458dd074df17520ad451ded198cd832138e929
Compiled by hbase-rm on Mon Mar 18 00:41:49 UTC 2019
From source with checksum fd9cba949d65fd3bca4df155254ac28c
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
发现是java的jar包有两个一样的,于是移除其中的一个,这里我选择的是hbase中的slf4j-log4j12-1.7.25.jar
[hadoop@localhost local]$ sudo rm -rf /usr/local/hbase/lib/slf4j-log4j12-1.7.25.jar
再次执行HBase命令,问题解决。
[hadoop@localhost hbase]$ hbase version
HBase 2.0.5
Source code repository git://dd7c519a402b/opt/hbase-rm/output/hbase revision=76458dd074df17520ad451ded198cd832138e929
Compiled by hbase-rm on Mon Mar 18 00:41:49 UTC 2019
From source with checksum fd9cba949d65fd3bca4df155254ac28c
对文件/usr/local/hbase/conf/hbase-env.sh进行配置
配置JAVA_HOME,HBASE_CLASSPATH,HBASE_MANAGES_ZK.
HBASE_CLASSPATH设置为本机Hadoop安装目录下的conf目录(即/usr/local/hadoop/conf)
[hadoop@localhost hbase]$ vim /usr/local/hbase/conf/hbase-env.sh
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64
export HBASE_CLASSPATH=/usr/local/hadoop/conf
export HBASE_MANAGES_ZK=true
配置/usr/local/hbase/conf/hbase-site.xml
用命令vi打开并编辑hbase-site.xml,命令如下:
[hadoop@localhost hbase]$ vim /usr/local/hbase/conf/hbase-site.xml
修改hbase.rootdir,指定HBase数据在HDFS上的存储路径;将属性hbase.cluter.distributed设置为true。
假设当前Hadoop集群运行在伪分布式模式下,在本机上运行,且NameNode运行在9000端口。
hbase.rootdir指定HBase的存储目录;hbase.cluster.distributed设置集群处于分布式模式.
<configuration>
#配置在hdfs上的存储地址
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
#配置内置zk地址
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
<description>The directory shared by RegionServers.
</description>
</property>
#配置zk数据存放地址,这里配置的是: /usr/local/hadoop/zookeperdata
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/hadoop/zookeperdata</value>
<description>Property from ZooKeeper config zoo.cfg.
The directory where the snapshot is stored.
</description>
</property>
#.配置启用集群分布式运行
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
</configuration>
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
<description>
Controls whether HBase will check for stream capabilities (hflush/hsync).
Disable this if you intend to run on LocalFileSystem, denoted by a rootdir
with the 'file://' scheme, but be mindful of the NOTE below.
(如果你打算在本地文件系统上运行,请禁用此选项。)
WARNING: Setting this to false blinds you to potential data loss and
inconsistent system state in the event of process and/or node failures. If
HBase is complaining of an inability to use hsync or hflush it's most
likely not a false positive.
(将此设置为false会使您在节点故障时看不到潜在的数据丢失和进程中不一致的系统状态。如果HBase提示无法使用 hsync或hflush,那么它很可能不是一个误报。)
</description>
</property>
接下来测试运行HBase。
第一步:首先登陆ssh,之前设置了无密码登陆,因此这里不需要密码;再切换目录至/usr/local/hadoop ;再启动hadoop,如果已经启动hadoop请跳过此步骤。命令如下:
[hadoop@localhost ~]$ start-dfs.sh
Starting namenodes on [localhost]
Starting datanodes
Starting secondary namenodes [account.jetbrains.com]
[hadoop@localhost ~]$ start-hbase.sh
localhost: running zookeeper, logging to /usr/local/hbase/logs/hbase-hadoop-zookeeper-localhost.localdomain.out
running master, logging to /usr/local/hbase/logs/hbase-hadoop-master-localhost.localdomain.out
: running regionserver, logging to /usr/local/hbase/logs/hbase-hadoop-regionserver-localhost.localdomain.out
输入命令jps,能看到NameNode,DataNode和SecondaryNameNode都已经成功启动,表示hadoop启动成功
能看到HRegionServer、HMaster、HQuorumPeer,表示HBase启动成功
[hadoop@localhost ~]$ jps
51732 NameNode
53044 Jps
52839 HRegionServer #hbase msalve进程
51865 DataNode
52682 HMaster #hbase master进程
52110 SecondaryNameNode
52543 HQuorumPeer # ZooKeeper进程
通过默认端口号16010在浏览器中使用http://localhost:16010/master-status访问HBase
也可以在/usr/local/hbase/conf/hbase-site.xml文件夹中进行自定义
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
=======================================================================
博客写于:2019年3月30日21:14:55
hadoop 版本 3.1.2
尝鲜:安装了Hadoop 3.1.2后,准备安装HBase,比较了多个版本后,一开始准备安装HBase 2.1.4但是配置完后会提示
“错误: 找不到或无法加载主类 org.apache.hadoop.hbase.util.GetJavaProperty”,并且在使用时发现无法加载master、zk,多番查找资料后无法解决问题。
[hadoop@localhost local]$ hbase version
错误: 找不到或无法加载主类 org.apache.hadoop.hbase.util.GetJavaProperty
HBase 2.1.4
Source code repository git://bcd8553a5734/opt/hbase-rm/output/hbase revision=5b7722f8551bca783adb36a920ca77e417ca99d1
Compiled by hbase-rm on Tue Mar 19 19:05:06 UTC 2019
From source with checksum d210900ccde556a0bd80acd860998807
于是重新下载HBase 2.0.5进行安装,未出现上述问题。
贴一段摘自官网的建议:
建议使用Hadoop 2.x.
Hadoop 2.x速度更快,并且包含一些功能,例如短路读取(请参阅利用本地数据),这将有助于改善HBase随机读取配置文件。Hadoop 2.x还包含重要的错误修复程序,可以改善您的整体HBase体验。HBase不支持与早期版本的Hadoop一起运行。有关不同HBase版本的特定要求,请参阅下表。
Hadoop 3.x仍处于早期访问版本中,尚未经过HBase社区对生产用例的充分测试。
参考资料:
安装、环境变量
http://dblab.xmu.edu.cn/blog/install-hbase/
配置文件相关:
https://blog.csdn.net/smily_tk/article/details/82561859
https://blog.csdn.net/qq_33857413/article/details/82868411
日志包冲突的解决
https://blog.csdn.net/wangshuminjava/article/details/79994713
官方文档:
http://hbase.apache.org/book.html#hbase.secure.simpleconfiguration
=======================================================================