講到rman就要講到catalog,也就是恢複目錄,這個東東我覺得沒有太大的用,如果資料庫沒有打到open狀態,恢複目錄資料庫根本串連不上。我個人建議可以不使用catalog資料庫,當然為了全面的瞭解rman,還是要簡單瞭解下catalog資料庫是用來做什麼的,catalog資料庫是專門供rman使用,用來儲存備份資訊(不是儲存備份檔案)及備份指令碼的地方。
如果我們不用catalog的時候,備份資訊就存放在控制檔案當中,這些備份資訊是做恢複的時候需要用到的資訊。
情景一:使用catalog資料庫
1.建立catalog資料表空間
create tablespace rman_ts
datafile ‘xxxxxxxx/rman_ts01.dbf’
size 10m;
2.建立rman使用者
create user rman identified by rman
default tablespace rman_ts
temporary tablespace temp
quota unlimited on rman_ts
3.使用者授權
grant recovery_catalog_owner to rman
grant resource,connect to rman
4.在目錄資料庫中建立恢複目錄
rman catalog rman/rman
create catalog tablespace rman_ts
這個時候我們就可以正常使用catalog資料庫了,可以做下測試
[Oracle@ora10 ~]$ rman target / catalog rman/rman
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Mar 28 15:05:06 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: QDYX (DBID=3280546065)
connected to recovery catalog database
情景二:不使用恢複目錄
rman target /
做個全備份
run {
allocate channel n1 type disk;
allocate channel n2 type disk;
backup as compressed backupset database
format '/disk01/backup/ora10_%d_%s_%p';
release channel n1;
release channel n2;
}
做增量備份(差異增量)
run {
allocate channel c1 type disk;
backup incremental level 0
format '/disk01/backup/rmanbak/inc0_%u_%T'
database;
release channel c1;
}
備份資料檔案
backup datafile 8;
備份資料表空間
backup tablespace users;
備份歸檔日誌
backup archivelog all delete all input;
備份資料庫同時備份歸檔日誌,並刪除歸檔日誌
backup as compressed backupset database plus archivelog delete all input
format '/disk01/backup/ora10_%d_%s_%p';
注意:這裡可以使用run{}產生一段代碼,定製一些參數就行備份,也可以直接使用預設參數備份。在備份時如果不指定備份的路徑,則預設儲存在flash_recovery_area目錄下。