備份相關的動態效能檢視及監控

智慧先行者發表於2015-01-11

 

    1.相關檢視

        v$backup_files

        v$backup_set

        v$backup_piece

        v$backup_redolog

        v$backup_spfile

        v$backup_device

        v$rman_configuration

        v$archived_log

        v$backup_corruption

        v$copy_corruption

        v$database_block_corruption

        v$backup_datafile

       

    2.檢視channel對應的server sessions

            使用set command id命令

        查詢v$process和v$session判斷哪一個會話與之對應的RMAN通道

        SQL> select sid,username,client_info from v$session

          2  where client_info is not null;

 

               SID USERNAME                       CLIENT_INFO

        ---------- ------------------------------ ------------------------------

               146 SYS                            rman channel=ORA_DISK_1

               148 SYS                            rman channel=ORA_DISK_2

               150 SYS                            rman channel=ORA_DISK_3

           

        --下面使用了set command id命令

        RMAN> run{

        2> allocate channel ch1 type disk;

        3> set command id to 'rman';

        4> backup as copy datafile 4

        5> format '/u01/app/oracle/rmanbak/dd_%U';

        6> }

           

        SQL> select sid,username,client_info from v$session

          2   where client_info is not null;

 

               SID USERNAME                       CLIENT_INFO

        ---------- ------------------------------ ------------------------------

               140 SYS                            id=rman

          

        SQL> select sid,spid,client_info

          2  from v$process p ,v$session s

          3  where p.addr = s.paddr

          4  and client_info like '%id=%';

 

               SID SPID         CLIENT_INFO

        ---------- ------------ ------------------------------

               140 5002         id=rman 

          

        --檢視rman完整的進度      

        SQL> select sid,serial#,context,sofar,totalwork,

          2  round(sofar/totalwork*100,2) "% Complete"

          3  from v$session_longops

          4   where opname like 'RMAN:%'

          5  and opname not like 'RMAN:aggregate%'

          6  and totalwork!=0;    

 

        --通過如下SQL獲得rman用來完成備份操作的服務程式的SID與SPID資訊:

        select sid, spid, client_info

          from v$process p, v$session s

         where p.addr = s.paddr

           and client_info like '%id=rman%'

     

    3.Linux下的rman自動備份

        備份指令碼+crontab

        bak_inc0 :0級增量備份,每週日使用級增量進行備份

        bak_inc1 :1級增量備份,每週三使用級增量備份,備份從週日以來到週三所發生的資料變化

        bak_inc2 :2級增量備份,備份每天發生的差異增量。如從週日到週一的差異,從週一到週二的差異

       

        --下面是級增量的指令碼,其餘級與級依法炮製,所不同的是備份級別以及tag標記

        [oracle@oradb scripts]$ cat bak_inc0

        run {

        allocate channel ch1 type disk;

        backup as compressed backupset  incremental level 0

        format '/u01/oracle/bk/rmbk/incr0_%d_%U'

        tag 'day_incr0'

        database plus archivelog delete input;

        release channel ch1;

        }

               

        逐個測試指令碼

        [oracle@oradb bk]$ rman target / log=/u01/oracle/bk/log/bak_inc0.log /

        > cmdfile=/u01/oracle/bk/scripts/bak_inc0.rcv

        RMAN> 2> 3> 4> 5> 6> 7> 8> 9>

        [oracle@oradb bk]$

 

        編輯crontab

        [root@oradb ~]# whoami

        root

        [root@oradb ~]# crontab -e -u oracle

 

        45 23 * * 0 rman target / log=/u01/oracle/bk/log/bak_inc0.log append cmdfile = /u01/oracle/bk/scripts/bak_inc0.rcv

        45 23 * * 1 rman target / log=/u01/oracle/bk/log/bak_inc2.log append cmdfile = /u01/oracle/bk/scripts/bak_inc2.rcv

        45 23 * * 2 rman target / log=/u01/oracle/bk/log/bak_inc2.log append cmdfile = /u01/oracle/bk/scripts/bak_inc2.rcv

        45 23 * * 3 rman target / log=/u01/oracle/bk/log/bak_inc1.log append cmdfile = /u01/oracle/bk/scripts/bak_inc1.rcv

        45 23 * * 4 rman target / log=/u01/oracle/bk/log/bak_inc2.log append cmdfile = /u01/oracle/bk/scripts/bak_inc2.rcv

        45 23 * * 5 rman target / log=/u01/oracle/bk/log/bak_inc2.log append cmdfile = /u01/oracle/bk/scripts/bak_inc2.rcv

        45 23 * * 6 rman target / log=/u01/oracle/bk/log/bak_inc2.log append cmdfile = /u01/oracle/bk/scripts/bak_inc2.rcv

        "/tmp/crontab.XXXXInBzgR" 7L, 791C written

        crontab: installing new crontab

        儲存之後重啟crontab

        [root@oradb ~]# service crond restart

        Stopping crond: [  OK  ]

        Starting crond: [  OK  ]

       

        檢查自動備份是否成功執行

 

相關文章