Elasticsearch集群启动脚本(start-es)
cd /usr/local/bin
sudo vi start-es
脚本内容如下:
#!/bin/bash
echo "start elasticsearch-------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;service elasticsearch start"
done
sleep 3s
jpsx
exit 0
设置脚本执行权限:
sudo chmod +x start-es
sudo chown vagrant:vagrant start-es
Elasticsearch集群停止脚本(stop-es)
cd /usr/local/bin
sudo vi stop-es
脚本内容如下:
#!/bin/bash
echo "stop elasticsearch-------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;service elasticsearch stop"
done
sleep 3s
jpsx
exit 0
设置脚本执行权限:
sudo chmod +x stop-es
sudo chown vagrant:vagrant stop-es
分发(选做):
# 使用root账户分发至其他节点
sudo scp -r /usr/local/bin/*-es root@bigdata-node2:/usr/local/bin/
sudo scp -r /usr/local/bin/*-es root@bigdata-node3:/usr/local/bin/