#!/bin/bash
#菜单打印
conf=/root/shell/deploy.conf
tag=hadoop
cat <<-EOF
s 启动集群
t 关闭集群
q 退出程序
EOF
#用户选择需要维护的内容
while true
do
read -p "请选择需要操作的内容(helo h):" action
clear
cat <<-EOF
s 启动集群
t 关闭集群
j 发送jps命令
q 退出程序
EOF
case $action in
h|help)
clear;cat <<-EOF
s 启动集群
t 关闭集群
q 退出程序
EOF
;;
s)
if [ -f $conf ]
then
for server in `cat ${conf} | grep -v "#" | grep ${tag} | awk -F "," '{print $1}'`
do
echo "*******************$server***************************"
ssh $server "source ~/.bash_profile; zkServer.sh start"
done
start-dfs.sh
else
echo "Erro:conf does not exist"
fi
;;
t)
stop-dfs.sh
if [ $? -eq 0 ]
then
if [ -f $conf ]
then
for server in `cat ${conf} | grep -v "#" | grep ${tag} | awk -F "," '{print $1}'`
do
echo "*******************$server***************************"
ssh $server "source ~/.bash_profile; zkServer.sh stop"
done
else
echo "Erro:conf does not exist"
fi
else
echo "关闭失败需要手动关闭集群"
fi
;;
j)
if [ -f $conf ]
then
for server in `cat ${conf} | grep -v "#" | grep ${tag} | awk -F "," '{print $1}'`
do
echo "*******************$server***************************"
ssh $server "source ~/.bash_profile; jps"
done
start-dfs.sh
else
echo "Erro:conf does not exist"
fi
;;
q)
exit
;;
esac
done
#!/bin/bash#菜单打印conf=/root/shell/deploy.conftag=hadoopcat <<-EOF s 启动集群 t 关闭集群 q 退出程序 EOF#用户选择需要维护的内容 while truedoread -p "请选择需要操作的内容(helo h):" actionclearcat <<-EOF s 启动