oracle 控制文件误删除手动恢复小测试

测试系统 OLinux 5.9 oracle版本 11.2.0.4

备份控制文件

1.备份到trace文件

SQL> alter database backup controlfile to trace;

Database altered.

查看告警日志,确定备份控制文件trace的位置信息

alter database backup controlfile to trace

Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_1452.trc

Completed: alter database backup controlfile to trace

oracle 10g 控制文件备份在udump目录中

2.备份控制文件为binary文件

SQL> alter database backup controlfile to ‘/oracle/control20150608_bk.ctl‘;

Database altered.

切换日志,完成全库备份(临时表空间存放的是临时数据不需要备份,online redolog在归档模式下自动备份,不需要手动备份)

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

实验一:

丢失控制文件如何恢复

手动删除所有控制文件,尝试重启数据库

[[email protected] prod]$ ls

control01.ctl  control02.ctl  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf

[[email protected] prod]$ rm -rf *.ctl

SQL> shutdown abort

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area  534462464 bytes

Fixed Size                  2254952 bytes

Variable Size             209717144 bytes

Database Buffers          314572800 bytes

Redo Buffers                7917568 bytes

ORA-00205: error in identifying control file, check alert log for more info

告警日志错误信息

ALTER DATABASE   MOUNT

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/app/oracle/oradata/prod/control02.ctl‘

ORA-27037: unable to obtain file status

Linux-x86_64 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/prod/control01.ctl‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-205 signalled during: ALTER DATABASE   MOUNT...

Sat Jun 06 09:40:05 2015

Checker run found 2 new persistent data failures

恢复,将备份的binary控制文件恢复至原来控制文件位置

SQL> !

[[email protected] prod]$ cp /oracle/control20150608_bk.ctl ./control01.ctl

[[email protected] prod]$ cp /oracle/control20150608_bk.ctl ./control02.ctl

[[email protected] prod]$ exit

当前数据库为nomount状态,尝试mount

SQL> alter database mount;

Database altered.

尝试打开数据库

SQL> alter database open;

alter database open

*

ERROR at line 1:

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

SQL> alter database open noresetlogs;

alter database open noresetlogs

*

ERROR at line 1:

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

SQL> recover database using backup controlfile;

ORA-00279: change 976301 generated at 06/06/2015 08:48:22 needed for thread 1

ORA-00289: suggestion : /oracle/arch2/1_6_881656848.dbf

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

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

auto

ORA-00279: change 976728 generated at 06/06/2015 09:12:40 needed for thread 1

ORA-00289: suggestion : /oracle/arch2/1_7_881656848.dbf

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

ORA-00278: log file ‘/oracle/arch2/1_6_881656848.dbf‘ no longer needed for this

recovery

ORA-00279: change 976731 generated at 06/06/2015 09:12:41 needed for thread 1

ORA-00289: suggestion : /oracle/arch2/1_8_881656848.dbf

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

ORA-00278: log file ‘/oracle/arch2/1_7_881656848.dbf‘ no longer needed for this

recovery

ORA-00279: change 976734 generated at 06/06/2015 09:12:42 needed for thread 1

ORA-00289: suggestion : /oracle/arch2/1_9_881656848.dbf

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

ORA-00278: log file ‘/oracle/arch2/1_8_881656848.dbf‘ no longer needed for this

recovery

ORA-00308: cannot open archived log ‘/oracle/arch2/1_9_881656848.dbf‘

ORA-27037: unable to obtain file status

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

Additional information: 3

找不到归档日志/oracle/arch2/1_9_881656848.dbf

此归档日志可能为当前日志组日志

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

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

1          1          0   52428800        512          1 YES CURRENT                       0                      0

3          1          0   52428800        512          1 YES UNUSED                      0                      0

2          1          0   52428800        512          1 YES UNUSED                       0                      0

当前日志组为3

SQL> select group#, member from v$logfile;

GROUP# MEMBER

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

3 /u01/app/oracle/oradata/prod/r

edo03.log

2 /u01/app/oracle/oradata/prod/r

edo02.log

1 /u01/app/oracle/oradata/prod/r

edo01.log

重新recover

SQL> recover database using backup controlfile;

ORA-00279: change 976301 generated at 06/06/2015 08:48:22 needed for thread 1

ORA-00289: suggestion : /oracle/arch2/1_6_881656848.dbf

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

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

/u01/app/oracle/oradata/prod/redo01.log

Log applied.

Media recovery complete.

SQL> alter database open resetlogs;

Database altered.

数据库恢复成功

实验二,关库删除控制文件,用trace备份的控制文件进行恢复

在实验一中数据库被resetlogs打开过,需要重新对控制文件进行备份

SQL> alter database backup controlfile to trace;

Database altered.

告警日志信息:

alter database backup controlfile to trace

Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_10568.trc

Completed: alter database backup controlfile to trace

正常关库删除控制文件

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> !

[[email protected] ~]$ cd $ORACLE_BASE/oradata/prod/

[[email protected] prod]$ ls

control01.ctl  control02.ctl  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf

[[email protected] prod]$ rm -rf *.ctl

