ES集群的自动启动脚本

1、先创建一个文件存储脚本:
mkdir elasticsearch
mv elasticsearch/ elastic
2、进入该文件夹:
cd elastic
3、创建脚本:
touch elastic-stop.sh
4、添加权限:
chmod u+x elastic-stop.sh
5、编写脚本:
vim elastic-stop.sh
6、脚本内容如下:
#!/bin/sh
#######################################
##一键启动或关闭es集群
##author:July
##date:2019-08-30
#######################################

#ps -aux | grep org.elasticsearch.bootstrap.Elasticsearch | awk -F " " ‘{print $2}’ | xargs kill -9

USER=hadoop01

cat elastic-host.txt(写绝对路径) | while read host
do
##完成远程节点进程的关闭
nohup ssh “ U S E R " @ " {USER}"@" USER"@"{host}” “ps -aux | grep org.elasticsearch.bootstrap.Elasticsearch | awk -F” " ‘{print $2}’ | xargs kill -9" >dev/null 2>&1 &

done

7、要杀死的进程列表,在同样文件下创建文件
vim elastic-host.txt
内容:
hadoop01
hadoop02
hadoop03

8、脚本调试查看命令:
bash -x elastic-stop.sh

9、执行脚本:直接执行就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值