Recently, the hadoop cluster is frequently started and closed, and several machines have to be operated each time. It is too annoying, because I wrote a file to open and close the cluster with one click.
First, a demo.sh file is created, and the file permissions are modified so that the file can be executed.
The contents of the file are:
#!/bin/bash
for i in {
"vbserver","vbserver01","vbserver02","vbserver03"};
do
echo "-----$1 $i zookeeper-------"
ssh $i "source /etc/profile;/opt/bigdata/hadoop/zookeeper345/bin/zkServer.sh $1"
done
sleep 5
for j in {
"vbserver","vbserver01","vbserver02","vbserver03"};
do
echo "------$j status-------"
ssh $j "source /etc/profile;/opt/bigdata/hadoop/zookeeper345/bin/zkServer.sh status"
done
sleep 5
var='-all.sh'
var1=$1$var
sleep 3
echo "----- hadoop $1-----"
ssh vbserver "sh /opt/bigdata/hadoop/hadoop260/sbin/$var1"
echo "------yarn-daemon resourcemanager"
ssh vbserver01 "sh /opt/bigdata/hadoop/hadoop260/sbin/yarn-daemon.sh $1 resourcemanager"
When you want to turn on or off zookeeper and hadoop
./demo.sh start
或者
./demo.sh stop