本文章是关于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的。