【控制文件丢失-恢复-1】

控制文件恢复:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:35:08 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> alter system set control_files=‘/u01/oracle/oradata/jadl10g/control01.ctl‘,‘/u01/oracle/flash_recovery_area/jadl10g/control02.ctl‘ scope=spfile;

System altered.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> ho cp /u01/oracle/oradata/jadl10g/control02.ctl /u01/oracle/flash_recovery_area/jadl10g/control02.ctl

SQL> startup

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

Database opened.

SQL> select name from v$controlfile;

NAME

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

/u01/oracle/oradata/jadl10g/control01.ctl

/u01/oracle/flash_recovery_area/jadl10g/control02.ctl

进入rman确定存在控制文件的备份集:

RMAN> list backup of controlfile;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

6       Full    6.80M      DISK        00:00:01     06-NOV-14

BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20141106T103719

Piece Name: /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T103719_b5oqr4bc_.bkp

Control File Included: Ckp SCN: 457789       Ckp time: 06-NOV-14

1.部分丢失:

[[email protected] ~]$ rm /u01/oracle/oradata/jadl10g/control01.ctl

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 10:39:42 2014

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

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00554: initialization of internal recovery manager package failed

RMAN-06003: ORACLE error from target database:

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/oracle/oradata/jadl10g/control01.ctl‘

ORA-27041: unable to open file

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

Additional information: 3

rman的备份信息是记录在控制文件中的,连接到rman时会报错的。但是可以连接到sqlplus。

能执行的操作是查询等,不涉及控制文件的变化,涉及控制文件的变化就会出错。

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:43:43 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> conn scott/tiger

Connected.

SQL> select * from dept;

DEPTNO DNAME          LOC

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

10 ACCOUNTING     NEW YORK

20 RESEARCH       DALLAS

30 SALES          CHICAGO

40 OPERATIONS     BOSTON

此时不能一致性关闭数据库(shutdown immediate),是不能触发ckpt的,所以只能是shutdown abort;

SQL> shutdown immediate

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/oracle/oradata/jadl10g/control01.ctl‘

ORA-27041: unable to open file

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

Additional information: 3

SQL> shutdown abort

ORACLE instance shut down.

部分性丢失拷贝存在的为丢失的文件,不需要rman做恢复:

[[email protected] ~]$ cp /u01/oracle/flash_recovery_area/jadl10g/control02.ctl /u01/oracle/oradata/jadl10g/control01.ctl

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:47:13 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

Database opened.

2.全部丢失

删除所有的控制文件:

[[email protected] ~]$ rm /u01/oracle/oradata/jadl10g/control01.ctl

[[email protected] ~]$ rm /u01/oracle/flash_recovery_area/jadl10g/control02.ctl

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 10:50:22 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> shutdown immediate ---不能一致性关闭数据库

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/oracle/oradata/jadl10g/control01.ctl‘

ORA-27041: unable to open file

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

Additional information: 3

SQL> shutdown abort  ---只能这样关闭数据库

ORACLE instance shut down.

连接到rman:

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 10:52:18 2014

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

connected to target database (not started)

RMAN> startup nomount  --启动数据库到nomount阶段

Oracle instance started

Total System Global Area     599785472 bytes

Fixed Size                     2098112 bytes

Variable Size                163580992 bytes

Database Buffers             427819008 bytes

Redo Buffers                   6287360 bytes

RMAN> restore controlfile from autobackup;  ---该命令只能在打开了自动备份的情况下执行;

Starting restore at 06-NOV-14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

recovery area destination: /u01/oracle/flash_recovery_area

database name (or database unique name) used for search: JADL10G

channel ORA_DISK_1: no autobackups found in the recovery area

autobackup search outside recovery area not attempted because DBID was not set

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 11/06/2014 10:52:59

RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

---出错是由于没有打开自动备份

RMAN>  exit

Recovery Manager complete.

找到文件的备份集:

[[email protected] ~]$ ls /u01/oracle/flash_recovery_area/JADL10G/backupset/

2014_11_05  2014_11_06

[[email protected] ~]$ ls /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06

o1_mf_annnn_BACKUP_JADL10G_000_1_b5nlkxph_.bkp

