安裝ansible工具: 1)直接yum install -y ansible; 2)而後更改配置,/etc/ansible/ansible.cfg,將裏面的host_key_checking = False前的#去掉,去掉ssh在首次鏈接出現檢查keys的提示 3)去設置hosts文件,在最後加入如下配置,10.139.11.118是要遠程的服務器IP,ansible_ssh_user登陸服務器的用戶,ansible_ssh_pass登陸服務器的密碼 [test] 10.139.11.118 ansible_ssh_user=root ansible_ssh_pass='1qaz!QAZ' 10.139.11.119 ansible_ssh_user=root ansible_ssh_pass='1qaz!QAZ' 4)測試ansible是否可用 # ansible test -m command -a 'uptime' 10.139.11.118 | SUCCESS | rc=0 >> 14:23:41 up 4 days, 21:01, 2 users, load average: 0.00, 0.01, 0.05 10.139.11.119 | SUCCESS | rc=0 >> 14:23:39 up 4 days, 21:00, 2 users, load average: 0.00, 0.01, 0.05 批量安裝tmux工具: # ansible test -m shell -a 'yum install tmux' 遠程複製的命令,將vdbench安裝包全複製到各個虛機中 # ansible test -m copy -a "src=/root/lrr/fio dest=/root" 遠程批量執行fio腳本的命令: # ansible test -m shell -a 'tmux;cd /root/fio;nohup sh fio.sh &'