#!/bin/bash echo "start-----------" hosts=("hadoop01" "hadoop02" "hadoop03") for host in ${hosts[@]} do ssh hadoop@$host << EOF cd ~/app/elasticsearch/bin ./elasticsearch -d -p ./pid exit EOF done for host in ${hosts[@]} do ssh hadoop@$host << EOF jps exit EOF done echo "end-----------------"
以下是关闭集群的脚本
#!/bin/bash echo "start-----------" hosts=("hadoop01" "hadoop02" "hadoop03") for host in ${hosts[@]} do ssh hadoop@$host << EOF jps exit EOF done for host in ${hosts[@]} do ssh hadoop@$host << "EOF" pid=`jps | grep "Elasticsearch" | gawk '{ print $1 }'` if [[ ${pid} && -n ${pid} ]]; then kill -9 ${pid}; fi exit EOF done for host in ${hosts[@]} do ssh hadoop@$host << EOF jps exit EOF done echo "end-----------------"