o1_mf_ncnnf_TAG20141106T013740_b5nr3599_.bkp

o1_mf_ncsnf_BACKUP_JADL10G_000_1_b5nlkr13_.bkp

o1_mf_ncsnf_TAG20141106T001636_b5nmdmv8_.bkp

o1_mf_ncsnf_TAG20141106T021509_b5ntbwdp_.bkp

o1_mf_ncsnf_TAG20141106T052124_b5o59df8_.bkp

o1_mf_ncsnf_TAG20141106T103719_b5oqr4bc_.bkp

o1_mf_nnndf_BACKUP_JADL10G_000_1_b5nljc9p_.bkp

o1_mf_nnndf_TAG20141106T001636_b5nmc58w_.bkp

o1_mf_nnndf_TAG20141106T021509_b5nt9fsr_.bkp

o1_mf_nnndf_TAG20141106T052124_b5o56ok0_.bkp

o1_mf_nnndf_TAG20141106T103719_b5oqpzy9_.bkp

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 10:56:40 2014

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

connected to target database: jadl10g (not mounted)

----也可以采用如下的命令执行恢复,注意此路径的中备份必须存在,是ncsnf开头的。

RMAN> restore controlfile from ‘/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T103719_b5oqr4bc_.bkp‘;

Starting restore at 06-NOV-14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

output filename=/u01/oracle/oradata/jadl10g/control01.ctl

output filename=/u01/oracle/flash_recovery_area/jadl10g/control02.ctl

Finished restore at 06-NOV-14

RMAN> alter database mount; --启动到mount

database mounted

released channel: ORA_DISK_1

RMAN> recover database; --恢复数据库

Starting recover at 06-NOV-14

Starting implicit crosscheck backup at 06-NOV-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 06-NOV-14

Starting implicit crosscheck copy at 06-NOV-14

using channel ORA_DISK_1

Finished implicit crosscheck copy at 06-NOV-14

searching for all files in the recovery area

cataloging files...

cataloging done

List of Cataloged Files

=======================

File Name: /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T103719_b5oqr4bc_.bkp

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_31_b5or9wnr_.arc

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 31 is already on disk as file /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_31_b5or9wnr_.arc

archive log thread 1 sequence 32 is already on disk as file /u01/oracle/oradata/jadl10g/redo02.log

archive log filename=/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_31_b5or9wnr_.arc thread=1 sequence=31

archive log filename=/u01/oracle/oradata/jadl10g/redo02.log thread=1 sequence=32

media recovery complete, elapsed time: 00:00:03

Finished recover at 06-NOV-14

RMAN> alter database open resetlogs;  ---执行该命令后,需要重新备份数据库,之前的备份无效了。

database opened

RMAN> backup database;

Starting backup at 06-NOV-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/u01/oracle/oradata/jadl10g/system01.dbf

input datafile fno=00003 name=/u01/oracle/oradata/jadl10g/sysaux01.dbf

input datafile fno=00005 name=/u01/oracle/oradata/jadl10g/example01.dbf

input datafile fno=00002 name=/u01/oracle/oradata/jadl10g/undotbs01.dbf

input datafile fno=00004 name=/u01/oracle/oradata/jadl10g/users01.dbf

channel ORA_DISK_1: starting piece 1 at 06-NOV-14

channel ORA_DISK_1: finished piece 1 at 06-NOV-14

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T110014_b5os1yxq_.bkp tag=TAG20141106T110014 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 06-NOV-14

channel ORA_DISK_1: finished piece 1 at 06-NOV-14

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T110014_b5os338z_.bkp tag=TAG20141106T110014 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 06-NOV-14

3.控制文件丢失,日志文件也丢失,采用重建控制文件脚本的方法来恢复

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 12:48:14 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> create table scott.c1 as select * from scott.dept;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     2

Next log sequence to archive   4

Current log sequence           4

SQL> create table scott.c2 as select * from scott.dept;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     3

Next log sequence to archive   5

Current log sequence           5

SQL> create table scott.c3 as select * from scott.dept;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     4

Next log sequence to archive   6

Current log sequence           6

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

[[email protected] ~]$ ls /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/

o1_mf_1_2_b5oydkr2_.arc  o1_mf_1_4_b5ozhtq5_.arc

