Hadoop+zookeeper+hbase boot self-startup
Hadoop2.7.3+zookeeper3.4.9+hbase1.2.6
I want them to be self-booting, which requires 2 scripts. H2.sh and h3.sh.
#! / bin/bash
# discribe: realize hadoop+zookeeper+hbase boot self-startup
# links that are very useful to me: ssh to other machines to enable zk startup. Https://zhidao.baidu.com/question/1447196109490350780.html
I can use # while true, but I'm not familiar with it.
# Don't be afraid if there are villains in the way. Don't overcome the villain with your own ability, because you can't overcome it. You can go around by yourself. Or find someone else to overcome the villain.
# realize automatic boot, thanks to the link below, after you have solved the problem of switching users, continue to execute the following command. Http://www.jb51.net/article/59255.htm
# therefore, this script also needs to cooperate with the directory h2.sh script to complete the overall boot self-startup. The function of h2.sh is to execute this script after switching users.
The contents are as follows:
H3.sh:
While true
Do
For ip in master11 slave22 slave23
Do
Ping-c 5$ ip & > / dev/null & # without the & symbol, will always prompt. I can't give any other orders. & > / dev/null is also important.
If [$?-ne 0]; then
Tag=1
Echo $ip+ "NO kai ji"
Break
Else
Tag=0
Fi
Done
If [$tag-eq 0]; then
Break
Fi
Break # this is a difficult point. Its function is to jump out of the while loop. Avoid the endless cycle.
Done
/ usr/local/hadoop273/sbin/start-all.sh
[$?-eq 0] & & sleep 5 | | exit 1
For i in master11 slave22 slave23
Do
Ssh $I "/ home/hadoop/hadoop/zookeeper-3.4.9/bin/zkServer.sh start"
Done
# [$?-eq 0] & & / usr/local/hbase-1.2.6/bin/start-hbase.sh | | exit 2
If [$?-eq 0]; then
/ usr/local/hbase-1.2.6/bin/start-hbase.sh
Else
Echo "zk no ok"
Fi
H2.sh:
Su-hadoop-s / bin/bash / root/h3.sh.
Just put h2.sh under / etc/init.d/, and that's fine.
The script must have execute permission.