oracle - 控制文件 恢复

 

本文章是关于control 控制文件的恢复:

oracle@aoracle ezhou]$ ls -l | wc -l
18
[oracle@aoracle ezhou]$ ls -l *.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:43 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:43 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:43 control03.ctl
[oracle@aoracle ezhou]$ mv control01.ctl ./bak
[oracle@aoracle ezhou]$ ls -l *.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:44 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:44 control03.ctl

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup;
ORACLE instance started.

Total System Global Area  335544320 bytes
Fixed Size                  1219280 bytes
Variable Size              79693104 bytes
Database Buffers          251658240 bytes
Redo Buffers                2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info


SQL> select status from v$instance;

STATUS
------------
STARTED

SQL>

下面讲恢复:
[oracle@aoracle ezhou]$ cp control02.ctl control01.ctl
[oracle@aoracle ezhou]$ ls -l *.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:47 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:45 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 21:45 control03.ctl
[oracle@aoracle ezhou]$

shutdwon immediate;
startup;

Database mounted.

ORA-01122: database file 1 failed verification check
        ORA-01110: data file 1: '/u02/ezhou/system01.dbf'
        ORA-01207: file is more recent than controlfile - old controlfile

        rman target /
        run{
            restore database;
            recover database;
            sql 'alter database open';
            }
        RMAN-00571: ===========================================================
        RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
        RMAN-00571: ===========================================================
        RMAN-03009: failure of sql command on default channel at 09/08/2005 17:29:04
        RMAN-11003: failure during parse/execution of SQL statement: alter database open
        ORA-00322: log 3 of thread 1 is not current copy
        ORA-00312: online log 3 thread 1: '/u02/ezhou/redo03.log'
        ORA-00312: online log 3 thread 1: '/u02/ezhou/redo01.log'
        ORA-00312: online log 3 thread 1: '/u02/ezhou/redo02.log'

        alter database clear unarchived logfile group 1;
        alter database open;

    恢复成功
   
===========================

下面讲损坏全部control file 的处理:

[oracle@aoracle ezhou]$ mv *.ctl ./bak
[oracle@aoracle ezhou]$ ls -l *.ctl
ls: *.ctl: No such file or directory


因为 nomount ---> mounted 状态是要有control file的。
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  335544320 bytes
Fixed Size                  1219280 bytes
Variable Size              79693104 bytes
Database Buffers          251658240 bytes
Redo Buffers                2973696 bytes
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info

shutdwon immediate;
startup nomount;

[oracle@aoracle u02]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 6 21:56:13 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ezhou (not mounted)

RMAN> run {
2> restore controlfile;
3> restore database;
4> sql 'alter database mount';
5> recover database;
6> sql 'alter database open resetlogs';
7> }

Starting restore at 06-DEC-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/06/2011 21:57:40
RMAN-06563: control file or SPFILE must be restored using FROM AUTOBACKUP

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of configure command at 12/06/2011 21:59:04
ORA-01507: database not mounted

-----------------
没有办法,下面从rman 备份的路径下恢复:

RMAN> restore controlfile from '/u02/rman/ctl_c-4046377924-20111206-01';

Starting restore at 06-DEC-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u02/ezhou/control01.ctl
output filename=/u02/ezhou/control02.ctl
output filename=/u02/ezhou/control03.ctl
Finished restore at 06-DEC-11

看一下:
[oracle@aoracle ezhou]$ ls -l *.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 22:17 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 22:17 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 Dec  6 22:17 control03.ctl

恢复成功。

经验说明,做个全备是多么的重要。

RMAN> sql ' alter database mount';

sql statement:  alter database mount
released channel: ORA_DISK_1

RMAN> exit

Recovery Manager complete.
[oracle@aoracle u02]$ exit
exit

SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> !
[oracle@aoracle u02]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 6 22:22:18 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: EZHOU (DBID=4046377924, not open)

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/rman/ctl_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/pp/oracle/product/10.2/db_1/dbs/snapcf_ezhou.f'; # default

RMAN>

可以看到oracle 在 mounted 和nomount 下看到的rman 的show是不一样的。
现在control autobackup 是on的。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenghuiping2001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值