o1_mf_1_3_b5ozgwpw_.arc  o1_mf_1_5_b5ozjrrr_.arc

[[email protected] ~]$ rm /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_4_b5ozhtq5_.arc

[[email protected] ~]$ rm /u01/oracle/oradata/jadl10g/control01.ctl

[[email protected] ~]$ rm /u01/oracle/flash_recovery_area/jadl10g/control02.ctl

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 12:55:01 2014

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

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00554: initialization of internal recovery manager package failed

RMAN-06003: ORACLE error from target database:

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/oracle/oradata/jadl10g/control01.ctl‘

ORA-27041: unable to open file

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

Additional information: 3

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 12:55:16 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> shutdown immediate

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/oracle/oradata/jadl10g/control01.ctl‘

ORA-27041: unable to open file

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

Additional information: 3

SQL> shutdown abort;

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 12:56:08 2014

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

connected to target database (not started)

RMAN> startup nomount

Oracle instance started

Total System Global Area     599785472 bytes

Fixed Size                     2098112 bytes

Variable Size                163580992 bytes

Database Buffers             427819008 bytes

Redo Buffers                   6287360 bytes

RMAN> restore controlfile from ‘/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T123548_b5oyp966_.bkp‘;

Starting restore at 06-NOV-14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

output filename=/u01/oracle/oradata/jadl10g/control01.ctl

output filename=/u01/oracle/flash_recovery_area/jadl10g/control02.ctl

Finished restore at 06-NOV-14

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> exit

Recovery Manager complete.

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 12:59:16 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> alter database backup controlfile to trace as ‘/tmp/s.sql‘ reuse;

Database altered.

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

[[email protected] ~]$ vi /tmp/s.sql

[[email protected] ~]$ vi /tmp/s.sql

[[email protected] ~]$ sed ‘/^$/d‘ /tmp/s.sql >/tmp/s1.sql

[[email protected] ~]$ sed ‘s/^ //g‘ -i /tmp/s1.sql

[[email protected] ~]$ sed ‘s/^ //g‘ -i /tmp/s1.sql

[[email protected] ~]$ sed ‘s/^ //g‘ -i /tmp/s1.sql

[[email protected] ~]$ sed ‘s/^ //g‘ -i /tmp/s1.sql

[[email protected] ~]$ cat /tmp/s1.sql

-- The following commands will create a new control file and use it

-- to open the database.

-- Data used by Recovery Manager will be lost.

-- The contents of online logs will be lost and all backups will

-- be invalidated. Use this only if online logs are damaged.

-- WARNING! The current control file needs to be checked against

-- the datafiles to insure it contains the correct files. The

-- commands printed here may be missing log and/or data files.

-- Another report should be made after the database has been

-- successfully opened.

-- After mounting the created controlfile, the following SQL

-- statement will place the database in the appropriate

-- protection mode:

--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "JADL10G" RESETLOGS  ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1 ‘/u01/oracle/oradata/jadl10g/redo01.log‘  SIZE 50M,

GROUP 2 ‘/u01/oracle/oradata/jadl10g/redo02.log‘  SIZE 50M,

GROUP 3 ‘/u01/oracle/oradata/jadl10g/redo03.log‘  SIZE 50M

-- STANDBY LOGFILE

DATAFILE

‘/u01/oracle/oradata/jadl10g/system01.dbf‘,

‘/u01/oracle/oradata/jadl10g/undotbs01.dbf‘,

‘/u01/oracle/oradata/jadl10g/sysaux01.dbf‘,

‘/u01/oracle/oradata/jadl10g/users01.dbf‘,

‘/u01/oracle/oradata/jadl10g/example01.dbf‘

CHARACTER SET AL32UTF8

;

-- Commands to re-create incarnation table

-- Below log names MUST be changed to existing filenames on

-- disk. Any one log file from each branch can be used to

-- re-create incarnation records.

-- ALTER DATABASE REGISTER LOGFILE ‘/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_1_%u_.arc‘;

-- ALTER DATABASE REGISTER LOGFILE ‘/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_1_%u_.arc‘;

-- Recovery is required if any of the datafiles are restored backups,

-- or if the last shutdown was not normal or immediate.