[[email protected] prod]$ ls

redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf

[[email protected] prod]$

尝试打开数据库

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

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jun 6 14:15:11 2015

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

Connected to an idle instance.

SQL>

SQL>

SQL> startup

ORACLE instance started.

Total System Global Area  534462464 bytes

Fixed Size                  2254952 bytes

Variable Size             209717144 bytes

Database Buffers          314572800 bytes

Redo Buffers                7917568 bytes

ORA-00205: error in identifying control file, check alert log for more info

告警日志报错:

ALTER DATABASE   MOUNT

ORA-00210: cannot open the specified control file

ORA-00202: control file: ‘/u01/app/oracle/oradata/prod/control02.ctl‘

ORA-27037: unable to obtain file status

Linux-x86_64 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/prod/control01.ctl‘

ORA-27037: unable to obtain file status

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

Additional information: 3

ORA-205 signalled during: ALTER DATABASE   MOUNT...

Sat Jun 06 15:31:09 2015

Checker run found 2 new persistent data failures

查看前trace备份的控制文件

more /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_10568.trc

创建控制文件的语句如下

--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "PROD" RESETLOGS  ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1 ‘/u01/app/oracle/oradata/prod/redo01.log‘  SIZE 50M BLOCKSIZE 512,

GROUP 2 ‘/u01/app/oracle/oradata/prod/redo02.log‘  SIZE 50M BLOCKSIZE 512,

GROUP 3 ‘/u01/app/oracle/oradata/prod/redo03.log‘  SIZE 50M BLOCKSIZE 512

-- STANDBY LOGFILE

DATAFILE

‘/u01/app/oracle/oradata/prod/system01.dbf‘,

‘/u01/app/oracle/oradata/prod/sysaux01.dbf‘,

‘/u01/app/oracle/oradata/prod/undotbs01.dbf‘,

‘/u01/app/oracle/oradata/prod/users01.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 ‘/oracle/arch1/1_1_824297850.dbf‘;

-- ALTER DATABASE REGISTER LOGFILE ‘/oracle/arch1/1_1_881678511.dbf‘;

-- 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/app/oracle/oradata/prod/temp01.dbf‘

SIZE 30408704  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

-- End of tempfile additions.

--

开始尝试创建控制文件

[[email protected] prod]$ exit

exit

SQL> CREATE CONTROLFILE REUSE DATABASE "PROD" RESETLOGS  ARCHIVELOG

2      MAXLOGFILES 16

3      MAXLOGMEMBERS 3

4      MAXDATAFILES 100

5      MAXINSTANCES 8

6      MAXLOGHISTORY 292

7  LOGFILE

8    GROUP 1 ‘/u01/app/oracle/oradata/prod/redo01.log‘  SIZE 50M BLOCKSIZE 512,

9    GROUP 2 ‘/u01/app/oracle/oradata/prod/redo02.log‘  SIZE 50M BLOCKSIZE 512,

10    GROUP 3 ‘/u01/app/oracle/oradata/prod/redo03.log‘  SIZE 50M BLOCKSIZE 512

11  -- STANDBY LOGFILE

12  DATAFILE

13    ‘/u01/app/oracle/oradata/prod/system01.dbf‘,

14    ‘/u01/app/oracle/oradata/prod/sysaux01.dbf‘,

15    ‘/u01/app/oracle/oradata/prod/undotbs01.dbf‘,

16    ‘/u01/app/oracle/oradata/prod/users01.dbf‘

17  CHARACTER SET AL32UTF8

18  ;

Control file created.

SQL> RECOVER DATABASE USING BACKUP CONTROLFILE;

ORA-00279: change 977244 generated at 06/06/2015 15:30:21 needed for thread 1

ORA-00289: suggestion : /oracle/arch1/1_6_881678511.dbf

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

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

auto

ORA-00308: cannot open archived log ‘/oracle/arch1/1_6_881678511.dbf‘

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 ‘/oracle/arch1/1_6_881678511.dbf‘

ORA-27037: unable to obtain file status

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

Additional information: 3

找不到归档日志/oracle/arch1/1_6_881678511.dbf

此归档日志可能为当前日志组日志

SQL> select * from v$log;

GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

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

1          1          0   52428800        512          1 YES UNUSED                       0                      0

3          1          0   52428800        512          1 YES CURRENT                      0                      0

2          1          0   52428800        512          1 YES UNUSED                       0                      0

当前日志组为3

SQL> select group#, member from v$logfile;

GROUP# MEMBER

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

3 /u01/app/oracle/oradata/prod/r

edo03.log

2 /u01/app/oracle/oradata/prod/r

edo02.log

1 /u01/app/oracle/oradata/prod/r

edo01.log

重新recover

SQL> recover database using backup controlfile;

ORA-00279: change 977244 generated at 06/06/2015 15:30:21 needed for thread 1

ORA-00289: suggestion : /oracle/arch1/1_6_881678511.dbf

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

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

/u01/app/oracle/oradata/prod/redo03.log

Log applied.

Media recovery complete.

开库

SQL> alter database open resetlogs;

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE

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

READ WRITE

恢复成功

