[root@room8pc205 elk]# vim es_manager.sh
#!/bin/bash
##BY:PlatoWG@163.com
##DATE:2018-12-19
##Start es cluster##
##es11-es15为es集群主机名,通过管理server需要无密码管理集群每个主机
start(){
for i in es11 es12 es13 es14 es15
do
ssh $i systemctl start elasticsearch.service
done
}
##Stop es cluster##
stop(){
for i in es11 es12 es13 es14 es15
do
ssh $i systemctl stop elasticsearch.service
done
}
##Status of es cluster##
status(){
for i in es11 es12 es13 es14 es15
do
ssh $i systemctl status elasticsearch.service
done
}
##Retart es cluster##
restart(){
for i in es11 es12 es13 es14 es15
do
ssh $i systemctl restart elasticsearch.service
done
}
##调用自定义函数管理es集群
case $1 in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo "USEAGE: $0 start|stop|status|restart"
esac