1. 下载
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 |
2. 解压下载的文件,并切换到新创建的目录。
(base) [root@node001 bao]
(base) [root@node001 bao]
3. 配置hbase-env.sh
(base) [root@node001 conf]
-bash: /usr/local/java: 是一个目录
(base) [root@node001 conf]
export 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
4. 配置hbase-site.xml
<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>
5. 配置regionservers
(base) [root@node001 conf]
(base) [root@node001 conf]
node001.djin.com
node002.djin.com
node003.djin.com
6 配置备主节点
(base) [root@node001 conf]
/opt/src/hbase-2.4.12/conf
(base) [root@node001 conf]
(base) [root@node001 conf]
7. 配置环境变量
(base) [root@node001 hbase-2.4.12]
export HBASE_HOME=/opt/src/hbase-2.4.12
export PATH= $PATH:$HBASE_HOME/bin
8. 链接hadoop配置
(base) [root@node001 ~]
(base) [root@node001 ~]
9. 同步配置到其他节点
9.1 同步环境变量
(base) [root@node001 hbase-2.4.12]
到各节点激活配置
source ~/.bashrc
9.2 同步包及配置
(base) [root@node001 src]
10. 启动
10.1 启动 hadoop
(base) [root@node001 bin]
if [$# -lt 1]
then
echo "No Args Input..."
exit;
fi
case $1 in
"start")
echo "=================启动Hadoop集群==============="
echo "-----------------启动hdfs----------------"
ssh node001 "/opt/src/hadoop-3.3.1/sbin/start-dfs.sh"
sleep 5
echo "-----------------启动yarn----------------"
ssh node002 "/opt/src/hadoop-3.3.1/sbin/start-yarn.sh"
sleep 5
echo "-----------------启动historyserver----------------"
ssh node001 "/opt/src/hadoop-3.3.1/bin/mapred --daemon start historyserver"
sleep 5
;;
"stop")
echo "=================关闭Hadoop集群==============="
echo "-----------------关闭historyserver----------------"
ssh node001 "/opt/src/hadoop-3.3.1/bin/mapred --daemon stop historyserver"
sleep 5
echo "-----------------关闭yarn----------------"
ssh node002 "/opt/src/hadoop-3.3.1/sbin/stop-yarn.sh"
sleep 5
echo "-----------------关闭hdfs----------------"
ssh node001 "/opt/src/hadoop-3.3.1/sbin/stop-dfs.sh"
sleep 5
;;
*)
echo "Input Args Error.."
;;
esac
(base) [root@node001 bin]
10.2 启动zookeeper
(base) [root@node001 data]
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@node001 data]
(base) [root@node001 data]
8576 DataNode
9475 JobHistoryServer
8309 NameNode
9175 NodeManager
28008 QuorumPeerMain
28095 Jps
10.3 启动hbase
(base) [root@node001 ssh]
错误1:如报Host key verification failed 错误 解决Host key verification failed 错误2:未能在hdfs上创建/hbase目录
- 查看日志
(base) [root@node001 ~]
util.FSUtils: Waiting for dfs to exit safe mode...
- 百度一把发现时hadoop处于安全模式,创建不了目录
(base) [root@node001 ~]
Safe mode is ON
- 关闭安全模式,之后就可以成功创建hdfs目录/hbase
(base) [root@node001 ~]
(base) [root@node001 ~]
Safe mode is OFF
11.启动hbase shell测试
hbase shell启动失败解决 问题解决后启动测试
(base) [root@node001 lib]
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
Version 2.4.12, r8382f55b15be6ae190f8d202a5e6a40af177ec76, Fri Apr 29 19:34:27 PDT 2022
Took 0.0010 seconds
hbase:001:0> exit
(base) [root@node001 lib]
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
Version 2.4.12, r8382f55b15be6ae190f8d202a5e6a40af177ec76, Fri Apr 29 19:34:27 PDT 2022
Took 0.0011 seconds
hbase:001:0> create 'test', 'cf'
Created table test
Took 0.9043 seconds
=> Hbase::Table - test
hbase:002:0> list 'test'
TABLE
test
1 row(s)
Took 0.0175 seconds
=> ["test"]
hbase:003:0> describe 'test'
Table test is ENABLED
test
COLUMN FAMILIES DESCRIPTION
{NAME => 'cf', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING =>
'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOP
E => '0'}
1 row(s)
Quota is disabled
Took 0.0877 seconds
hbase:004:0> put 'test', 'row1', 'cf:a', 'value1'
Took 0.0573 seconds
hbase:005:0> put 'test', 'row2', 'cf:b', 'value2'
Took 0.0056 seconds
hbase:006:0> put 'test', 'row3', 'cf:c', 'value3'
Took 0.0091 seconds
hbase:007:0> scan 'test'
ROW COLUMN+CELL
row1 column=cf:a, timestamp=2022-05-23T22:52:42.123, value=value1
row2 column=cf:b, timestamp=2022-05-23T22:52:53.079, value=value2
row3 column=cf:c, timestamp=2022-05-23T22:53:04.220, value=value3
3 row(s)
Took 0.0212 seconds
hbase:008:0> get 'test', 'row1'
COLUMN CELL
cf:a timestamp=2022-05-23T22:52:42.123, value=value1
1 row(s)
Took 0.5428 seconds
hbase:009:0> disable 'test'
Took 0.3357 seconds
hbase:010:0> enable 'test'
Took 0.6361 seconds
hbase:011:0> disable 'test'
Took 0.3328 seconds
hbase:012:0> drop 'test'
Took 0.1287 seconds
|