1. xcall.sh 查看状态 的命令: xcall.sh jps
1 #! /bin/bash
2
3 for i in hadoop102 hadoop103 hadoop104
4 do
5 echo --------- $i ----------
6 ssh $i "$*"
7 done
#!/bin/bash
params=$@
for i in hadoop102 hadoop103 hadoop101
do
echo ==========s$i $params==========
ssh $i "source /etc/profile;$params"
done
2.复制某个目录到其他节点 xsync
1 #!/bin/bash
2 #1 获取输入参数个数,如果没有参数,直接退出
3 pcount=$#
4 if((pcount==0)); then
5 echo no args;
6 exit;
7 fi
8
9 #2 获取文件名称
10 p1=$1
11 fname=`basename $p1`
12 echo fname=$fname
13
14 #3 获取上级目录到绝对路径
15 pdir=`cd -P $(dirname $p1); pwd`
16 echo pdir=$pdir
17
18 #4 获取当前用户名称
19 user=`whoami`
20
21 #5 循环
22 for((host=103; host<105; host++)); do
23 echo ------------------- hadoop$host --------------
24 rsync -av $pdir/$fname $user@hadoop$host:$pdir
25 done
3. 启动kafka kafka.sh start
1 #! /bin/bash
2
3 case $1 in
4 "start"){
5 for i in hadoop102 hadoop103 hadoop104
6 do
7 ssh $i "/opt/module/kafka_2.11-1.0.0/bin/kafka-server-start.sh -daemon /opt/module/kafka_2.11-1.0.0/config/server.properties"
8 done
9 };;
10 esac
#! /bin/bash
case $1 in
"start"){
for i in hadoop102 hadoop103 hadoop101
do
ssh $i "/opt/module/kafka_2.11-1.0.1/bin/kafka-server-start.sh -daemon /opt/module/kafka_2.11-1.0.1/config/server.properties"
done
};;
esac
View Code
4. zk.sh start
1 #! /bin/bash
2
3 case $1 in
4 "start"){
5 for i in hadoop102 hadoop103 hadoop104
6 do
7 ssh $i "/opt/module/zookeeper-3.4.12/bin/zkServer.sh start"
8 done
9 };;
10 "stop"){
11 for i in hadoop102 hadoop103 hadoop104
12 do
13 ssh $i "/opt/module/zookeeper-3.4.12/bin/zkServer.sh stop"
14 done
15 };;
16 "status"){
17 for i in hadoop102 hadoop103 hadoop104
18 do
19 ssh $i "/opt/module/zookeeper-3.4.12/bin/zkServer.sh status"
20 done
21 };;
22 esac
#! /bin/bash
case $1 in
"start"){
for i in hadoop102 hadoop103 hadoop104
do
ssh $i "/opt/module/zookeeper-3.4.12/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop102 hadoop103 hadoop104
do
ssh $i "/opt/module/zookeeper-3.4.12/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop102 hadoop103 hadoop104
do
ssh $i "/opt/module/zookeeper-3.4.12/bin/zkServer.sh status"
done
};;
esac
View Code
5. 启动hadoop hadoop.sh start
1 #! /bin/bash
2
3 case $1 in
4 "start"){
5 for i in hadoop102
6 do
7 ssh $i "/opt/module/hadoop-2.7.3/sbin/start-all.sh"
8 done
9
10 for i in hadoop103
11 do
12 ssh $i "/opt/module/hadoop-2.7.3/sbin/start-yarn.sh"
13 done
14 };;
15 esac
16
#! /bin/bash
case $1 in
"start"){
for i in hadoop102
do
ssh $i "/opt/module/hadoop-2.7.3/sbin/start-all.sh"
done
for i in hadoop103
do
ssh $i "/opt/module/hadoop-2.7.3/sbin/start-yarn.sh"
done
};;
esac
View Code