recover database using backup controlfile; (恢复的时候告诉数据库不要以控制文件的scn恢复,使用数据库的scn为准进行恢复)
1.关闭数据库,对控制文件进行冷备份
SQL> shutdown immediate
cp /u01/app/oracle/oradata/slnngk/control01.ctl /u01/app/oracle/oradata/slnngk/bak_control01.ctl
cp /u01/app/oracle/fast_recovery_area/slnngk/control02.ctl /u01/app/oracle/fast_recovery_area/slnngk/bak_control02.ctl
2.启动数据库执行检查点切换
SQL> startup
ORACLE instance started.
Total System Global Area 1837244416 bytes
Fixed Size 2254224 bytes
Variable Size 503319152 bytes
Database Buffers 1325400064 bytes
Redo Buffers 6270976 bytes
Database mounted.
Database opened.
SQL> alter system checkpoint;
System altered.
SQL> alter system checkpoint;
System altered.
3.关闭数据库,使用原来备份的控制文件启动数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
cp /u01/app/oracle/oradata/slnngk/bak_control01.ctl /u01/app/oracle/oradata/slnngk/control01.ctl
cp /u01/app/oracle/fast_recovery_area/slnngk/bak_control02.ctl /u01/app/oracle/fast_recovery_area/slnngk/control02.ctl
4.尝试启动数据库
SQL> startup
ORACLE instance started.
Total System Global Area 1837244416 bytes
Fixed Size 2254224 bytes
Variable Size 503319152 bytes
Database Buffers 1325400064 bytes
Redo Buffers 6270976 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/slnngk/system01.dbf'
ORA-01207: file is more recent than control file - old control file
提示数据库的scn大于控制文件记录的
查看控制文件scn
SQL> select CHECKPOINT_CHANGE# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1717921
1717921
1717921
1717921
1717921
1717921
6 rows selected.
查看数据文件头部scn
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
1718516
1718516
1718516
1718516
1718516
1718516
6 rows selected.
5.尝试恢复
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/slnngk/system01.dbf'
ORA-01207: file is more recent than control file - old control file
SQL> recover database until cancel;
ORA-00283: recovery session canceled due to errors
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/slnngk/system01.dbf'
ORA-01207: file is more recent than control file - old control file
加上using backup controlfile 参数,告诉数据库不要以控制文件的scn为准恢复数据库,以数据库的scn为准进行恢复
recover database using backup controlfile;
SQL> recover database using backup controlfile;
ORA-00279: change 1717921 generated at 11/12/2021 01:07:36 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/fast_recovery_area/SLNNGK/archivelog/2021_11_12/o1_mf_1_5_%u_.ar
c
ORA-00280: change 1717921 for thread 1 is in sequence #5
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/slnngk/redo08.log ####这里逐一输入redo日志组
Log applied.
Media recovery complete.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
2 INACTIVE
9 UNUSED
7 INACTIVE
8 CURRENT
3 INACTIVE
6 rows selected.
6.打开数据库
SQL> alter database open resetlogs;
Database altered.
使用rman恢复旧的控制文件
1.关闭数据库
SQL> shutdown immediate
2.删除当前的控制文件
mv /u01/app/oracle/oradata/slnngk/control01.ctl /u01/app/oracle/oradata/slnngk/bak_control01.ctl
mv /u01/app/oracle/fast_recovery_area/slnngk/control02.ctl /u01/app/oracle/fast_recovery_area/slnngk/bak_control02.ctl
3.启动数据库里到nomount
SQL> startup nomount
4.恢复控制文件
RMAN> restore controlfile from '/u01/rmanbak/daily_ctl_SLNNGK_252_7s0duvc5_20211112.bak';
Starting restore at 12-NOV-21
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/slnngk/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/slnngk/control02.ctl
Finished restore at 12-NOV-21
5.恢复
SQL> alter database mount;
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
SQL> recover database using backup controlfile;
ORA-00279: change 1721111 generated at 11/12/2021 02:15:12 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/fast_recovery_area/SLNNGK/archivelog/2021_11_12/o1_mf_1_5_%u_.ar
c
ORA-00280: change 1721111 for thread 1 is in sequence #5
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/slnngk/redo02.log
ORA-00310: archived log contains sequence 2; sequence 5 required
ORA-00334: archived log: '/u01/app/oracle/oradata/slnngk/redo02.log'
SQL> recover database using backup controlfile;
ORA-00279: change 1721111 generated at 11/12/2021 02:15:12 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/fast_recovery_area/SLNNGK/archivelog/2021_11_12/o1_mf_1_5_%u_.ar
c
ORA-00280: change 1721111 for thread 1 is in sequence #5
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/slnngk/redo07.log
ORA-00310: archived log contains sequence 4; sequence 5 required
ORA-00334: archived log: '/u01/app/oracle/oradata/slnngk/redo07.log'
SQL> recover database using backup controlfile;
ORA-00279: change 1721111 generated at 11/12/2021 02:15:12 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/fast_recovery_area/SLNNGK/archivelog/2021_11_12/o1_mf_1_5_%u_.ar
c
ORA-00280: change 1721111 for thread 1 is in sequence #5
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/slnngk/redo08.log ##这里逐一输入redo日志组
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.