Elasticsearch集群启动脚本(start-es)

  1. cd /usr/local/bin
  2. sudo vi start-es

脚本内容如下:

  1. #!/bin/bash
  2. echo "start elasticsearch-------------------------------------------------"
  3. for i in bigdata-node1 bigdata-node2 bigdata-node3
  4. do
  5. ssh $i "source /etc/profile;service elasticsearch start"
  6. done
  7. sleep 3s
  8. jpsx
  9. exit 0

设置脚本执行权限:

  1. sudo chmod +x start-es
  2. sudo chown vagrant:vagrant start-es

Elasticsearch集群停止脚本(stop-es)

  1. cd /usr/local/bin
  2. sudo vi stop-es

脚本内容如下:

  1. #!/bin/bash
  2. echo "stop elasticsearch-------------------------------------------------"
  3. for i in bigdata-node1 bigdata-node2 bigdata-node3
  4. do
  5. ssh $i "source /etc/profile;service elasticsearch stop"
  6. done
  7. sleep 3s
  8. jpsx
  9. exit 0

设置脚本执行权限:

  1. sudo chmod +x stop-es
  2. sudo chown vagrant:vagrant stop-es

分发(选做):

  1. # 使用root账户分发至其他节点
  2. sudo scp -r /usr/local/bin/*-es root@bigdata-node2:/usr/local/bin/
  3. sudo scp -r /usr/local/bin/*-es root@bigdata-node3:/usr/local/bin/