catalog備份資料庫及RMAN儲存指令碼

張衝andy發表於2017-01-04
環境說明:


提前配置好兩個庫的監聽與tnsnames.ora
IP:10.100.25.13 為目標資料庫  
IP:10.100.25.14 為恢復目錄資料庫(catalog database)


以下操作全部都在恢復目錄資料庫下執行:


1.為恢復目錄建立一個表空間,表空間名稱是 catalogts。使用者名稱是catalogdemo 密碼是
oracle。給這個使用者賦予恢復目錄擁有者許可權。


SQL> create tablespace catalogts datafile'/home/oracle/app/oradata/catalog01.dbf' size 50m autoextend on;


Tablespace created.


SQL> create user catalogdemo identified by oracle default tablespace catalogts quota unlimited on catalogts;


User created.


SQL> grant recovery_catalog_owner to catalogdemo;


Grant succeeded.




2.使用RMAN用catalogdemo使用者連線到恢復目錄資料庫。在 catalogts 表空間中建立恢復目錄。


[oracle@11g ~]$ rman catalog catalogdemo/oracle@10.100.25.14:1521/orcl


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 4 14:54:43 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to recovery catalog database


RMAN> create catalog tablespace catalogts;


recovery catalog created


3.使用RMAN,連線到目標資料庫和恢復目錄資料庫。


[oracle@11g ~]$ rman target sys/oracle@10.100.25.13:1521/orcl catalog catalogdemo/oracle@10.100.25.14:1521/orcl


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 4 14:56:21 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: ORCL (DBID=1388303183)
connected to recovery catalog database


5.在恢復目錄中註冊目標資料庫,執行resync catalog 命令來同步控制檔案和恢復目錄。


RMAN> register database;


database registered in recovery catalog
starting full resync of recovery catalog
full resync complete


RMAN> resync catalog;


starting full resync of recovery catalog
full resync complete




RMAN> list incarnation;




List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
2       21      ORCL     1388303183       PARENT  1          15-AUG-09
2       4       ORCL     1388303183       CURRENT 945184     09-OCT-14




RMAN> backup database;


Starting backup at 04-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=52 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oradata/orcl/ogg01.dbf
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/home/oracle/app/oradata/orcl/tbtb01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/15ppb1kf_1_1 tag=TAG20141204T151527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:38
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/16ppb1pd_1_1 tag=TAG20141204T151527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-DEC-14


——————————————————————————————————————————————————
--  檢查備份是否存在於目標資料庫相應位置    (目標資料庫執行)


[oracle@11g dbs]$ pwd
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@11g dbs]$ ll
total 1200476
-rw-r-----. 1 oracle oinstall 1209679872 Dec  4 15:17 15ppb1kf_1_1
-rw-r-----. 1 oracle oinstall    9830400 Dec  4 15:18 16ppb1pd_1_1




——————————————————————————————————————————————————










catalog RMAN儲存指令碼


指令碼的分類
    local : 在rman連線的目標資料庫下建立的指令碼,此類指令碼僅僅適用於當前目標資料庫。即是針對特定的資料庫建立的rman指令碼
    global : 能夠在恢復目錄註冊的任意目標資料庫中執行
    如:create global script XXXX comment 'A script for full backup to be used with any database' {。。。。}


a:  建立rman本地儲存指令碼
RMAN> create script whole_backup { backup database; }


created script whole_backup


b:執行rman本地儲存指令碼
RMAN> run { execute  script whole_backup; }


executing script: whole_backup


Starting backup at 04-DEC-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oradata/orcl/ogg01.dbf
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/home/oracle/app/oradata/orcl/tbtb01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/17ppb2rh_1_1 tag=TAG20141204T153617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:56
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/18ppb34q_1_1 tag=TAG20141204T153617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 04-DEC-14


c:  檢視當前恢復目錄內的指令碼
list [global | all] script names
       
RMAN> list script names;


d:  更新指令碼
    replace [global] script scrip_name {....}
    replace [global] script script_name from file '<dir>'  --從檔案更新指令碼


RMAN> replace  script whole_backup { allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog  delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2; }2> 3> 4> 5> 6> 7> 


replaced script whole_backup


e:  檢視指令碼內容
RMAN> print script whole_backup;


printing stored script: whole_backup
{ allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog  delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2; }


f: 刪除指令碼
delete [global] script script_name


OK,轉載請標明出處。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2131919/,如需轉載,請註明出處,否則將追究法律責任。

相關文章