在一般情况下我们启动hbase要先启动hadoop和zookeeper。
虽然在实际开发环境中我们不会频繁的去启动和关闭hbase,但笔者在学习初期需要频繁启动和关闭hbase,因此编写shell脚本以便后续一键启动。
这是笔者的环境变量配置:
cat /etc/profile.d/my_env.sh
#HADOOP_HOME
export HADOOP_HOME=/opt/module/hadoop-3.1.3
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
#ZOOKEEPER_HOME
export ZOOKEEPER_HOME=/opt/module/zookeeper-3.5.7
export PATH=$PATH:$ZOOKEEPER_HOME/bin
#HBASE_HOME
export HBASE_HOME=/opt/module/hbase
export PATH=$PATH:$HBASE_HOME/bin
zookeeper启动、停止脚本
vim zk.sh
#!/bin/bash
case $1 in
"start"){
for i in hadoop-001 hadoop-002 hadoop-003
do
echo ---------- zookeeper $i 启动 ------------
ssh $i "zkServer.sh start"
done
echo ========================= zookeeper...start=========================
};;
"stop"){
for i in hadoop-001 hadoop-002 hadoop-003
do
echo ---------- zookeeper $i 停止 ------------
ssh $i "zkServer.sh stop"
done
echo ========================= zookeeper...stop=========================
};;
"status"){
for i in hadoop-001 hadoop-002 hadoop-003
do
echo ---------- zookeeper $i 状态 ------------
ssh $i "zkServer.sh status"
done
};;
esac
hadoop启动、停止脚本
vim hadoop.sh
#!/bin/bash
case $1 in
"start"){
ssh hadoop-001 "start-dfs.sh"
echo "=========================HDFS...start========================="
ssh hadoop-002 "start-yarn.sh"
echo "=========================YARN...start========================="
};;
"stop"){
ssh hadoop-001 "stop-dfs.sh"
echo "=========================HDFS...stop========================="
ssh hadoop-002 "stop-yarn.sh"
echo "=========================YARN...stop========================="
};;
esac
hbase启动、停止脚本
vim hbase.sh
#!/bin/bash
case $1 in
"start"){
sh zk.sh start
sh hadoop.sh start
start-hbase.sh
echo "=========================hbase...start========================="
};;
"stop"){
sh zk.sh stop
sh hadoop.sh stop
stop-hbase.sh
echo "=========================hbas...stop========================="
};;
esac
编写完成,让我们一键启动吧!
shell脚本启动:
[hadoop@hadoop-001 ~]$ sh hbase.sh start
[hadoop@hadoop-001 ~]$ jps
65921 NameNode
66049 DataNode
66376 NodeManager
66719 HMaster
66958 HRegionServer
67310 Jps
65710 QuorumPeerMain
版权归原作者 电光火石尔 所有, 如有侵权,请联系我们删除。