1.在node1的/root/bin目錄下編寫zk、hdfs啟動腳本
[root@node1 ~]# mkdir bin
[root@node1 ~]# ls
anaconda-ks.cfg bin hh.txt
[root@node1 ~]# cd bin/
[root@node1 bin]# vim starthdfs.sh
#!/bin/bash
#啟動zk叢集
for node in node2 node3 node4
do
ssh $node "source /etc/profile;zkServer.sh start"
done
#休眠1s
sleep 1
#啟動hdfs叢集
start-dfs.sh
#檢視目前節點node1中的角色程序
echo "-----------node1 jps--------------"
jps
#檢視其它三個節點中的角色程序
for nd in node2 node3 node4
do
echo "-----------$node jps--------------"
ssh $nd "source /etc/profile;jps"
done
# ESC->:wq
[root@node1 bin]# chmod +x starthdfs.sh
2.在node1的/root/bin目錄下編寫zk、hdfs關閉腳本
[root@node1 bin]# vim stophdfs.sh
[root@node1 bin]# cat stophdfs.sh
#!/bin/bash
#關閉hdfs叢集
stop-dfs.sh
#休眠1s
sleep 1
#關閉zk叢集
for node in node2 node3 node4
do
ssh $node "source /etc/profile;zkServer.sh stop"
done
#檢視四個節點中角色程序
allJps.sh
[root@node1 bin]# vim allJps.sh
[root@node1 bin]# cat allJps.sh
#!/bin/bash
#檢視目前節點的角色程序
echo "-----------node1 jps--------------"
jps
for node in node2 node3 node4
do
echo "-----------$node jps--------------"
ssh $node "source /etc/profile;jps"
done
[root@node1 bin]# chmod +x allJps.sh
[root@node1 bin]# chmod +x stophdfs.sh
[root@node1 bin]# vim starthdfs.sh
#!/bin/bash
#啟動zk叢集
for node in node2 node3 node4
do
ssh $node "source /etc/profile;zkServer.sh start"
done
#休眠1s
sleep 1
#啟動hdfs叢集
start-dfs.sh
#調用allJps.sh
allJps.sh