cp方式恢复控制文件

使用cp方式恢复控制文件并恢复数据库,这是在线备份的方式。
--备份控制文件到指定的路径:

sys@PROD>alter database backup controlfile to '/home/oracle/control_bak.ctl';

Database altered.
--查看生成的控制文件备份:

sys@PROD>!ls /home/oracle/control_bak.ctl

/home/oracle/control_bak.ctl


 --先只删除一个控制文件:

!rm /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!rm /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!ls /u01/app/oracle/oradata/PROD/control01.ctl

ls: /u01/app/oracle/oradata/PROD/control01.ctl: No such file or directory

sys@PROD>shutdown immediate;

--尝试关库:

Database closed.

ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/oradata/PROD/control01.ctl'

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

sys@PROD>

sys@PROD>

sys@PROD>shutdown abort;

ORACLE instance shut down.

 

--将备份的控制文件复制到控制文件原目录

!cp /home/oracle/control_bak.ctl /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!cp /home/oracle/control_bak.ctl /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!ls /u01/app/oracle/oradata/PROD/control01.ctl

/u01/app/oracle/oradata/PROD/control01.ctl

 

--数据库启动到mount模式

sys@PROD>startup mount;

ORACLE instance started.

 

Total System Global Area  835104768 bytes

Fixed Size                  2257840 bytes

Variable Size             507513936 bytes

Database Buffers          322961408 bytes

Redo Buffers                2371584 bytes

ORA-00214: control file '/u01/app/oracle/fast_recovery_area/PROD/control02.ctl'

version 1904 inconsistent with file

'/u01/app/oracle/oradata/PROD/control01.ctl' version 1901

#版本不一致。

 

--删除其中一个控制文件,从备份中拷贝一份:

sys@PROD>!rm /u01/app/oracle/fast_recovery_area/PROD/control02.ctl

sys@PROD>!cp /home/oracle/control_bak.ctl /u01/app/oracle/fast_recovery_area/PROD/control02.ctl

sys@PROD>!ls /u01/app/oracle/fast_recovery_area/PROD/control02.ctl

/u01/app/oracle/fast_recovery_area/PROD/control02.ctl

 #这里为了两个控制文件的版本一致性,删除版本号大的日志文件,然后从备份中复制一份。

--关闭重启实例到mount状态:

sys@PROD>startup mount;

ORA-01081: cannot start already-running ORACLE - shut it down first

sys@PROD>shutdown abort;    

ORACLE instance shut down.

sys@PROD>

sys@PROD>

sys@PROD>startup mount;

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size                  2257840 bytes

Variable Size             507513936 bytes

Database Buffers          322961408 bytes

Redo Buffers                2371584 bytes

Database mounted.

sys@PROD>

 

--尝试open数据库

sys@PROD>alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 

sys@PROD>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/PROD/system01.dbf'

sys@PROD>recover database;

ORA-00283: recovery session canceled due to errors

ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

 

--使用归档日志恢复系统数据文件:

sys@PROD>recover database using backup controlfile until cancel;

ORA-00279: change 1784270 generated at 11/07/2016 16:33:19 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/PROD/archivelog/2016_11_07/o1_mf_1_1_%u_.arc

ORA-00280: change 1784270 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

cancel

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01152: file 1 was not restored from a sufficiently old backup

ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'

ORA-01112: media recovery not started

 #提示需要从日志文件恢复系统数据文件。

--查看当前的日志组:

sys@PROD>select group#,status from v$log where status='CURRENT';

    GROUP# STATUS

---------- ----------------

         1 CURRENT

sys@PROD>recover database using backup controlfile until cancel;

ORA-00279: change 1784270 generated at 11/07/2016 16:33:19 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/PROD/archivelog/2016_11_07/o1_mf_1_1_%u_.arc

ORA-00280: change 1784270 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

/u01/app/oracle/oradata/PROD/redo01.log         #输入第一组日志文件的绝对路径#

Log applied.

Media recovery complete.

sys@PROD>

--再次尝试打开数据库:

sys@PROD>alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

sys@PROD>alter database open RESETLOGS;

Database altered.

#成功打开数据库。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31392094/viewspace-2127991/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31392094/viewspace-2127991/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值