标签:
uat(装在214上,在214上执行):
cat /etc/ansible/hosts
已添加组:
[hdp]
172.30.64.214 ansible_ssh_user=root
172.30.64.213 ansible_ssh_user=root
172.30.64.216 ansible_ssh_user=root
172.30.64.220 ansible_ssh_user=root
测试:
ansible hdp -m ping
172.30.64.220 | success >> {
"changed": false,
"ping": "pong"
}
172.30.64.213 | success >> {
"changed": false,
"ping": "pong"
}
172.30.64.216 | success >> {
"changed": false,
"ping": "pong"
}
172.30.64.214 | success >> {
"changed": false,
"ping": "pong"
}
常用文件操作命令:
拷贝文件(214上执行):
ansible hdp -m copy -a "src=/etc/ansible/test.txt dest=/tmp/"
拷贝/tmp下面的test目录到hdp组所有节点的tmp目录下:
ansible hdp -m copy -a "src=/tmp/test dest=/tmp/"
拷贝的同时也可以指定所属用户组:
ansible hdp -m copy -a "src=/tmp/test dest=/tmp owner=hdfs group=hadoop"
删除文件:
ansible hdp -m file -a "dest=/tmp/test.txt state=absent"
更改文件权限:
ansible hdp -m file -a "dest=/tmp/test.txt mode=777"
更改文件所属的用户和组:
ansible hdp -m file -a "dest=/tmp/test.txt owner=hdfs group=hadoop"
创建目录:
ansible hdp -m file -a "dest=/tmp/test owner=hdfs group=hadoop state=directory"
创建文件:
ansible hdp -m file -a "dest=/tmp/test/1.txt owner=hdfs group=hadoop state=touch"
pat(装在36节点上):
hosts文件里已配置几个组,其中25-34是个节点为在solr组里
ansible storm -m shell -a ‘grep 6226930000997489 /var/log/storm/notify-20151231-135801-12-1451541482*log‘
ansible datanode -m shell -a "netstat -tunlp |grep 8986" -u root
ansible hdp -m shell -a " chmod 777 /root/tcp_monitor.sh " -u root
ansible hdp -m shell -a " sh /root/tcp_monitor.sh " -u root
ansible storm -m shell -a ‘grep 3015 /var/log/storm/notify-20160331-235433*‘
ansible datanode -m shell -a "netstat -n|awk ‘/^tcp/{++S[$NF]} END {for (a in S) print a,S[a]}‘" -u root
ansible hdp -m copy -a "src=/root/tcp_monitor.sh dest=/root/tcp_monitor.sh owner=root group=root"
ansible hdp -m shell -a " chmod 777 /root/tcp_monitor.sh " -u root
标签:
原文地址:http://www.cnblogs.com/riyueyuzhuzhu/p/5584783.html