rman恢復資料庫--用備份的控制檔案
1、做全庫備份
RMAN> run{
allocate channel c1 type disk maxpiecesize=500m;
backup current controlfile format '+dgasm/backup/ctl_%d_%s';
backup full database format '+dgasm/backup/db_%d_%s_%p_%t';
sql 'alter system archive log current';
release channel c1;
}2> 3> 4> 5> 6> 7>
allocate channel c1 type disk maxpiecesize=500m;
backup current controlfile format '+dgasm/backup/ctl_%d_%s';
backup full database format '+dgasm/backup/db_%d_%s_%p_%t';
sql 'alter system archive log current';
release channel c1;
}2> 3> 4> 5> 6> 7>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=37 device type=DISK
allocated channel: c1
channel c1: SID=37 device type=DISK
Starting backup at 30-JUN-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 30-JUN-12
channel c1: finished piece 1 at 30-JUN-12
piece handle=+DGASM/backup/ctl_ora11_37 tag=TAG20120630T094535 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
Finished backup at 30-JUN-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 30-JUN-12
channel c1: finished piece 1 at 30-JUN-12
piece handle=+DGASM/backup/ctl_ora11_37 tag=TAG20120630T094535 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
Finished backup at 30-JUN-12
Starting backup at 30-JUN-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DGASM/ora11/datafile/system.257.785186755
input datafile file number=00002 name=+DGASM/ora11/datafile/sysaux.258.785186845
input datafile file number=00003 name=+DGASM/ora11/datafile/undotbs1.259.785186901
input datafile file number=00004 name=+DGASM/ora11/datafile/users.272.787009469
channel c1: starting piece 1 at 30-JUN-12
channel c1: finished piece 1 at 30-JUN-12
piece handle=+DGASM/backup/db_ora11_38_1_787311941 tag=TAG20120630T094541 comment=NONE
channel c1: starting piece 2 at 30-JUN-12
channel c1: finished piece 2 at 30-JUN-12
piece handle=+DGASM/backup/db_ora11_38_2_787311941 tag=TAG20120630T094541 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:00
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 30-JUN-12
channel c1: finished piece 1 at 30-JUN-12
piece handle=+DGASM/backup/db_ora11_39_1_787312002 tag=TAG20120630T094541 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 30-JUN-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DGASM/ora11/datafile/system.257.785186755
input datafile file number=00002 name=+DGASM/ora11/datafile/sysaux.258.785186845
input datafile file number=00003 name=+DGASM/ora11/datafile/undotbs1.259.785186901
input datafile file number=00004 name=+DGASM/ora11/datafile/users.272.787009469
channel c1: starting piece 1 at 30-JUN-12
channel c1: finished piece 1 at 30-JUN-12
piece handle=+DGASM/backup/db_ora11_38_1_787311941 tag=TAG20120630T094541 comment=NONE
channel c1: starting piece 2 at 30-JUN-12
channel c1: finished piece 2 at 30-JUN-12
piece handle=+DGASM/backup/db_ora11_38_2_787311941 tag=TAG20120630T094541 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:00
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 30-JUN-12
channel c1: finished piece 1 at 30-JUN-12
piece handle=+DGASM/backup/db_ora11_39_1_787312002 tag=TAG20120630T094541 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 30-JUN-12
sql statement: alter system archive log current
released channel: c1
RMAN>
2、做操做
建立haozg user 然後建表
SQL> create table haozg_hist as select * from v$loghist;
Table created.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL>
SQL> create table test(id number,name varchar2(13));
Table created.
SQL> insert into test select object_id,object_name from dba_objects where rownum=1;
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
3、關閉資料庫,刪除控制檔案,模擬控制檔案順壞
在grid 使用者下操作
ASMCMD> cd controlfile
ASMCMD> ls
current.260.787304065
ASMCMD> rm -f *
ASMCMD> ls
current.260.787304065
ASMCMD> rm -f *
4、啟動資料庫到nomount狀態
5、轉儲控制檔案從備份集中
RMAN> restore controlfile from '+dgasm/backup/ctl_ora11_37';
Starting restore at 30-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=+DGASM/controlfile/control01.ctl
Finished restore at 30-JUN-12
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=+DGASM/controlfile/control01.ctl
Finished restore at 30-JUN-12
RMAN>
6、啟動資料庫到mount狀態
7、恢復資料庫
RMAN> recover database;
Starting recover at 30-JUN-12
released channel: ORA_DISK_1
Starting implicit crosscheck backup at 30-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
Crosschecked 19 objects
Finished implicit crosscheck backup at 30-JUN-12
released channel: ORA_DISK_1
Starting implicit crosscheck backup at 30-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=26 device type=DISK
Crosschecked 19 objects
Finished implicit crosscheck backup at 30-JUN-12
Starting implicit crosscheck copy at 30-JUN-12
using channel ORA_DISK_1
Crosschecked 8 objects
Finished implicit crosscheck copy at 30-JUN-12
using channel ORA_DISK_1
Crosschecked 8 objects
Finished implicit crosscheck copy at 30-JUN-12
searching for all files in the recovery area
cataloging files...
no files cataloged
cataloging files...
no files cataloged
using channel ORA_DISK_1
RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rows
ORACLE error from target database:
ORA-19922: there is no parent row with id 0 and level 1
RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rows
ORACLE error from target database:
ORA-19922: there is no parent row with id 0 and level 1
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file +DGASM/ora11/onlinelog/group_2.264.785192615
archived log for thread 1 with sequence 9 is already on disk as file +DGASM/ora11/onlinelog/group_3.265.785192859
archived log for thread 1 with sequence 10 is already on disk as file +DGASM/ora11/onlinelog/group_1.263.785192081
archived log file name=/oracle/archivelog/1_1_787309225.dbf thread=1 sequence=1
archived log file name=/oracle/archivelog/1_2_787309225.dbf thread=1 sequence=2
archived log file name=/oracle/archivelog/1_3_787309225.dbf thread=1 sequence=3
archived log file name=/oracle/archivelog/1_4_787309225.dbf thread=1 sequence=4
archived log file name=/oracle/archivelog/1_5_787309225.dbf thread=1 sequence=5
archived log file name=/oracle/archivelog/1_6_787309225.dbf thread=1 sequence=6
archived log file name=/oracle/archivelog/1_7_787309225.dbf thread=1 sequence=7
archived log file name=+DGASM/ora11/onlinelog/group_2.264.785192615 thread=1 sequence=8
archived log file name=+DGASM/ora11/onlinelog/group_3.265.785192859 thread=1 sequence=9
archived log file name=+DGASM/ora11/onlinelog/group_1.263.785192081 thread=1 sequence=10
media recovery complete, elapsed time: 00:00:02
Finished recover at 30-JUN-12
archived log for thread 1 with sequence 9 is already on disk as file +DGASM/ora11/onlinelog/group_3.265.785192859
archived log for thread 1 with sequence 10 is already on disk as file +DGASM/ora11/onlinelog/group_1.263.785192081
archived log file name=/oracle/archivelog/1_1_787309225.dbf thread=1 sequence=1
archived log file name=/oracle/archivelog/1_2_787309225.dbf thread=1 sequence=2
archived log file name=/oracle/archivelog/1_3_787309225.dbf thread=1 sequence=3
archived log file name=/oracle/archivelog/1_4_787309225.dbf thread=1 sequence=4
archived log file name=/oracle/archivelog/1_5_787309225.dbf thread=1 sequence=5
archived log file name=/oracle/archivelog/1_6_787309225.dbf thread=1 sequence=6
archived log file name=/oracle/archivelog/1_7_787309225.dbf thread=1 sequence=7
archived log file name=+DGASM/ora11/onlinelog/group_2.264.785192615 thread=1 sequence=8
archived log file name=+DGASM/ora11/onlinelog/group_3.265.785192859 thread=1 sequence=9
archived log file name=+DGASM/ora11/onlinelog/group_1.263.785192081 thread=1 sequence=10
media recovery complete, elapsed time: 00:00:02
Finished recover at 30-JUN-12
RMAN>
從上面的恢復過程可以看到,應用了所有的日誌,包括線上日誌,歸檔日誌到sequence9,但是恢復sequence 到10。
10作為當前日誌。
10作為當前日誌。
8、以resetlogs 方式開啟資料庫
9、檢查使用者和表,資料都存在。
總結:rman 自動以datafile 為基準,應用所有歸檔日誌檔案,包括線上日誌檔案,完成不完全恢復。oracle 不知道恢復的終點,
有多少日誌,應用多少日誌,日誌都存在的情況下,資料沒有丟失。在這個過程中沒有讓dba參與。
v$log 中的內容來自控制檔案。
有多少日誌,應用多少日誌,日誌都存在的情況下,資料沒有丟失。在這個過程中沒有讓dba參與。
v$log 中的內容來自控制檔案。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7755871/viewspace-776377/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rman備份-(1) 利用備份級恢復資料檔案和控制檔案
- 使用備份的控制檔案恢復資料庫資料庫
- rman備份恢復-rman恢復資料檔案測試
- RMAN備份恢復之控制檔案的恢復(三)
- RMAN備份恢復之控制檔案的恢復(二)
- RMAN備份恢復之控制檔案的恢復(一)
- rman備份丟失控制檔案恢復
- RMAN資料庫恢復 之歸檔模式有(無)備份-丟失資料檔案的恢復資料庫模式
- 【rman 備份與恢復】恢復丟失所有的控制檔案
- Oracle資料庫控制檔案在備份恢復中的作用Oracle資料庫
- rman恢復--歸檔模式有備份,丟失資料檔案的恢復模式
- rman恢復--歸檔模式無備份,丟失資料檔案的恢復模式
- 備份與恢復--利用備份的控制檔案恢復
- 只有rman備份集,控制檔案丟失的恢復
- RMAN基於備份控制檔案恢復失敗
- 【備份恢復】利用 備份控制檔案到指定目錄下的控制檔案 恢復控制檔案
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(三)
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(二)
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(一)
- 備份與恢復--重建控制檔案後資料檔案損壞的恢復
- rman資料庫全庫備份與恢復資料庫
- 使用RMAN備份集和過時的控制檔案進行資料庫的恢復(2/2)資料庫
- 使用RMAN備份集和過時的控制檔案進行資料庫的恢復(1/2)資料庫
- 【備份與恢復】恢復受損的複用控制檔案
- 利用備份的控制檔案恢復
- 控制檔案的備份和恢復
- RMAN備份恢復——RAC環境資料庫的備份(zt)資料庫
- RMAN備份恢復--RAC環境資料庫的備份(十)資料庫
- RMAN備份恢復——RAC環境資料庫的備份(一)資料庫
- 備份與恢復系列 十一 控制檔案的備份與恢復
- 【備份恢復】丟失所有控制檔案,利用RMAN進行恢復操作
- 【備份恢復】RMAN catalog 恢復目錄資料庫資料庫
- RMAN說,我能備份(4)--RMAN備份資料檔案和控制檔案
- 【備份恢復】歸檔模式下丟失系統關鍵資料檔案 利用RMAN備份恢復模式
- RMAN備份恢復典型案例——資料檔案存在壞快
- 非系統資料檔案損壞,rman備份恢復
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- 非RMAN熱備份資料庫和恢復資料庫