RECOVER DATABASE USING BACKUP CONTROLFILE

-- Database can now be opened zeroing the online logs.

ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.

-- Online tempfiles have complete space information.

-- Other tempfiles may require adjustment.

ALTER TABLESPACE TEMP ADD TEMPFILE ‘/u01/oracle/oradata/jadl10g/temp01.dbf‘ REUSE;

-- End of tempfile additions.

--

SQL> start /tmp/s1.sql

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Control file created.

ORA-00279: change 424293 generated at 11/06/2014 12:50:02 needed for thread 1

ORA-00289: suggestion :

/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_5_b5ozjrrr

_.arc

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

ORA-00308: cannot open archived log ‘--‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘ALTER‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘--‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘--‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘--‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘ALTER‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘--‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-00308: cannot open archived log ‘--‘

ORA-27037: unable to obtain file status

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

Additional information: 3

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

cancel

Media recovery cancelled.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01113: file 1 needs media recovery if it was restored from backup, or END

BACKUP if it was not

ORA-01110: data file 1: ‘/u01/oracle/oradata/jadl10g/system01.dbf‘

*******此时发现数据文件是不一致的,增加隐藏参数(忽略一致性的验证)打开数据库。

*******不采用重建控制文件脚本,而采用recover的话,会丢数据而且没有办法打开。

SQL> create pfile=‘/tmp/s.ora‘ from spfile;

File created.

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

[[email protected] ~]$ vi /tmp/s.ora

*._allow_resetlogs_corruption=true  ----允许打开数据库是有损坏

SQL> startup mount pfile=‘/tmp/s.ora‘;

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-00603: ORACLE server session terminated by fatal error

此时忽略打开终止符号,重新启动数据库;

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 13:23:42 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

ORA-01113: file 1 needs media recovery if it was restored from backup, or END

BACKUP if it was not

ORA-01110: data file 1: ‘/u01/oracle/oradata/jadl10g/system01.dbf‘

SQL> shutdown abort

ORACLE instance shut down.

SQL> startup mount pfile=‘/tmp/s.ora‘;

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

SQL> recover database until cancel;

ORA-00279: change 424297 generated at 11/06/2014 13:21:46 needed for thread 1

ORA-00289: suggestion :

/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_1_%u_.arc

ORA-00280: change 424297 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-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: ‘/u01/oracle/oradata/jadl10g/system01.dbf‘

ORA-01112: media recovery not started

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-00603: ORACLE server session terminated by fatal error

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 13:36:21 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

ORA-01113: file 1 needs media recovery if it was restored from backup, or END

BACKUP if it was not

ORA-01110: data file 1: ‘/u01/oracle/oradata/jadl10g/system01.dbf‘

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 13:38:58 2014

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

connected to target database: JADL10G (DBID=2011530396, not open)

RMAN> startup force nomount

Oracle instance started

Total System Global Area     599785472 bytes

Fixed Size                     2098112 bytes

Variable Size                163580992 bytes

Database Buffers             427819008 bytes

Redo Buffers                   6287360 bytes

RMAN> restore controlfile from ‘/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T123548_b5oyp966_.bkp‘;

Starting restore at 06-NOV-14

using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

output filename=/u01/oracle/oradata/jadl10g/control01.ctl

output filename=/u01/oracle/flash_recovery_area/jadl10g/control02.ctl

Finished restore at 06-NOV-14

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 06-NOV-14

Starting implicit crosscheck backup at 06-NOV-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 06-NOV-14

Starting implicit crosscheck copy at 06-NOV-14

using channel ORA_DISK_1

Finished implicit crosscheck copy at 06-NOV-14

searching for all files in the recovery area

cataloging files...

cataloging done

List of Cataloged Files

=======================

File Name: /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T123548_b5oyp966_.bkp

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_3_b5ozgwpw_.arc

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_5_b5p1c4ho_.arc

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_1_b5p24r2c_.arc

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_5_b5ozjrrr_.arc

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_4_b5p1c4do_.arc

File Name: /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_6_b5p1c4l4_.arc

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/oracle/oradata/jadl10g/system01.dbf

restoring datafile 00002 to /u01/oracle/oradata/jadl10g/undotbs01.dbf

