批量启动zookeeper
#!/bin/bash
iparray = ( ha001 ha002 ha003)
case $@ in
start)
for ip in ${iparray[ *] }
do
ssh $ip "source /etc/profile;zkServer.sh start"
sleep 2s
done
exit
; ;
stop)
for ip in ${iparray[ *] }
do
ssh $ip "source /etc/profile;zkServer.sh stop"
sleep 2s
done
exit
; ;
status)
for ip in ${iparray[ *] }
do
ssh $ip "source /etc/profile;zkServer.sh status"
sleep 2s
done
exit
; ;
*)
echo "nothing to do!"
esac
jps查看所有节点服务启动情况
iparray = ( ha001 ha002 ha003)
for ip in ${iparray[ *] }
do
echo "-------------$ip -jps-------------"
ssh $ip "source /etc/profile;jps"
sleep 2s
done
exit
防火墙端口管理
iparray = ( ha001 ha002 ha003)
case $1 in
add )
for ip in ${iparray[ *] }
do
echo "###############open ports on $ip ###############"
for port in $*
do
if [ "$port " = "add" ]
then
continue
else
echo "########opening $port ########"
ssh $ip "firewall-cmd --add-port=$port /tcp --permanent"
sleep 2s
ssh $ip "firewall-cmd --reload"
fi
done
ssh $ip "firewall-cmd --zone=public --list-port"
done
exit
; ;
list)
for ip in ${iparray[ *] }
do
echo "###############list ports on $ip ###############"
ssh $ip "firewall-cmd --zone=public --list-port"
done
exit
; ;
state)
for ip in ${iparray[ *] }
do
echo "###############firewalld state on $ip ###############"
ssh $ip "firewall-cmd --state"
done
exit
; ;
start)
for ip in ${iparray[ *] }
do
echo "###############start firewalld on $ip ###############"
ssh $ip "systemctl start firewalld"
done
exit
; ;
stop)
for ip in ${iparray[ *] }
do
echo "###############stop firewalld on $ip ###############"
ssh $ip "systemctl stop firewalld"
done
exit
; ;
remove)
for ip in ${iparray[ *] }
do
port = $2
echo "###############remove $port on $ip ###############"
ssh $ip "firewall-cmd --zone=public --remove-port=$port /tcp --permanent"
ssh $ip "firewall-cmd --reload"
done
exit
; ;
*)
echo "###############parameter error###############"
esac