共计 760 个字符,预计需要花费 2 分钟才能阅读完成。
Linux 机器:
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 机器:
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 机器没什么需要注意的地方。
正文完