安装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 &'