您的位置:首页 > 运维架构

丢失控制文件,有旧的备份控制文件,之后有drop表空间和create表空间的操作恢复。

2013-01-15 16:48 781 查看
一、实验说明:

本实验是基于: 《丢失控制文件恢复实验记录--1(当前的控制文件损坏,使用旧控制文件进行恢复(旧控制文件之后DROP了表空间的情况))》 《丢失控制文件恢复实验记录--2(当前的控制文件损坏,使用旧控制文件进行恢复(旧控制文件之后新增了表空间的情况))》,把这两个实验的情况综合以后做一个恢复实验。

操作系统:rhel 5.4 x32

数据库:oracle 11g r2

二、操作内容:

----首先做一个当前控制文件的备份----
1 RMAN> backup current controlfile;

Starting backup at 15-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=31 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 15-JAN-13
channel ORA_DISK_1: finished piece 1 at 15-JAN-13
piece handle=/u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T172740_8hb88g4w_.bkp tag=TAG20130115T172740 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-JAN-13

----产生一些数据,其中先创建表空间echo,再删除表空间jack,最后创建表空间jacks----
16 SQL> create tablespace echo datafile '/u01/app/oracle/oradata/echo01.dbf' size 50m;

Tablespace created.

SQL> alter system switch logfile;

System altered.

SQL> drop tablespace jack including contents and datafiles;

Tablespace dropped.

SQL> create table echo_part tablespace echo as select * from dba_objects where rownum<1000;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> create tablespace jacks datafile '/u01/app/oracle/oradata/jacks01.dbf' size 50m;

Tablespace created.

SQL> alter system switch logfile;

System altered.

SQL> delete from jack_part where rownum<500;

499 rows deleted.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> select count(*) from echo_part;

COUNT(*)
----------
999

SQL> select count(*) from jack_part;

COUNT(*)
----------
1500

----模拟控制文件丢失----
80 SQL> shutdown abort;
ORACLE instance shut down.

[oracle@yft yft]$ rm /u01/app/oracle/oradata/yft/control01.ctl
[oracle@yft yft]$ rm /u01/app/oracle/flash_recovery_area/yft/control02.ctl

----启动时报错----
86 SQL> startup
ORACLE instance started.

Total System Global Area  330600448 bytes
Fixed Size            1336344 bytes
Variable Size          272632808 bytes
Database Buffers       50331648 bytes
Redo Buffers            6299648 bytes
ORA-00205: error in identifying control file, check alert log for more info

----alert日志里面也报错----
96 ALTER DATABASE   MOUNT
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/flash_recovery_area/yft/control02.ctl'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/yft/control01.ctl'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-205 signalled during: ALTER DATABASE   MOUNT...

----恢复一下旧的控制文件----
109 RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T172740_8hb88g4w_.bkp';

Starting restore at 15-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/yft/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/yft/control02.ctl
Finished restore at 15-JAN-13

----将数据库至于mount状态----
122 RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

----查看数据文件信息,因为这时用的是旧的控制文件,所以jack还存在的,后创建的表空间是看不见的----
127 SQL> select file#, name, status from v$datafile;

FILE# NAME                                            STATUS
---------- ------------------------------------------ ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf            SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf            ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf           ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf             ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf           ONLINE
6 /u01/app/oracle/oradata/yft/jack01.dbf              ONLINE

6 rows selected.

----这时候恢复会报错----
140 RMAN> recover database;

Starting recover at 15-JAN-13
Starting implicit crosscheck backup at 15-JAN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Finished implicit crosscheck backup at 15-JAN-13

Starting implicit crosscheck copy at 15-JAN-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 15-JAN-13

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_3_8hb8cpok_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_7_8hb8fzoy_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_6_8hb8fwpt_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_4_8hb8dl3l_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_2_8hb8cjnn_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_5_8hb8fplg_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc
File Name: /u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T172740_8hb88g4w_.bkp
File Name: /u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T120908_8h9om64f_.bkp
File Name: /u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T165728_8hb6hwyn_.bkp
File Name: /u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T113519_8h9mmrr6_.bkp

using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/15/2013 17:32:40
RMAN-06094: datafile 6 must be restored

