https://www.apache.org/dyn/closer.lua/hbase/2.4.12/hbase-2.4.12-bin.tar.gz
节点角色配置
节点 | Master | ZooKeeper | RegionServer |
---|---|---|---|
node001 | yes | yes | yes |
node002 | backup | yes | yes |
node003 | no | yes | yes |
(base) [root@node001 bao]# tar -zxvf hbase-2.4.12-bin.tar.gz -C ../src
(base) [root@node001 bao]# cd ../src/hbase-2.4.12/conf
(base) [root@node001 conf]# $JAVA_HOME
-bash: /usr/local/java: 是一个目录
(base) [root@node001 conf]# vim hbase-env.shexport JAVA_HOME=/usr/local/java/
export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP="true"
export HBASE_CLASSPATH=/opt/src/hadoop-3.3.1/etc/hadoop/
export HBASE_MANAGES_ZK=false
<property><name>hbase.cluster.distributed</name><value>true</value></property><property><name>hbase.rootdir</name><value>hdfs://node001:8020/hbase</value></property><property><name>hbase.zookeeper.quorum</name><value>node001,node002,node003</value></property><property><name>hbase.zookeeper.property.dataDir</name><value>/tmp/zookeeper/data</value></property><property><name>hbase.unsafe.stream.capability.enforce</name><value>false</value></property>
(base) [root&#64;node001 conf]# vim regionservers
(base) [root&#64;node001 conf]# cat regionservers
node001.djin.com
node002.djin.com
node003.djin.com
(base) [root&#64;node001 conf]# pwd
/opt/src/hbase-2.4.12/conf
(base) [root&#64;node001 conf]# touch backup-masters
(base) [root&#64;node001 conf]# echo node002> backup-masters
(base) [root&#64;node001 hbase-2.4.12]# vim ~/.bashrc
#set HBASE_HOME
export HBASE_HOME&#61;/opt/src/hbase-2.4.12
export PATH&#61; $PATH:$HBASE_HOME/bin
(base) [root&#64;node001 ~]# ln -s $HADOOP_HOME/etc/hadoop/core-site.xml $HBASE_HOME/conf/core-site.xml
(base) [root&#64;node001 ~]# ln -s $HADOOP_HOME/etc/hadoop/hdfs-site.xml $HBASE_HOME/conf/hdfs-site.xml
(base) [root&#64;node001 hbase-2.4.12]# pscp -h /node.list ~/.bashrc ~/
到各节点激活配置
source ~/.bashrc
(base) [root&#64;node001 src]# pscp -h /node.list -r /opt/src/hbase-2.4.12 /opt/src/
(base) [root&#64;node001 bin]# cat myhadoop.sh
#!/bin/bashif [$# -lt 1]
thenecho "No Args Input..."exit;
ficase $1 in
"start")echo "&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;启动Hadoop集群&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;"echo "-----------------启动hdfs----------------"ssh node001 "/opt/src/hadoop-3.3.1/sbin/start-dfs.sh"sleep 5echo "-----------------启动yarn----------------"ssh node002 "/opt/src/hadoop-3.3.1/sbin/start-yarn.sh"sleep 5echo "-----------------启动historyserver----------------"ssh node001 "/opt/src/hadoop-3.3.1/bin/mapred --daemon start historyserver"sleep 5
;;
"stop")echo "&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;关闭Hadoop集群&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;"echo "-----------------关闭historyserver----------------"ssh node001 "/opt/src/hadoop-3.3.1/bin/mapred --daemon stop historyserver"sleep 5echo "-----------------关闭yarn----------------"ssh node002 "/opt/src/hadoop-3.3.1/sbin/stop-yarn.sh"sleep 5echo "-----------------关闭hdfs----------------"ssh node001 "/opt/src/hadoop-3.3.1/sbin/stop-dfs.sh"sleep 5
;;
*)echo "Input Args Error.."
;;
esac
(base) [root&#64;node001 bin]# myhadoop.sh start
(base) [root&#64;node001 data]# cat /home/djin/bin/start-zk-all
#! /bin/bash
for host in node001 node002 node003
do
ssh $host "/opt/src/zookeeper-3.6.3/bin/zkServer.sh start"
echo "$host zkServer is running"
done
(base) [root&#64;node001 data]# start-zk-all
(base) [root&#64;node001 data]# jps
8576 DataNode
9475 JobHistoryServer
8309 NameNode
9175 NodeManager
28008 QuorumPeerMain
28095 Jps
(base) [root&#64;node001 ssh]# start-hbase.sh
错误1&#xff1a;如报Host key verification failed 错误 解决Host key verification failed
错误2&#xff1a;未能在hdfs上创建/hbase目录
(base) [root&#64;node001 ~]# vim $HBASE_HOME/logs/hbase-root-master-node001.djin.com.logutil.FSUtils: Waiting for dfs to exit safe mode...
(base) [root&#64;node001 ~]# hdfs dfsadmin -safemode get
Safe mode is ON
(base) [root&#64;node001 ~]# hadoop dfsadmin -safemode leave
(base) [root&#64;node001 ~]# hdfs dfsadmin -safemode get
Safe mode is OFF
hbase shell启动失败解决
问题解决后启动测试
(base) [root&#64;node001 lib]# hbase shell
2022-05-23 22:34:43,074 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
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.4.12, r8382f55b15be6ae190f8d202a5e6a40af177ec76, Fri Apr 29 19:34:27 PDT 2022
Took 0.0010 seconds
hbase:001:0> exit
(base) [root&#64;node001 lib]# hbase shell
2022-05-23 22:49:45,386 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
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.4.12, r8382f55b15be6ae190f8d202a5e6a40af177ec76, Fri Apr 29 19:34:27 PDT 2022
Took 0.0011 seconds
hbase:001:0> create &#39;test&#39;, &#39;cf&#39;
Created table test
Took 0.9043 seconds
&#61;> Hbase::Table - test
hbase:002:0> list &#39;test&#39;
TABLE
test
1 row(s)
Took 0.0175 seconds
&#61;> ["test"]
hbase:003:0> describe &#39;test&#39;
Table test is ENABLED
test
COLUMN FAMILIES DESCRIPTION
{NAME &#61;> &#39;cf&#39;, BLOOMFILTER &#61;> &#39;ROW&#39;, IN_MEMORY &#61;> &#39;false&#39;, VERSIONS &#61;> &#39;1&#39;, KEEP_DELETED_CELLS &#61;> &#39;FALSE&#39;, DATA_BLOCK_ENCODING &#61;>
&#39;NONE&#39;, COMPRESSION &#61;> &#39;NONE&#39;, TTL &#61;> &#39;FOREVER&#39;, MIN_VERSIONS &#61;> &#39;0&#39;, BLOCKCACHE &#61;> &#39;true&#39;, BLOCKSIZE &#61;> &#39;65536&#39;, REPLICATION_SCOP
E &#61;> &#39;0&#39;}1 row(s)
Quota is disabled
Took 0.0877 seconds
hbase:004:0> put &#39;test&#39;, &#39;row1&#39;, &#39;cf:a&#39;, &#39;value1&#39;
Took 0.0573 seconds
hbase:005:0> put &#39;test&#39;, &#39;row2&#39;, &#39;cf:b&#39;, &#39;value2&#39;
Took 0.0056 seconds
hbase:006:0> put &#39;test&#39;, &#39;row3&#39;, &#39;cf:c&#39;, &#39;value3&#39;
Took 0.0091 seconds
hbase:007:0> scan &#39;test&#39;
ROW COLUMN&#43;CELLrow1 column&#61;cf:a, timestamp&#61;2022-05-23T22:52:42.123, value&#61;value1row2 column&#61;cf:b, timestamp&#61;2022-05-23T22:52:53.079, value&#61;value2row3 column&#61;cf:c, timestamp&#61;2022-05-23T22:53:04.220, value&#61;value3
3 row(s)
Took 0.0212 seconds
hbase:008:0> get &#39;test&#39;, &#39;row1&#39;
COLUMN CELLcf:a timestamp&#61;2022-05-23T22:52:42.123, value&#61;value1
1 row(s)
Took 0.5428 seconds
hbase:009:0> disable &#39;test&#39;
Took 0.3357 seconds
hbase:010:0> enable &#39;test&#39;
Took 0.6361 seconds
hbase:011:0> disable &#39;test&#39;
Took 0.3328 seconds
hbase:012:0> drop &#39;test&#39;
Took 0.1287 seconds