TiDB 测试环境清理脚本
中控机上建立清理脚本
vi chean.sh
#!/bin/bash
for file in ` ls -al /etc/systemd/system | grep "^-" | awk '{print $9}' `
do
systemctl stop $file
systemctl disable $file
done
for file in ` ps -ef | grep supervise | grep -v auto | awk '{print $2}' `
do
kill -9 $file
done
for file in ` ps -ef | grep -E "mysql|haproxy|java|golang|sysbench|etcd|kube|tidb|pd|tikv|pump|prometheus|drainer|grafana" | grep -v 'grep' | awk '{print $2}' `
do
kill -9 $file
done
使用 ansible-adhoc 推送脚本
ansible -i inventory.ini monitored_servers -m copy -a "src=.../clean.sh dest=/tmp/clean.sh mode=0777"
执行脚本
ansible -i inventory.ini monitored_servers -m shell -a "bash /tmp/clean.sh"
或者去目标服务器上
./tmp/clean.sh