----查看一下有多少归档日志----
177 [oracle@yft yft]$ ll /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/
total 964
-rw-r----- 1 oracle oinstall 529408 Jan 15 17:28 o1_mf_1_1_8hb89qfn_.arc
-rw-r----- 1 oracle oinstall 152576 Jan 15 17:29 o1_mf_1_2_8hb8cjnn_.arc
-rw-r----- 1 oracle oinstall   1536 Jan 15 17:29 o1_mf_1_3_8hb8cpok_.arc
-rw-r----- 1 oracle oinstall  73728 Jan 15 17:29 o1_mf_1_4_8hb8dl3l_.arc
-rw-r----- 1 oracle oinstall 193024 Jan 15 17:30 o1_mf_1_5_8hb8fplg_.arc
-rw-r----- 1 oracle oinstall   1536 Jan 15 17:30 o1_mf_1_6_8hb8fwpt_.arc
-rw-r----- 1 oracle oinstall   2048 Jan 15 17:30 o1_mf_1_7_8hb8fzoy_.arc

---基于控制文件恢复,这时不能锁定6号文件,所以需要将6号文件offline----
187 SQL> recover database using backup controlfile;
ORA-00283: recovery session canceled due to errors
ORA-01110: data file 6: '/u01/app/oracle/oradata/yft/jack01.dbf'
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/oradata/yft/jack01.dbf'

SQL> alter database datafile 6 offline;

Database altered.

----基于控制文件恢复,将归档日志一个一个恢复,当出现有报错时,将数据文件置于offline-----
198 SQL> recover database using backup controlfile;
ORA-00279: change 3794952 generated at 01/15/2013 17:19:33 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc
ORA-00280: change 3794952 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc
ORA-00283: recovery session canceled due to errors
ORA-01244: unnamed datafile(s) added to control file by media recovery
ORA-01110: data file 7: '/u01/app/oracle/oradata/echo01.dbf'

ORA-01112: media recovery not started

SQL> /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc
SP2-0734: unknown command beginning "/u01/app/o..." - rest of line ignored.
SQL> recover database using backup controlfile;
ORA-00283: recovery session canceled due to errors
ORA-01111: name for data file 7 is unknown - rename to correct file
ORA-01110: data file 7: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00007'
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01111: name for data file 7 is unknown - rename to correct file
ORA-01110: data file 7: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00007'

SQL> select file#, name, status from v$datafile;

FILE# NAME                                                   STATUS
---------- ---------------------------------------------------- ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf                   SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf                   ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf                  ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf                    ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf                  ONLINE
6 /u01/app/oracle/oradata/yft/jack01.dbf                     RECOVER
7 /u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00007       RECOVER

7 rows selected.

SQL> alter database datafile 7 offline;

Database altered.

SQL> recover database using backup controlfile;
ORA-00279: change 3794981 generated at 01/15/2013 17:28:11 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc
ORA-00280: change 3794981 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc
ORA-00279: change 3795249 generated at 01/15/2013 17:28:23 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_2_8hb8cjnn_.arc
ORA-00280: change 3795249 for thread 1 is in sequence #2
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_1_8hb89qfn_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_2_8hb8cjnn_.arc
ORA-00279: change 3795309 generated at 01/15/2013 17:29:20 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_3_8hb8cpok_.arc
ORA-00280: change 3795309 for thread 1 is in sequence #3
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_2_8hb8cjnn_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_3_8hb8cpok_.arc
ORA-00279: change 3795314 generated at 01/15/2013 17:29:26 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_4_8hb8dl3l_.arc
ORA-00280: change 3795314 for thread 1 is in sequence #4
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_3_8hb8cpok_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_4_8hb8dl3l_.arc
ORA-00283: recovery session canceled due to errors
ORA-01244: unnamed datafile(s) added to control file by media recovery
ORA-01110: data file 6: '/u01/app/oracle/oradata/jacks01.dbf'

ORA-01112: media recovery not started

SQL> select file#, name, status from v$datafile;

FILE# NAME                             STATUS
---------- ------------------------------------------------------------ ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf            SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf            ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf            ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf            ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf            ONLINE
6 /u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006     RECOVER
7 /u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00007     RECOVER

7 rows selected.

SQL> alter database datafile 7 offline;

Database altered.

SQL> recover database using backup controlfile;
ORA-00283: recovery session canceled due to errors
ORA-01111: name for data file 6 is unknown - rename to correct file
ORA-01110: data file 6: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006'
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01111: name for data file 6 is unknown - rename to correct file
ORA-01110: data file 6: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006'

SQL> alter database datafile 6 offline;

Database altered.