时间: 2024-10-03 13:27:57

oracle 控制文件误删除手动恢复小测试的相关文章

Oracle 控制文件和日志文件

管理控制文件 在Oracle数据库中,控制文件是一个很小(大小一般在10MB范围内)的二进制文件,含有数据库的结构信息,包括数据文件和日志文件的信息.可以将控制文件理解为物理数据库的一个元数据存储库.控制文件在数据库创建时被自动创建,并在数据库发生物理变化时更新.控制文件被不断更新,并且在任何时候都要保证控制文件是可用的.只有Oracle进程才能够安全地更新控制文件的内容,所以,任何时候都不要试图手动编辑控制文件. 由于控制文件在数据库中的重要地位,所以保护控制文件的安全非常重要,为此Oracl

oracle控制文件

转载请注明出处  控制文件(Control File)是Oracle的物理文件之一,它记录了数据库的物理结构(数据文件.日志文件等的名称和位置),数据库转载和打开都需要控制文件, 还记录了日志序列号,检查点和日志历史信息,同步和恢复数据库都需要控制文件. 控制文件包含以下信息: 数据名称 数据文件名称和位置 重做日志名称和位置 表空间名称和位置 当前日志序列号 检查点信息 日志历史信息 RMAN信息 查询控制文件T-SQL: SQL> col name format a30 SQL> sele

Oracle 数据文件误删除的不完全恢复

应用环境: 我的一个表被人不小心误删除了,这时候,我不可以把整个库都恢复回去,那样太麻烦了. 所以现在我就从新到一个新库,只将这一个数据文件拷贝过来恢复. 那我们Oracle在恢复文件的时候是不可以只恢复一部分数据文件的,因为oracle  要保证数据文件块头信息一致,所以如果我们要恢复部分文件的话,就得采取以下这种方法: 可以另起一个库,再把要恢复的数据文件拷贝过来,恢复.(当然不单单是该数据文件,还要包括system表空间,undo表空间) 1)另起一个库很简单,可以搞出参数文件,在参数文件

oracle 控制文件多路复用

网上有很多关于控制文件的操作,我大概看了下.有很多都是炒来炒去转来转去.下面以自己理解和操作为例来对oracle的控制文件进行下介绍. 首先介绍下控制文件 在oralce数据库中,控制文件是一个很小的二进制文件,一般大小在10MB左右在数据库创建时被自动创建,并在数据库变化时更新.控制文件不断被更新,并且在任何时候都要保证控制文件可用.控制文件在oracle中扮演者很重要的角色,没有控制文件或者控制文件损坏数据库必然down掉.控制文件包含有数据库结构信息,数据文件和日志文件信息. 由于控制文件

Oracle控制文件与参数文件管理_超越OCP精通Oracle视频教程培训13

Oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习Oracle Parameter参数文件与Oracle控制文件controlfile的深入解析,如何修改参数文件,Oracle控制文件的作用,针对Resetlogs和NoResetlogs的分析,oracle控制文件的重建/镜像/备份/恢复等日常管理与维护. 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址: http://edu.51cto.com/course

Oracle 控制文件(CONTROLFILE)

--============================= -- Oracle 控制文件(CONTROLFILE) --============================= 一.Oracle 控制文件 为二进制文件,初始化大小由CREATE DATABASE指定,可以使用RMAN备份 记录了当前数据库的结构信息,同时也包含数据文件及日志文件的信息以及相关的状态,归档信息等等 在参数文件中描述其位置,个数等等.通常采用分散放开,多路复用的原则.在mount阶段被读取,open阶段一直被使

oracle 控制文件的重建

目录 oracle 控制文件的重建 NORESETLOGS RESETLOGS oracle 控制文件的重建 不到最后时刻,如三个控制文件都已损坏,又没有控制文件的备份.还是不要重建控制文件,处理不好就会有数据丢失. NORESETLOGS Set #1. NORESETLOGS case -- -- The following commands will create a new control file and use it -- to open the database. -- Data

使用控制文件快照辅助恢复

如果没有设置控制文件自动备份,则在备份的时候首先会有控制文件快照,这样快照的信息不包含备份集的信息. 启用控制文件自动备份之后,在备份完之后会有控制文件快照,以及控制文件和spfile的备份. Rman >show controlfile autobackup; Rman>show snapshot controlfile name; Rman>configure controlfile autobackup on; 测试如下: RMAN> backup database form

服务器异常断电,导致oracle控制文件版本不一致,报错ora-00214解决记录

控制文件介绍: 每一个oracle都至少会生成一个控制文件,一个数据库可以拥有多个控制文件,但是一个控制文件只能属于一个数据库. 控制文件内部除了存放数据库名及其创建日期,数据文件,日志文件等相关信息,在系统运行的过程中还会存放系统更改号,检查点信息及归档的当前状态等信息. 出于安全考虑,数据库会自动创建2到3个控制文件,每个控制文件记录相同的信息,这个可以确保在数据库运行时,某个控制文件损坏,oracle会自动使用另一个控制文件,当所有控制文件损坏时,数据库将无法工作. 注:通过 v$cont