首页 > Linux操作系统 > Linux操作系统 > 有整库备份的情况rman恢复全库
在利用RMAN备份了整个数据库后,我们恢复数据库到备份的状态,利用之前的全备恢复,需要以下一系列操作。
|
RMAN> list backup;
using target database control file instead of recovery catalog
RMAN> list backup;
RMAN> backup database;
Starting backup at 04-MAR-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=529 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oracle/u01/app/oracle/oradata/orcl/system01.dbf input datafile fno=00003 name=/oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf input datafile fno=00005 name=/oracle/u01/app/oracle/oradata/orcl/admin01.dbf input datafile fno=00002 name=/oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf input datafile fno=00004 name=/oracle/u01/app/oracle/oradata/orcl/users01.dbf input datafile fno=00006 name=/oracle/u01/app/oracle/oradata/orcl/users02.dbf channel ORA_DISK_1: starting piece 1 at 04-MAR-13 channel ORA_DISK_1: finished piece 1 at 04-MAR-13 piece handle=/oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp tag=TAG20130304T165311 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 Finished backup at 04-MAR-13
Starting Control File and SPFILE Autobackup at 04-MAR-13 piece handle=/oracle/u01/app/oracle/backup/c-1324770912-20130304-0d comment=NONE Finished Control File and SPFILE Autobackup at 04-MAR-13 |
备份过程如果没有设置备份路径会自动备份到rman默认路径,通过show all,也可以检查参数更改备份路径
|
RMAN> list backup;
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 140 Full 963.54M DISK 00:00:42 04-MAR-13 BP Key: 144 Status: AVAILABLE Compressed: NO Tag: TAG20130304T165311 Piece Name: /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp List of Datafiles in backup set 140 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/system01.dbf 2 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf 3 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf 4 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/users01.dbf 5 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/admin01.dbf 6 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/users02.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 141 Full 7.52M DISK 00:00:00 04-MAR-13 BP Key: 145 Status: AVAILABLE Compressed: NO Tag: TAG20130304T165357 Piece Name: /oracle/u01/app/oracle/backup/c-1324770912-20130304-0d Control File Included: Ckp SCN: 5925970 Ckp time: 04-MAR-13 SPFILE Included: Modification time: 04-MAR-13 |
通过检查,已经备份成功,备份集号为141
|
SQL> shutdown abort; ORACLE instance shut down. |
此时不用一致性停库也行,因为模拟实验,将要删除整个数据库文件。
|
[oracle@dev206 oracle]$ rm -rf /oracle/u01/app/oracle/oradata/orcl/* |
|
SQL> startup ORA-32004: obsolete and/or deprecated parameter(s) specified ORACLE instance started.
Total System Global Area 1224736768 bytes Fixed Size 2020384 bytes Variable Size 352324576 bytes Database Buffers 855638016 bytes Redo Buffers 14753792 bytes ORA-00205: error in identifying control file, check alert log for more info |
此时数据库已经不能启动,在启动到nomount过程中报205错误,找不到控制文件。
|
[oracle@dev206 ~]$ rman target / RMAN> restore controlfile from '/oracle/u01/app/oracle/backup/c-1324770912-20130304-0d';
Starting restore at 04-MAR-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=540 devtype=DISK
channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output filename=/oracle/u01/app/oracle/oradata/orcl/control01.ctl output filename=/oracle/u01/app/oracle/oradata/orcl/control02.ctl output filename=/oracle/u01/app/oracle/oradata/orcl/control03.ctl Finished restore at 04-MAR-13 |
检验/oracle/u01/app/oracle/oradata/orcl路径下已经恢复控制文件。
|
RMAN> alter database mount;
database mounted released channel: ORA_DISK_1 |
|
RMAN> restore database;
Starting restore at 04-MAR-13 Starting implicit crosscheck backup at 04-MAR-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=540 devtype=DISK Crosschecked 1 objects Finished implicit crosscheck backup at 04-MAR-13
Starting implicit crosscheck copy at 04-MAR-13 using channel ORA_DISK_1 Crosschecked 4 objects Finished implicit crosscheck copy at 04-MAR-13
searching for all files in the recovery area cataloging files... cataloging done
List of Cataloged Files ======================= File Name: /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_ncnnf_TAG20130304T143106_8m8hxc3s_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /oracle/u01/app/oracle/oradata/orcl/system01.dbf restoring datafile 00002 to /oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf restoring datafile 00003 to /oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf restoring datafile 00004 to /oracle/u01/app/oracle/oradata/orcl/users01.dbf restoring datafile 00005 to /oracle/u01/app/oracle/oradata/orcl/admin01.dbf restoring datafile 00006 to /oracle/u01/app/oracle/oradata/orcl/users02.dbf channel ORA_DISK_1: reading from backup piece /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp tag=TAG20130304T165311 channel ORA_DISK_1: restore complete, elapsed time: 00:00:36 Finished restore at 04-MAR-13 |
检验/oracle/u01/app/oracle/oradata/orcl路径下已经恢复数据文件。
|
RMAN> alter database open resetlogs;
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 03/04/2013 17:05:30 ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/oracle/u01/app/oracle/oradata/orcl/system01.dbf' |
因为我们只是在物理层恢复了数据文件,还需要在逻辑上恢复数据库。
|
RMAN> recover database;
Starting recover at 04-MAR-13 using channel ORA_DISK_1
starting media recovery
unable to find archive log archive log thread=1 sequence=3 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 03/04/2013 17:06:34 RMAN-06054: media recovery requesting unknown log: thread 1 seq 3 lowscn 5925 |
报错是因为找不到到日志文件,继续下一步。
|
RMAN> alter database open resetlogs;
database opened |
检验/oracle/u01/app/oracle/oradata/orcl路径下已经恢复了日志文件
此时数据库已经启动完成。
|
SQL>startup force |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26252014/viewspace-755277/ ,如需转载,请注明出处,否则将追究法律责任。