SQL> recover database using backup controlfile;
ORA-00279: change 3795326 generated at 01/15/2013 17:29:35 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_4_8hb8dl3l_.arc
ORA-00280: change 3795326 for thread 1 is in sequence #4

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_4_8hb8dl3l_.arc
ORA-00279: change 3795595 generated at 01/15/2013 17:29:54 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_5_8hb8fplg_.arc
ORA-00280: change 3795595 for thread 1 is in sequence #5
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_4_8hb8dl3l_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_5_8hb8fplg_.arc
ORA-00279: change 3795623 generated at 01/15/2013 17:30:30 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_6_8hb8fwpt_.arc
ORA-00280: change 3795623 for thread 1 is in sequence #6
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_5_8hb8fplg_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_6_8hb8fwpt_.arc
ORA-00279: change 3795628 generated at 01/15/2013 17:30:36 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_7_8hb8fzoy_.arc
ORA-00280: change 3795628 for thread 1 is in sequence #7
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_6_8hb8fwpt_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_7_8hb8fzoy_.arc
ORA-00279: change 3795632 generated at 01/15/2013 17:30:39 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_8_%u_.arc
ORA-00280: change 3795632 for thread 1 is in sequence #8
ORA-00278: log file '/u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_7_8hb8fzoy_.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/yft/redo02.log
Log applied.
Media recovery complete.

----因为从上面已经看到8号日志文件是不存的,就说明该文件是当前日志文件,可以使用select b.sequence#, a.member, b.status from v$logfile a, v$log b where a.group#=b.group#;
查询日志信息。----
----而且从alert日志从可以看到在abort之前的当前日志redo02.log----
364 Thread 1 advanced to log sequence 8 (LGWR switch)
Current log# 2 seq# 8 mem# 0: /u01/app/oracle/oradata/yft/redo02.log
Tue Jan 15 17:30:39 2013
Archived Log entry 27 added for thread 1 sequence 7 ID 0xb047497f dest 1:
Tue Jan 15 17:31:03 2013
Shutting down instance (abort)

----resetlogs打开数据库----
371 SQL> alter database open resetlogs;

Database altered.

SQL> select file#, name, status from v$datafile;

FILE# NAME                                                 STATUS
---------- ------------------------------------------------- ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf                 SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf                 ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf                ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf                  ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf                ONLINE
6 /u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006     OFFLINE
7 /u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00007     OFFLINE

7 rows selected.

----想要将jacks的表空间online表错----
389 SQL> alter tablespace jacks online;
alter tablespace jacks online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006'

SQL> alter database datafile 6 online;
alter database datafile 6 online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006'

----将open以后出现的$ORACLE_HOME/dbs路径下的文件重命名一下----
404 SQL> alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00006' to '/u01/app/oracle/oradata/jacks01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00007' to '/u01/app/oracle/oradata/echo01.dbf';

Database altered.

----online时还是报错就需要执行下面的步骤----
412 SQL> alter tablespace jacks online;
alter tablespace jacks online
*
ERROR at line 1:
ORA-01190: control file or data file 6 is from before the last RESETLOGS
ORA-01110: data file 6: '/u01/app/oracle/oradata/jacks01.dbf'

SQL> select file#, name, status from v$datafile;

FILE# NAME                                            STATUS
---------- --------------------------------------------- ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf            SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf            ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf           ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf             ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf           ONLINE
6 /u01/app/oracle/oradata/jacks01.dbf                 OFFLINE
7 /u01/app/oracle/oradata/echo01.dbf                  OFFLINE

7 rows selected.

----以下步骤是解决上面的报错的方法----
434 SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

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

Total System Global Area  330600448 bytes
Fixed Size            1336344 bytes
Variable Size          272632808 bytes
Database Buffers       50331648 bytes
Redo Buffers            6299648 bytes
Database mounted.
Database opened.
SQL> alter session set events 'immediate trace name adjust_scn level 1';

Session altered.

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

Total System Global Area  330600448 bytes
Fixed Size            1336344 bytes
Variable Size          272632808 bytes
Database Buffers       50331648 bytes
Redo Buffers            6299648 bytes
Database mounted.
SQL> select ts#,file#,name,status,checkpoint_change# from v$datafile;

TS#    FILE# NAME                                              STATUS       CHECKPOINT_CHANGE#
---------- ---------- -------------------------------------------- --------------- ------------------
0        1 /u01/app/oracle/oradata/yft/system01.dbf               SYSTEM              3796246
1        2 /u01/app/oracle/oradata/yft/sysaux01.dbf               ONLINE              3796246
2        3 /u01/app/oracle/oradata/yft/undotbs01.dbf              ONLINE              3796246
4        4 /u01/app/oracle/oradata/yft/users01.dbf                ONLINE              3796246
6        5 /u01/app/oracle/oradata/yft/example01.dbf              ONLINE              3796246
10        6 /u01/app/oracle/oradata/jacks01.dbf                    OFFLINE             3795324
9        7 /u01/app/oracle/oradata/echo01.dbf                     OFFLINE             3794979

