根据这个帖子http://www.itpub.net/viewthread.php?tid=1027951&extra=&page=1,进行模拟冷备份冷备份+归档文件,是否能恢复到初始状态。
试验的想法:
先对数据库进行冷备份,保证数据库开启归档,然后创建一个表。随后关闭数据库,将数据文件和控制文件拷贝到原来的位置,实现冷备还原。
试验的目的:
冷备还原后,能将创建的表恢复。
测试结果:失败!
主要做法:
1.冷备初始的所有文件,包括数据文件,日志文件,控制文件,参数文件等等,所有的文件。
2.检查归档日志:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
3.创建一个表:
SQL> select * from xx
2 ;
XX
----------
glf
4.关闭数据库:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
5.将原来冷备的控制文件,数据文件拷贝到现在目录下。
6.打开数据库:
SQL> startup
ORACLE instance started.
Total System Global Area 293601280 bytes
Fixed Size 1219040 bytes
Variable Size 100664864 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-00338: log 1 of thread 1 is more recent than control file
ORA-00312: online log 1 thread 1: '/oracle/oradata/orcl/redo01.log'
7.当控制文件和日志文件不一致的时候:
startup mount
ORACLE instance started.
Total System Global Area 293601280 bytes
Fixed Size 1219040 bytes
Variable Size 100664864 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
Database mounted.
红色标注是错误的做法:这样只是不完全恢复!
SQL> recover database using backup controlfile until cancel
ORA-00279: change 537267 generated at 08/01/2008 11:46:29 needed for thread 1
ORA-00289: suggestion :
/oracle/flash_recovery_area/ORCL/archivelog/2008_08_01/o1_mf_1_4_%u_.arc
ORA-00280: change 537267 for thread 1 is in sequence #4
Specify log: {
auto
ORA-00308: cannot open archived log
'/oracle/flash_recovery_area/ORCL/archivelog/2008_08_01/o1_mf_1_4_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00308: cannot open archived log
'/oracle/flash_recovery_area/ORCL/archivelog/2008_08_01/o1_mf_1_4_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
上面这样做其实是错误的,因为没有找到归档日志。应该从在线redolog入手,进行日志恢复。
SQL> conn sys/oracle as sysdba
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 293601280 bytes
Fixed Size 1219040 bytes
Variable Size 100664864 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
8.寻找以前那张表:
SQL> select * from xx;
select * from xx
*
ERROR at line 1:
ORA-00942: table or view does not exist
试验和预期结果不一致
正确做法:
SQL> recover database using backup controlfile;
ORA-00279: change 559252 generated at 08/01/2008 15:28:02 needed for thread 1
ORA-00289: suggestion :
/oracle/flash_recovery_area/ORCL/archivelog/2008_08_02/o1_mf_1_2_%u_.arc
ORA-00280: change 559252 for thread 1 is in sequence #2
Specify log: {
/oracle/oradata/orcl/redo01.log
Log applied.
Media recovery complete.
然后SQL> alter database open resetlogs;
Database altered.
SQL> select * from xx
2 ;
XX
----------
glf
试验和预期结果一致。
总结:实际这个是一个控制文件和日志文件不一致问题,如果直接使用"alter database open resetlogs" 显然是不完全恢复,那么一定会丢数据。如果先恢复联机日志,在重置日志组,实现完全恢复。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8334342/viewspace-417488/ ,如需转载,请注明出处,否则将追究法律责任。