Linux机器:
1 2 3 4 5 |
for ip in `cat ../ip.txt`;do salt $ip cp.get_file salt://filebeat_deploy/example-server.yml /data/filebeat/config/example-server.yml salt $ip cp.get_file salt://filebeat_deploy/restart.sh /data/filebeat/restart.sh salt "$ip" cmd.run "cd /data/filebeat/ && sh restart.sh" done |
这里有两个地方需要注意,否者会有严重问题:
1、要先到这里把第一种模式的restart脚本放到saltmaster上,然后在下发完filebeat配置之后把restart脚本也下发一下再执行重启filebeat命令,否者salt会卡住,
这种场景主要是因为某些情况下为了排障生产的filebeat启用了这里提到的中的第二种简单排错模式,这种模式会导致salt命令卡住
2. salt的重启filebeat命令一定要用"cd /data/filebeat/ && sh restart.sh",先cd后sh,如果直接用"sh /data/filebeat/restart.sh"虽然salt命令不会卡住,但会造成filebeat进程丢失。
Windows机器:
1 2 3 4 |
for ip in `cat ip.txt`;do salt "$ip" cp.get_file salt://filebeat/example-service.yml C:/filebeat/example-service.yml salt "$ip" cmd.run "net stop filebeat & net start filebeat" done |
Windows机器没什么需要注意的地方。