7 rows selected.

SQL> recover until cancel;
Media recovery complete.
SQL> alter database datafile 2,3,4,5,6,7 online;

Database altered.

SQL> alter database open resetlogs;

Database altered.

SQL> select ts#,file#,name,status,checkpoint_change# from v$datafile;

TS#    FILE# NAME                                               STATUS       CHECKPOINT_CHANGE#
---------- ---------- --------------------------------------------- --------------- ------------------
0        1 /u01/app/oracle/oradata/yft/system01.dbf               SYSTEM              3796250
1        2 /u01/app/oracle/oradata/yft/sysaux01.dbf               ONLINE              3796250
2        3 /u01/app/oracle/oradata/yft/undotbs01.dbf              ONLINE              3796250
4        4 /u01/app/oracle/oradata/yft/users01.dbf                ONLINE              3796250
6        5 /u01/app/oracle/oradata/yft/example01.dbf              ONLINE              3796250
10        6 /u01/app/oracle/oradata/jacks01.dbf                    ONLINE              3796250
9        7 /u01/app/oracle/oradata/echo01.dbf                     ONLINE              3796250

7 rows selected.

SQL> select count(*) from echo_part;

COUNT(*)
----------
999

SQL> select count(*) from jack_part;

COUNT(*)
----------
1500


下面是恢复的另一种方法,是在恢复控制文件以后再重建控制文件,再基于控制文件恢复。

----在abort之前的操作跟上面一样----
1 SQL> select count(*) from echo_part;

COUNT(*)
----------
999

SQL> select count(*) from jack_part;

COUNT(*)
----------
1001

----进行控制文件恢复----
14 RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/YFT/backupset/2013_01_15/o1_mf_ncnnf_TAG20130115T172740_8hb88g4w_.bkp';

Starting restore at 15-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/yft/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/yft/control02.ctl
Finished restore at 15-JAN-13

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

SQL> select b.sequence#, a.member, b.status from v$logfile a, v$log b where a.group#=b.group#;

SEQUENCE# MEMBER                     STATUS
---------- --------------------------------------------- ---------------
1 /u01/app/oracle/oradata/yft/redo01.log     CURRENT
0 /u01/app/oracle/oradata/yft/redo02.log     UNUSED
0 /u01/app/oracle/oradata/yft/redo03.log     UNUSED
----重建控制文件----
41 SQL> alter database backup controlfile to trace;

Database altered.

SQL> select value from v$diag_info where NAME = 'Default Trace File';

VALUE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/yft/yft/trace/yft_ora_3964.trc

[oracle@yft bak]$ sed -n '/CREATE CONTROLFILE.*NORESETLOGS/,/;/p' /u01/app/oracle/diag/rdbms/yft/yft/trace/yft_ora_3964.trc
CREATE CONTROLFILE REUSE DATABASE "YFT" NORESETLOGS  ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/yft/redo01.log'  SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/yft/redo02.log'  SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/yft/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/yft/system01.dbf',
'/u01/app/oracle/oradata/yft/sysaux01.dbf',
'/u01/app/oracle/oradata/yft/undotbs01.dbf',
'/u01/app/oracle/oradata/yft/users01.dbf',
'/u01/app/oracle/oradata/yft/example01.dbf',
'/u01/app/oracle/oradata/yft/jack01.dbf'
CHARACTER SET AL32UTF8
;

SQL>CREATE CONTROLFILE REUSE DATABASE "YFT" NORESETLOGS  ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/yft/redo01.log'  SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/yft/redo02.log'  SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/yft/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/yft/system01.dbf',
'/u01/app/oracle/oradata/yft/sysaux01.dbf',
'/u01/app/oracle/oradata/yft/undotbs01.dbf',
'/u01/app/oracle/oradata/yft/users01.dbf',
17    '/u01/app/oracle/oradata/yft/example01.dbf'
CHARACTER SET AL32UTF8
19  ;

Control file created.

SQL> select b.sequence#, a.member, b.status from v$logfile a, v$log b where a.group#=b.group#;

SEQUENCE# MEMBER                                 STATUS
---------- ------------------------------------- ---------------
7 /u01/app/oracle/oradata/yft/redo01.log     INACTIVE
8 /u01/app/oracle/oradata/yft/redo02.log     CURRENT
6 /u01/app/oracle/oradata/yft/redo03.log     INACTIVE

