How to understand ansible automatic operation and maintenance database
In this issue, the editor will bring you about how to understand the ansible automatic operation and maintenance database. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Check the database host and the database table space simply by ansible, on the premise that the database host has a unified user name and password.
Operation and maintenance environment: rhel 7.2, ansible 1.9
Database environment: Oracle 11.2.0.4, Suse 11sp4, unified users are Oracle and usercs
Ansible configuration file / etc/ansible/ansible.cfg, otherwise you need to define the host location when running ansible
-- configure host groups
[root@DBAMONITOR usercs] # more / ansible/hosts
[Suse]
192.168.15.21
192.168.15.22
192.168.15.46
192.168.15.47
-- simple testing
[root@DBAMONITOR .ssh] # ansible Suse-m ping-u usercs-k
SSH password:
192.168.15.22 | success > > {
"changed": false
"ping": "pong"
}
192.168.15.46 | success > > {
"changed": false
"ping": "pong"
}
192.168.15.47 | success > > {
"changed": false
"ping": "pong"
}
192.168.15.21 | success > > {
"changed": false
"ping": "pong"
}
-- View the space
[root@DBAMONITOR .ssh] # ansible Suse-m command-a "df-hT"-u usercs-k
Password:
[root@DBAMONITOR .ssh] # ansible Suse-m command-a "ls-l / tmp"-u usercs-k
Password:
-- copy the file:
[root@DBAMONITOR .ssh] # ansible Suse-m copy-a "src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg"-u usercs-k
Password:
{"src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg owner=usercs group=usercs mode=0644"}
-- execute scripts remotely
Ansible Suse-m shell-a "/ tmp/rocketzhang_test.sh"
Password:
-- create a directory remotely
Ansible Suse-m command-a "mkdir / home/oracle/scripts"-u oracle-k
Password:
-- configuration script
Source / .profile
Sqlplus-S "/ as sysdba"