溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何理解ansible自動(dòng)化運(yùn)維數(shù)據(jù)庫(kù)

發(fā)布時(shí)間:2021-11-12 16:29:41 來(lái)源:億速云 閱讀:217 作者:柒染 欄目:關(guān)系型數(shù)據(jù)庫(kù)

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)如何理解ansible自動(dòng)化運(yùn)維數(shù)據(jù)庫(kù),文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

   通過(guò)ansible簡(jiǎn)單對(duì)數(shù)據(jù)庫(kù)主機(jī)檢查和數(shù)據(jù)庫(kù)表空間的檢查,前提數(shù)據(jù)庫(kù)主機(jī)有統(tǒng)一的用戶名和密碼.

 運(yùn)維環(huán)境: rhel 7.2, ansible 1.9
 數(shù)據(jù)庫(kù)環(huán)境:Oracle 11.2.0.4, Suse 11sp4,統(tǒng)一用戶是Oracle和usercs
ansible配置文件/etc/ansible/ansible.cfg,否則在運(yùn)行ansible時(shí)需要制定host位置
--配置host組
[root@DBAMONITOR usercs]# more /ansible/hosts 
[Suse]
192.168.15.21
192.168.15.22
192.168.15.46
192.168.15.47


--簡(jiǎn)單測(cè)試
[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"
}


--查看空間
[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:
--復(fù)制文件:
[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" }


--遠(yuǎn)程執(zhí)行腳本
ansible Suse -m shell -a "/tmp/rocketzhang_test.sh"
password:
--遠(yuǎn)程創(chuàng)建目錄
ansible Suse -m command -a "mkdir /home/oracle/scripts" -u oracle -k
password:
--配置腳本
source ~/.profile
sqlplus -S "/as sysdba"<<EOF


set lin 200 pages 100
 select current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv\$database;


set pagesize 9999 
set linesize 132 
select
a.tablespace_name,
a.Total_mb,
f.Free_mb,
round(a.total_MB-f.free_mb,2) Used_mb,
round((f.free_MB/a.total_MB)*100) "%_Free"
from
(select tablespace_name, sum(bytes/(1024*1024)) total_MB from dba_data_files group by tablespace_name) a,
(select tablespace_name, round(sum(bytes/(1024*1024))) free_MB from dba_free_space group by tablespace_name) f
WHERE a.tablespace_name = f.tablespace_name(+)
order by "%_Free"
/
exit
EOF


--拷貝文件
ansible Suse -m copy -a "src=/ansible/check_db.sh  dest=/home/oracle/scripts" -u oracle -k
password:
--執(zhí)行腳本
ansible Suse -m command -a "chmod +x /home/oracle/scripts/check_db.sh" -u oracle -k 
password:
ansible Suse -m shell -a "/home/oracle/scripts/check_db.sh" -u oracle -k
password:

上述就是小編為大家分享的如何理解ansible自動(dòng)化運(yùn)維數(shù)據(jù)庫(kù)了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI