show all;
顯示rman的預設設定
列出資料庫還有那些資料檔案需要做備份:
report need backup;
1.已廢棄的備份和副本報表(也就是沒有用的備份組,是根據rman的冗餘來顯示的)
report obsolete;
2.顯示備份組列表
list backup;
刪除到期的備份組
delete backupset n;
如果作業系統中的檔案已經刪了,而備份資訊還在,那麼先做crosscheck,然後再delete expired 就可以清除這些不正確的備份資訊
crosscheck backuppiece 8;
然後delete backuppiece 8;
物理刪除了歸檔日誌,在使用rman 進行備份歸檔日誌的時候出現歸檔日誌不存在
change archivelog all crosscheck;
crosscheck archivelog all;
delete expired archivelog all;
3.恢複spfile
restore spfile to pfile 'e:\rmanbk\pfile.ora' from autobackup;
4.恢複控制檔案:
RMAN> restore controlfile from 'e:\rmanbk\CF_ORA9_20_1_573229179_20051101';
RMAN> run {
2> restore controlfile to 'e:\rmanbk\controlfilebak.ora' from autobackup;(因為是恢複的是控制檔案,所以必須要指定從備份的控制檔案中恢複)
3> replicate controlfile from 'e:\rmanbk\controlfilebak.ora';
4> }
5.rman備份的命令格式:
1).分配通道(allocate channel c1 type disk)
2).backup 備份和備份的類型(incremental level=0,1,2,3,4)
3).tag 可以增加個人化的標籤
4).format 備份組的路徑和命令格式
5).備份的內容(database...),(tablespace tools,system....),(archivelog all delete input)
6.對資料庫做一次全備份:
run {
allocate channel c1 type disk;
backup incremental level=0
format 'e:\rmanbk\%d_%p_%t'
(database);
}
run {
allocate channel c1 type disk;
backup full
format 'e:\rmanbk\%d_%p_%t'
(database);
}
7.備份歸檔日誌:
run {
allocate channel c1 type disk;
backup format 'e:\rmanbk\archlog_%d_%p_%t'
(archivelog all);
}
7.備份歸檔日誌(備份之後刪除歸檔日誌):
run {
allocate channel c1 type disk;
backup
tag 'ora9_archivelog_2004_11_16'
format 'e:\rmanbk\archlog_%d_%p_%t'
(archivelog all delete input);
}
查詢那些資料庫檔案需要進行恢複(在恢複資料檔案的時候需要)
select * from v$revocer_file;
select a.name,b.error from v$dbfile a,v$recover_file b where a.file#=b.file#;
恢複整個資料庫(也可以使用它恢複資料庫中需要恢複的檔案)
run {
allocate channel c1 type disk;
restore database;
recover database;
}
恢複某個丟失的資料檔案:
run {
allocate channel c1 type disk;
restore datafile 10;
recover datafile 10;
sql "alter database datafile 10 online";
}
恢複某個丟失的資料資料表空間:
run {
allocate channel c1 type disk;
restore tablespace test;
recover tablespace test;
sql "alter tablespace test online";
}
不完全恢複包括基於時間點、基於SCN、基於Log Sequence的恢複
基於系統變更號的不完全恢複
run {
allocate channel c1 type disk;
set until scn 123456;
restore database;
recover database;
sql "alter database open resetlogs";
}
基於時間不完全恢複
run {
allocate channel c1 type disk;
set until time "TO_DATE('2004-11-22 16:10:54','yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;
sql "alter database open resetlogs";
}
做基於時間點的恢複
RMAN> run
2> {allocate channel d1 type disk;
3> restore database until time '2005-03-30 16:13:54';
4> recover database;
5> release channel d1;
6> }