oracle之控制文件恢复

实验环境是在归档模式下,并且日志文件都在。

步骤:1. 全备数据库

 2. 利用备份的控制文件进行恢复

实验就把第一步省略了,直接开始第二步。

首先,先打开数据库到归档模式下:

SQL> startup mount
ORACLE instance started.
Total System Global Area  845348864 bytes
Fixed Size                  1339796 bytes
Variable Size             599789164 bytes
Database Buffers          239075328 bytes
Redo Buffers                5144576 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> select open_mode,log_mode from v$database;
OPEN_MODE                                LOG_MODE
---------------------------------------- ------------------------
READ WRITE                               ARCHIVELOG
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/product/11.2.0/db_1/ora_log
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2

开始备份控制文件:

SQL> alter database backup controlfile to '/tmp/controlfile.bak';
Database altered.

把原来的控制文件都删除,有几个删除几个,可以show parameter control_files查看,再次启动数据库:

SQL> startup
ORACLE instance started.
Total System Global Area  845348864 bytes
Fixed Size                  1339796 bytes
Variable Size             599789164 bytes
Database Buffers          239075328 bytes
Redo Buffers                5144576 bytes
ORA-00205: error in identifying control file, check alert log for more info

控制文件丢失,启动报错了,拷贝控制文件到原来的地方,有几个拷贝几个

cp /tmp/controlfile.bak $ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl

再次启动数据库

SQL> startup
ORACLE instance started.
Total System Global Area  845348864 bytes
Fixed Size                  1339796 bytes
Variable Size             599789164 bytes
Database Buffers          239075328 bytes
Redo Buffers                5144576 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

数据库已经挂载,但是没有打开,接下来按提示操作:

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/app/oracle/oradata/myorcl/system01.dbf'
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 1298791 generated at 01/09/2014 05:50:43 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/product/11.2.0/db_1/ora_log/1_25_835925739.dbf
ORA-00280: change 1298791 for thread 1 is in sequence #25
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/myorcl/redo01.log
Log applied.
Media recovery complete.

到这里,数据库已经提示恢复完成了,可以打开数据库了

SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
----------------------------------------
READ WRITE


你可能感兴趣的:(oracle,recover,文件恢复,control_files)