将备份的控制文件复制到控制文件路径!cp <backup control file path> <control file path>
打开数据库到mount模式alter database mount;
执行恢复控制文件的SQL命令recover database using backup controlfile;
计算还需应用的redolog
打开数据库到open模式alter database open resetlog
操作记录
模拟控制文件损坏
SQL>insertinto scott.t01 select*from scott.t01;
56rows created.
SQL>selectcount(*) from scott.t01;
COUNT(*) ---------- 112
SQL>select*from v$controlfile;
STATUS ------- NAME -------------------------------------------------------------------------------- IS_ BLOCK_SIZE FILE_SIZE_BLKS --- ---------- --------------
STATUS ------- NAME -------------------------------------------------------------------------------- IS_ BLOCK_SIZE FILE_SIZE_BLKS --- ---------- --------------
Total SystemGlobal Area 2137886720 bytes Fixed Size 2215064 bytes Variable Size 1392509800 bytes Database Buffers 738197504 bytes Redo Buffers 4964352 bytes ORA-00205: error in identifying control file, check alert log for more info
恢复控制文件
SQL>showparameter control_file;
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer7 control_files string /alidata/oracle/oradata/testdb /control01.ctl, /alidata/oracl e/flash_recovery_area/testdb/c ontrol02.ctl SQL>!cp -v /home/oracle/hotbk/control01.ctl /alidata/oracle/oradata/testdb/control01.ctl "/home/oracle/hotbk/control01.ctl" -> "/alidata/oracle/oradata/testdb/control01.ctl"
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto ORA-00279: change 3460407 generated at12/01/201921:48:24 needed for thread 1 ORA-00289: suggestion : /home/oracle/orc_booboo_dest1/1_121_1019996090.dbf ORA-00280: change 3460407for thread 1isin sequence #121 ORA-00278: log file '/home/oracle/orc_booboo_dest1/1_120_1019996090.dbf'no longer needed for this recovery
ORA-00279: change 3460410 generated at12/01/201921:48:25 needed for thread 1 ORA-00289: suggestion : /home/oracle/orc_booboo_dest1/1_122_1019996090.dbf ORA-00280: change 3460410for thread 1isin sequence #122 ORA-00278: log file '/home/oracle/orc_booboo_dest1/1_121_1019996090.dbf'no longer needed for this recovery
ORA-00279: change 3460413 generated at12/01/201921:48:27 needed for thread 1 ORA-00289: suggestion : /home/oracle/orc_booboo_dest1/1_123_1019996090.dbf ORA-00280: change 3460413for thread 1isin sequence #123 ORA-00278: log file '/home/oracle/orc_booboo_dest1/1_122_1019996090.dbf'no longer needed for this recovery
ORA-00279: change 3460416 generated at12/01/201921:48:28 needed for thread 1 ORA-00289: suggestion : /home/oracle/orc_booboo_dest1/1_124_1019996090.dbf ORA-00280: change 3460416for thread 1isin sequence #124 ORA-00278: log file '/home/oracle/orc_booboo_dest1/1_123_1019996090.dbf'no longer needed for this recovery
ORA-00279: change 3460419 generated at12/01/201921:48:30 needed for thread 1 ORA-00289: suggestion : /home/oracle/orc_booboo_dest1/1_125_1019996090.dbf ORA-00280: change 3460419for thread 1isin sequence #125 ORA-00278: log file '/home/oracle/orc_booboo_dest1/1_124_1019996090.dbf'no longer needed for this recovery
ORA-00308: cannot open archived log '/home/oracle/orc_booboo_dest1/1_125_1019996090.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3
SQL>columnmember format a50 SQL>select*from v$logfile;
GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 3 ONLINE /alidata/oracle/oradata/testdb/redo03.log NO 2 ONLINE /alidata/oracle/oradata/testdb/redo02.log NO 1 ONLINE /alidata/oracle/oradata/testdb/redo01.log NO
SQL>select file#,checkpoint_change# from v$datafile_header;
SQL>desc x$kcccp; Name Null? Type ----------------------------------------- -------- ---------------------------- ADDR RAW(8) INDX NUMBER INST_ID NUMBER CPTNO NUMBER CPSTA NUMBER CPFLG NUMBER CPDRT NUMBER CPRDB NUMBER CPLRBA_SEQ NUMBER CPLRBA_BNO NUMBER CPLRBA_BOF NUMBER CPODR_SEQ NUMBER CPODR_BNO NUMBER CPODR_BOF NUMBER CPODS VARCHAR2(16) CPODT VARCHAR2(20) CPODT_I NUMBER CPHBT NUMBER CPRLS VARCHAR2(16) CPRLC NUMBER CPMID NUMBER CPSDR_SEQ NUMBER CPSDR_BNO NUMBER CPSDR_ADB NUMBER
通过以下SQL可以查询到生产库lgwr进程已经写至current redolog的哪一个块。
select le.leseq CURRENT_LOG_SEQUENCE#,cp.CPODR_BNO from x$kcccp cp,x$kccle le where LE.leseq=CP.cpodr_seq and le.INST_ID=1;
大宝笔记
本节课重点掌握:
在线热备控制文件的命令
恢复数据库到控制文件时间点recover database using backup controlfile;