一、Hadoop群起脚本
#!/bin/bash
#提供对hadoop集群的一键启动和停止,只接受start或stop参数中的一个
#判断参数的个数
if(($#!=1))
then
echo 请输入start或stop参数中的任意一个
exit;
fi
#校验参数内容
if [ $1 = start ] || [ $1 = stop ]
then
$1-dfs.sh
$1-yarn.sh
ssh hadoop102 mr-jobhistory-daemon.sh $1 historyserver
xcall jps
else
echo 请输入start或stop参数中的任意一个
fi
二、zk群起脚本
#! /bin/bash
case $1 in
"start"){
for i in hadoop102 hadoop103 hadoop104
do
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop102 hadoop103 hadoop104
do
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop102 hadoop103 hadoop104
do
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh status"
done
};;
esac
三、xcall命令脚本
#! /bin/bash
for i in hadoop102 hadoop103 hadoop104
do
echo --------- $i ----------
ssh $i "$*"
done
四、集群时间同步脚本
#!/bin/bash
#dt.sh 日期,可以让集群中所有机器的时间同步到此日期
#如果用户没有传入要同步的日期,同步日期到当前的最新时间
if(($#==0))
then
xcall sudo ntpdate -u ntp1.aliyun.com
exit;
fi
#dt.sh 日期,可以让集群中所有机器的时间同步到此日期
for((i=102;i<=104;i++))
do
echo "--------------同步hadoop$i--------------"
ssh hadoop$i "sudo date -s '$@'"
done