SQL> recover database using backup controlfile;
ORA-00279: change 3797907 generated at 01/15/2013 17:55:36 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/YFT/archivelog/2013_01_15/o1_mf_1_8_%u_.arc
ORA-00280: change 3797907 for thread 1 is in sequence #8

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oracle/oradata/yft/redo02.log
Log applied.
Media recovery complete.
SQL> select file#, name, status from v$datafile;

FILE# NAME                                             STATUS
---------- --------------------------------------------- ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf             SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf             ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf            ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf              ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf            ONLINE

SQL> alter database open resetlogs;

Database altered.

SQL> select file#, name, status from v$datafile;

FILE# NAME                                                 STATUS
---------- ------------------------------------------------- ---------------
1 /u01/app/oracle/oradata/yft/system01.dbf                 SYSTEM
2 /u01/app/oracle/oradata/yft/sysaux01.dbf                 ONLINE
3 /u01/app/oracle/oradata/yft/undotbs01.dbf                ONLINE
4 /u01/app/oracle/oradata/yft/users01.dbf                  ONLINE
5 /u01/app/oracle/oradata/yft/example01.dbf                ONLINE
6 /u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00006     RECOVER
7 /u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00007     RECOVER

7 rows selected.

SQL> alter tablespace jacks online;
alter tablespace jacks online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01111: name for data file 6 is unknown - rename to correct file
ORA-01110: data file 6: '/u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00006'

SQL> alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00006' to '/u01/app/oracle/oradata/jacks01.dbf';

Database altered.

SQL> alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00007' to '/u01/app/oracle/oradata/echo01.dbf';

Database altered.

SQL> alter tablespace jacks online;
alter tablespace jacks online
*
ERROR at line 1:
ORA-01190: control file or data file 6 is from before the last RESETLOGS
ORA-01110: data file 6: '/u01/app/oracle/oradata/jacks01.dbf'

SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

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

Total System Global Area  330600448 bytes
Fixed Size            1336344 bytes
Variable Size          272632808 bytes
Database Buffers       50331648 bytes
Redo Buffers            6299648 bytes
Database mounted.
Database opened.
SQL> alter session set events 'immediate trace name adjust_scn level 1';

Session altered.

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

Total System Global Area  330600448 bytes
Fixed Size            1336344 bytes
Variable Size          272632808 bytes
Database Buffers       50331648 bytes
Redo Buffers            6299648 bytes
Database mounted.
SQL> select ts#,file#,name,status,checkpoint_change# from v$datafile;

TS#    FILE# NAME                                              STATUS       CHECKPOINT_CHANGE#
---------- ---------- ------------------------------------------- --------------- ------------------
0        1 /u01/app/oracle/oradata/yft/system01.dbf               SYSTEM              3798567
1        2 /u01/app/oracle/oradata/yft/sysaux01.dbf               ONLINE              3798567
2        3 /u01/app/oracle/oradata/yft/undotbs01.dbf              ONLINE              3798567
4        4 /u01/app/oracle/oradata/yft/users01.dbf                ONLINE              3798567
6        5 /u01/app/oracle/oradata/yft/example01.dbf              ONLINE              3798567
10        6 /u01/app/oracle/oradata/jacks01.dbf                    RECOVER                0
9        7 /u01/app/oracle/oradata/echo01.dbf                     RECOVER                0

7 rows selected.

SQL> recover until cancel;
Media recovery complete.
SQL> alter database datafile 2,3,4,5,6,7 online;

Database altered.

SQL> alter database open resetlogs;

Database altered.

SQL> select ts#,file#,name,status,checkpoint_change# from v$datafile;

TS#    FILE# NAME                                              STATUS       CHECKPOINT_CHANGE#
---------- ---------- ------------------------------------------ --------------- ------------------
0        1 /u01/app/oracle/oradata/yft/system01.dbf               SYSTEM              3798571
1        2 /u01/app/oracle/oradata/yft/sysaux01.dbf               ONLINE              3798571
2        3 /u01/app/oracle/oradata/yft/undotbs01.dbf              ONLINE              3798571
4        4 /u01/app/oracle/oradata/yft/users01.dbf                ONLINE              3798571
6        5 /u01/app/oracle/oradata/yft/example01.dbf              ONLINE              3798571
10        6 /u01/app/oracle/oradata/jacks01.dbf                    ONLINE              3798571
9        7 /u01/app/oracle/oradata/echo01.dbf                     ONLINE              3798571

7 rows selected.

SQL> select count(*) from jack_part;

COUNT(*)
----------
1001

SQL> select count(*) from echo_part;

COUNT(*)
----------
999
最后还是需要alter tablespace temp add tempfile '/u01/app/oracle/oradata/yft/temp02.dbf' size 200m;来增加临时表空间。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: