uat(installed on 214, performed on 214):
Cat/etc/ansible/hosts
Added group:
[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
Test:
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"
}
Common file operation commands:
Copy file (performed on 214):
Ansible hdp-m copy-a "Src=/etc/ansible/test.txt dest=/tmp/"
Copy the test directory under/TMP to the TMP directory for all nodes in the HDP group:
Ansible hdp-m copy-a "Src=/tmp/test dest=/tmp/"
You can also specify the owning user group as a copy:
Ansible hdp-m copy-a "src=/tmp/test dest=/tmp owner=hdfs Group=hadoop"
To delete a file:
Ansible hdp-m file-a "Dest=/tmp/test.txt state=absent"
To change file permissions:
Ansible hdp-m file-a "Dest=/tmp/test.txt mode=777"
To change the users and groups to which a file belongs:
Ansible hdp-m file-a "Dest=/tmp/test.txt owner=hdfs group=hadoop"
To create a directory:
Ansible hdp-m file-a "dest=/tmp/test owner=hdfs group=hadoop state=directory"
To create a file:
Ansible hdp-m file-a "dest=/tmp/test/1.txt owner=hdfs group=hadoop State=touch"
Pat(mounted on 36 nodes):
Several groups have been configured in the Hosts file, where 25-34 is a node in the SOLR group
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
Common commands related to Ansible tools