hadoop 集群中安装 hbase 2.2

安装 hadoop 集群

参见:ubuntu 基于 docker 搭建 hadoop 3.2 集群

下载 hbase

镜像地址: http://mirrors.hust.edu.cn/apache/hbase/stable/

wget http://mirrors.hust.edu.cn/apache/hbase/stable/hbase-2.2.4-bin.tar.gz
tar -zxvf hbase-2.2.4-bin.tar.gz -C /usr/local/
vim /etc/profile
export HBASE_HOME=/usr/local/hbase-2.2.4
export PATH=$PATH:$HBASE_HOME/bin

修改 hbase 配置文件

先在主节点 h01 上配置

cd $HBASE_HOME/conf
ls
hadoop-metrics2-hbase.properties  hbase-env.sh      hbase-site.xml          log4j.properties
hbase-env.cmd                     hbase-policy.xml  log4j-hbtop.properties  regionservers

1. hbase-env.sh

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export HBASE_MANAGES_ZK=true

2. hbase-site.xml

<configuration>
        <property>
                <name>hbase.rootdir</name>
                <value>hdfs://h01:9000/hbase</value>
        </property>
        <property>
                <name>hbase.cluster.distributed</name>
                <value>true</value>
        </property>
        <property>
                <name>hbase.master</name>
                <value>h01:60000</value>
        </property>
        <property>
                <name>hbase.zookeeper.quorum</name>
                <value>h01,h02,h03</value>
        </property>
        <property>
                <name>hbase.zookeeper.property.dataDir</name>
                <value>/data/hbase/zoodata</value>
        </property>
</configuration>
mkdir -p /data/hbase/zoodata

3. regionservers

h01
h02
h03

配置其它节点

拷贝 hbase

cd
scp -r /usr/local/hbase-2.2.4 root@h02:/usr/local/
scp -r /usr/local/hbase-2.2.4 root@h03:/usr/local/

远程执行脚本

在本地写好脚本 todo.sh,注意使用 单引号 ',才不会展开环境变量

echo 'export HBASE_HOME=/usr/local/hbase-2.2.4
export PATH=$PATH:$HBASE_HOME/bin' >> /etc/profile
source /etc/profile
mkdir -p /data/hbase/zoodata

用 ssh 执行脚本

ssh root@h02 < ./todo.sh
ssh root@h03 < ./todo.sh

启动 hbase

root@h01:~# start-hbase.sh 
SLF4J: Class path contains multiple SLF4J bindings.
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: Found binding in [jar:file:/usr/local/hbase-2.2.4/lib/client-facing-thirdparty/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]
SLF4J: Class path contains multiple SLF4J bindings.
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: Found binding in [jar:file:/usr/local/hbase-2.2.4/lib/client-facing-thirdparty/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]
h03: running zookeeper, logging to /usr/local/hbase-2.2.4/bin/../logs/hbase-root-zookeeper-h03.out
h01: running zookeeper, logging to /usr/local/hbase-2.2.4/bin/../logs/hbase-root-zookeeper-h01.out
h02: running zookeeper, logging to /usr/local/hbase-2.2.4/bin/../logs/hbase-root-zookeeper-h02.out
running master, logging to /usr/local/hbase-2.2.4/logs/hbase--master-h01.out
: running regionserver, logging to /usr/local/hbase-2.2.4/logs/hbase--regionserver-h01.out
root@h01:~# jps
6437 Jps
6216 HRegionServer
6046 HMaster
5983 HQuorumPeer
root@h01:~# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
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: Found binding in [jar:file:/usr/local/hbase-2.2.4/lib/client-facing-thirdparty/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 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.2.4, r67779d1a325a4f78a468af3339e73bf075888bac, 2020年 03月 11日 星期三 12:57:39 CST
Took 0.0039 seconds                                                                                                                          
hbase(main):001:0> whoami
root (auth:SIMPLE)
    groups: root
Took 0.0476 seconds  

HMaster 秒退

上面看似成功了,可没过几秒,HMaster 进程就挂了

2020-04-07 15:18:54,246 ERROR [master/h01:16000:becomeActiveMaster] master.HMaster: Failed to become active master
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:1523)
	at org.apache.hadoop.hbase.master.HMaster.finishActiveMasterInitialization(HMaster.java:938)
	at org.apache.hadoop.hbase.master.HMaster.startActiveMasterManager(HMaster.java:2124)
	at org.apache.hadoop.hbase.master.HMaster.lambda$run$0(HMaster.java:580)
	at java.lang.Thread.run(Thread.java:748)

尝试修改配置文件,加上

        <property>
                <name>hbase.unsafe.stream.capability.enforce</name>
                <value>false</value>
        </property>

安装成功

hbase(main):030:0> t = create 't', 'cf'
Created table t
Took 2.5417 seconds                                                                                                                       
=> Hbase::Table - t
hbase(main):031:0>  t = get_table 't'
Took 0.0012 seconds                                                                                                                         
=> Hbase::Table - t
hbase(main):033:0>  t.put 'r', 'cf:q', 'v'
Took 0.1344 seconds                                                                                                                          hbase(main):034:0>  t.scan
ROW                                  COLUMN+CELL                                                                                             
 r                                   column=cf:q, timestamp=1586273863757, value=v 
1 row(s)
Took 0.0698 seconds 
hbase(main):036:0> t.disable
Took 1.4032 seconds                                                                                                                          
hbase(main):038:0> t.drop
Took 0.9014 seconds 
原创文章 338 获赞 621 访问量 50万+

猜你喜欢

转载自blog.csdn.net/itnerd/article/details/105374045