restoring datafile 00003 to /u01/oracle/oradata/jadl10g/sysaux01.dbf

restoring datafile 00004 to /u01/oracle/oradata/jadl10g/users01.dbf

restoring datafile 00005 to /u01/oracle/oradata/jadl10g/example01.dbf

channel ORA_DISK_1: reading from backup piece /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T123548_b5oyo4xm_.bkp

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T123548_b5oyo4xm_.bkp tag=TAG20141106T123548

channel ORA_DISK_1: restore complete, elapsed time: 00:00:46

Finished restore at 06-NOV-14

RMAN> recover database;

Starting recover at 06-NOV-14

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_3_b5ozgwpw_.arc

archive log thread 1 sequence 4 is already on disk as file /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_4_b5p1c4do_.arc

archive log thread 1 sequence 1 is already on disk as file /u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_1_b5p24r2c_.arc

archive log filename=/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_3_b5ozgwpw_.arc thread=1 sequence=3

archive log filename=/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_4_b5p1c4do_.arc thread=1 sequence=4

archive log filename=/u01/oracle/flash_recovery_area/JADL10G/archivelog/2014_11_06/o1_mf_1_1_b5p24r2c_.arc thread=1 sequence=1

unable to find archive log

archive log thread=1 sequence=2

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 11/06/2014 13:46:47

RMAN-06054: media recovery requesting unknown log: thread 1 seq 2 lowscn 424301

RMAN> recover database until logseq 2; ---注意此处:恢复到日志序列号为2的地方,之后的数据肯定就是丢失啦

Starting recover at 06-NOV-14

using channel ORA_DISK_1

starting media recovery

media recovery complete, elapsed time: 00:00:03

Finished recover at 06-NOV-14

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

database opened

RMAN> exit

Recovery Manager complete.

***完成恢复后查询DB,发现之前建立的表C3丢失了,日志文件丢失肯定会造成数据的丢失,只是多少的问题噢噢!!!***

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 13:47:59 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

SQL> conn scott/tiger

Connected.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID

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

DEPT                           TABLE

EMP                            TABLE

BONUS                          TABLE

SALGRADE                       TABLE

C2                             TABLE

C1                             TABLE

6 rows selected.

SQL> desc c3 ----c3已经丢失了,他可能运气有点背,刚好在那个删除的归档日志里。

ERROR:

ORA-04043: object c3 does not exist

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine

and Real Application Testing options

进入rman重新备份数据库,删除无效备份:

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 13:50:35 2014

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

connected to target database: JADL10G (DBID=2011530396)

RMAN> delete backup;

****删除之前无效的备份

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=139 devtype=DISK

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

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

1       1       1   1   AVAILABLE   DISK        /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T123548_b5oyo4xm_.bkp

2       2       1   1   AVAILABLE   DISK        /u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T123548_b5oyp966_.bkp

Do you really want to delete the above objects (enter YES or NO)? yes

deleted backup piece

backup piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T123548_b5oyo4xm_.bkp recid=1 stamp=862922148

deleted backup piece

backup piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T123548_b5oyp966_.bkp recid=2 stamp=862926343

Deleted 2 objects

RMAN> backup database;

*****重新备份数据库之前的备份无效了;

Starting backup at 06-NOV-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/u01/oracle/oradata/jadl10g/system01.dbf

input datafile fno=00003 name=/u01/oracle/oradata/jadl10g/sysaux01.dbf

input datafile fno=00005 name=/u01/oracle/oradata/jadl10g/example01.dbf

input datafile fno=00002 name=/u01/oracle/oradata/jadl10g/undotbs01.dbf

input datafile fno=00004 name=/u01/oracle/oradata/jadl10g/users01.dbf

channel ORA_DISK_1: starting piece 1 at 06-NOV-14

channel ORA_DISK_1: finished piece 1 at 06-NOV-14

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T135107_b5p32dhf_.bkp tag=TAG20141106T135107 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 06-NOV-14

channel ORA_DISK_1: finished piece 1 at 06-NOV-14

piece handle=/u01/oracle/flash_recovery_area/JADL10G/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T135107_b5p33jjj_.bkp tag=TAG20141106T135107 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backup at 06-NOV-14

时间: 2024-10-10 19:12:14

