第 5 章 制作 Elastic 和 Kibana 的统一启停脚本
为了方便启动 ElasticSearch 和 Kibana, 制作统一启动脚本
#!/bin/bash
es_home=/opt/module/elasticsearch-6.3.1
kibana_home=/opt/module/kibana-6.3.1
case $1 in
"start") {
for i in hadoop201 hadoop202 hadoop203
do
ssh $i "source /etc/profile;${es_home}/bin/elasticsearch >$es_home/logs/es.log 2>&1 &"
done
nohup ${kibana_home}/bin/kibana >$kibana_home/kibana.log 2>&1 &
};;
"stop") {
ps -ef|grep ${kibana_home} |grep -v grep|awk '{print $2}'|xargs kill
for i in hadoop201 hadoop202 hadoop203
do
ssh $i "ps -ef|grep $es_home |grep -v grep|awk '{print \$2}'|xargs kill" >/dev/null 2>&1
done
};;
*){
echo "你启动的姿势不正确, 请使用参数 start 来启动es集群, 使用参数 stop 来关闭es集群"
};;
esac