【控制文件丢失-恢复-1】的相关文章

[网络课摘抄]8.1模拟控制文件丢失后的数据库恢复(完全恢复)

1.环境准备 1.1确认数据库版本 1.2确认数据库归档 1.3备份数据库文件 2模拟控制文件丢失后的数据库恢复(完全恢复). 2.1查看控制文件位置 2.2执行操作后删除控制文件 2.3启动数据库 启动数据库的时候发现数据库发生了报错,提示无法确认控制文件,检查告警文件,我们现在检查一下告警文件里的信息: 2.4重建控制文件 对于日志和数据文件都完整的情况下,如果只是控制文件丢失,那么重建控制文件是最好的一种解决方式,一般重建控制文件能够解决99%的问题,现在我们就重建控制文件. 2.5尝试打

RMAN备份之丢失数据文件及控制文件的恢复

About Recovery with a Backup Control FileIf all copies of the current control file are lost or damaged, then you must restore and mount a backup control file. You must then run the RECOVER command, even if no data files have been restored, and open t

【oracle】摸拟故障 - 数据文件丢失恢复,SCN的作用。

模拟数据文件丢失恢复,redolog.archivelog.controlfile文件未丢失的情况恢复. 1.  创建一个表空间.用户.分配权限.建表. a)   createtablespace HXW_WEN datafile'D:\ORACLE\ORADATA\HXW168\HXW_WEN_D01.DBF' size5M autoextendonnext1M maxsize20M; b)createuser wen identifiedby zerostudy defaulttablesp

控制文件丢失解决方法

控制文件丢失解决方式:1 alter database backup controlfile to trace;2 在trace文件中粘贴出这一段vi /home/oracle/control.sqlCREATE CONTROLFILE REUSE DATABASE "ORA11GR2" NORESETLOGS  NOARCHIVELOG    MAXLOGFILES 16    MAXLOGMEMBERS 3    MAXDATAFILES 100    MAXINSTANCES 8

用备份控制文件的恢复

用备份控制文件的恢复,控制文件中不包含数据文件,但联机日志中有           alter database backup controlfile to 'D:\control.ctl';           create tablespace tp1 datafile 'D:/tp1.dbf' size 10M;           create table t1(id int,name varchar2(10)) tablespace tp1;           insert into

Oracle 学习之RMAN(十二)恢复实战--控制文件丢失

首先我们进行一次全库备份 RMAN> run {   backup database    format '/backup/full_%d_%T_%s'   plus archivelog    format '/backup/arch_%d_%T_%s'   delete all input;  }  Starting backup at 2015/07/09 09:35:03 current log archived using channel ORA_DISK_1 channel ORA_

RMAN 备份恢复 删除表空间后控制文件丢失

先备份一个控制文件 RMAN> backup current controlfile tag='bak_ctlfile' format='/home/oracle/backup/bak_ctl_%U_%T'; drop一个表空间 SQL> drop tablespace xds including contents and datafiles; Tablespace dropped. 删除控制文件 rm /u01/app/oracle/oradata/orcl/control01.ctl rm

控制文件手工恢复

所有的控制文件坏了,有备份进行恢复 (1)备份control fileSQL> alter database backup controlfile to '/orcl_backup/hot/control.bin'; Database altered. 查看 检查点情况SQL> col name for a35SQL> select file#,name ,checkpoint_change# from v$datafile; FILE# NAME CHECKPOINT_CHANGE#-

手机文件丢失恢复技巧大汇总 安卓苹果数据丢失都可恢复

一.手机文件删除了能恢复吗 不小心删除了手机上的文件,还能不能重新恢复呢?如果删除的是备份过的文件,那我们理所当然能通过备份文件来恢复.但是,如果是没有备份的文件呢?其实也是可以恢复的,只要你停止对手机的频繁操作. 二.数据恢复的原理 恢复手机文件的方法有千千万,但是总结起来其实只有两类:一种是通过原来的备份恢复删除的文件,另一种是利用第三方软件恢复没备份的已删除文件. 其实,手机文件刚刚删除的时候,这些文件还没有彻底从手机中移除.手机系统虽然接到删除文件的指令,但只是把这些数据先隐藏起来,只要