Oracle案例:损坏控制文件的恢复方法
使用Oracle BMR(块介质恢复)功能快速恢复数据
使用BMR功能快速修复数据坏块Oracle提供了许多方法检测和修补数据库中的数据坏块,而BMR就是其中之一,其它方法还包括Analyze语句、dbv命令以及DBMS_REPAIR等。
DBMS_REPAIR包仅仅对transaction层和data层的坏块(即逻辑损坏的块)起作用,对物理上损坏的块,在它被读到缓冲区中时就已被标识出来了,而DBMS_REPAIR会忽略所有被标识为坏了的块。
要快速修复物理损坏的数据块,可以通过BMR功能来完成。
块介质恢复的最大好处在于可以降低平均恢复时间(MTTR) ,因为介质恢复的最小可恢复单位从数据文件缩小到块。
如果已知数据库中只有少量的块需要介质恢复,则最有效的方式是有选择地进行还原,只恢复需要恢复的块。
而且该技术提高了介质恢复期间的数据可用性,因为在数据恢复期间,数据文件可以保持联机状态,只有正在恢复的数据块是不可访问的。
使用BMR之前,需要对保护的数据进行备份。
在执行BMR时,只需要简单地执行blockrecover 命令就可以了,例如编号为4的数据文件的数据块385发生了损坏,修复时可以如下:RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 385;下面通过一个实例来讨论BMR的使用。
一、建立测试环境首先建立一个测试用的表T1,T1的结构如下:SQL> desc t1Name Null? Type--------------------------------------------------- -------- ---------------------COL1 NUMBERCOL2 CHAR(1000)将COL2的数据类型设置为CHAR(1000)只是为了让每个行记录占用的空间更多,这样我们可以使用较少的记录填充多个数据块。
为该测试表填入一部分测试数据:SQL>insert into t1 select rownum,rownum from dual connect by rownum<=20;上述语句使用了层次查询语句。
几种oracle数据库恢复的练习示例
7:提示文件不存在。
8ห้องสมุดไป่ตู้还原热备的文件,令该文件脱机。
Alter database datafile ‘88888888’ offline;
9:打开数据库。
10:恢复该文件。
Recover databfile ‘88888888’;
11:alter database datafile online.
而联机日志则可以保证数据库恢复到发生事故时的状态,算是完全恢复。
如果没归档的联机日志丢失(状态为ACTIVE或者CURRENT),则只能使用归档日志恢复到最后一个归档日志的地方,是不完全恢复。
End;
/
5:切换几次日志,使所有日志都已经归档。
Alter system switch log file;
6:正常关闭数据库。Shutdown immediate;
7:恢复:
把当前数据库所有文件移动到一个临时文件夹里,模拟数据库损坏。
8:COPY最初复制的数据库的所有文件,但控制文件和日志文件要使用目前数据库的。
9:启动数据库 startup
mount 后会提示SYSTEM表空间需要恢复。并给出恢复使用的归档日志文档。
确定归档日志位置正确后,输入auto.
ORACLE将一个一个的应用归档文档。直至提示完全恢复成功。
10:打开数据库 alter database open;
11:查看user1用户及t1表中是否有刚才插入的10000条记录。
ORA-00279: ?? 84851370 (? 09/24/2003 11:16:01 ??) ???? 1 ????
ORA-00289: ??: D:\ORACLE\ORADATA\SAMPLE\ARCHIVE\TESTT001S01324.ARC
一次曲折的rman控制文件恢复
/dev/rctrlfile2
/dev/rctrlfile3
用dd把控制文件都搞坏,如下:
# dd if=/dev/zero of=/dev/rctrlfile1 bs=32k
---
---
没有归档当前的redo log。
SQL> shutdown abort;
214 Full 5.30M DISK 00:00:05 14-MAR-12
BP Key: 216 Status: AVAILABLE Compressed: NO Tag: TAG20120314T051102
Piece Name: /oracle/app/oracle/product/10.2.0/db_1/dbs/05n5que6_1_1
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
提示需要用BACKUP CONTROLFILE方式recover database
ORA-01110: data file 1: '/dev/rsystem'
数据不一致,提示需要recover databdatabase until cancel;
ORA-00283: recovery session canceled due to errors
ORACLE instance shut down.
尝试正常启动数据库
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
损坏数据文件的恢复方法
损坏数据文件的恢复方法一:非归档模式下丢失或者损坏数据文件A:OS备份恢复方案在非归档模式下损坏或者丢失数据文件,如果有相应的备份,在一定程度上是可以恢复的,但是如果oracle过多的读写操作记录信息而导致redo重写的时候,恢复就会停滞,非归档下系统能自动恢复的仅仅限于redo中存在的记录。
可以成功恢复案例:SQL> startupORACLE instance started.Total System Global Area 235999352 bytesFixed Size 450680 bytesVariable Size 201326592 bytesDatabase Buffers 33554432 bytesRedo Buffers 667648 bytesDatabase mounted.Database openedSQL> create table test(a int);Table created.SQL> insert into test values(1);1 row created.SQL> /1 row created.SQL> /1 row created.SQL> /1 row created.SQL> commit;Commit complete.SQL> exit;[oracle@www oradata]$ cd cicro/[oracle@www cicro]$ lscontrol01.ctl cwmlite01.dbf indx01.dbf redo02.log temp01.dbfusers01.dbf control02.ctl drsys01.dbf odm01.dbf redo03.logtools01.dbf xdb01.dbf control03.ctl example01.dbf redo01.log system01.dbf undotbs01.dbf[oracle@www cicro]$ pwd/opt/oracle/oradata/cicro[oracle@www cicro]$ sqlplus "/as sysdba"SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL>exit;[oracle@www cicro]$ cp ./*.dbf ../[oracle@www cicro]$ sqlplus "/as sysdba"SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jul 25 19:44:31 2006 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to:Oracle9i Release 9.2.0.1.0 - ProductionJServer Release 9.2.0.1.0 – ProductionConnected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 235999352 bytesFixed Size 450680 bytesVariable Size 201326592 bytesDatabase Buffers 33554432 bytesRedo Buffers 667648 bytesDatabase mounted.Database opened.SQL> insert into test values(3333);1 row created.SQL> /1 row created.SQL> /1 row created.SQL> /1 row created.SQL> commit;Commit complete.SQL> select * from test;A----------1113333333333338 rows selected.SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL>exit;[oracle@www cicro]$ rm –rf ./*.dbf[oracle@www cicro]$ sqlplus "/as sysdba"Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 235999352 bytesFixed Size 450680 bytes技术社区Variable Size 201326592 bytesDatabase Buffers 33554432 bytesRedo Buffers 667648 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 1 - see DBWR trace fileORA-01110: data file 1: '/opt/oracle/oradata/cicro/system01.dbf'SQL> quit[oracle@www cicro]$ mv ../*.dbf .[oracle@www cicro]$ lscontrol01.ctl cwmlite01.dbf indx01.dbf redo02.log temp01.dbf users01.dbf control02.ctl drsys01.dbf odm01.dbf redo03.log tools01.dbf xdb01.dbf control03.ctl example01.dbf redo01.log system01.dbf undotbs01.dbf[oracle@www cicro]$ sqlplus "/as sysdba"SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jul 25 17:56:06 2006Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to:Oracle9i Release 9.2.0.1.0 - ProductionJServer Release 9.2.0.1.0 - ProductionSQL> recover database;Media recovery complete.SQL> alter database open;Database altered.SQL> select * from test;A----------111333333333333333333338 rows selected.至此,恢复成功!不完全恢复的案例基本操作与上面相同,还是首先建立一张表,然后插入数据:1:建表,写入数据,然后关闭数据库SQL> create table gaojf1 as select * from all_objects;T able created.SQL> insert into gaojf1 select * from gaojf1;29614 rows created.SQL> /59228 rows created. (即为现在此表数据有118456列)SQL>commit;SQL>shutdown immediate2:备份所有的数据文件3:启动数据库继续插入数据[oracle@www cicro]$ sqlplus "/as sysdba"SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jul 25 18:07:19 2006 Copyright (c) 1982, 2002, Oracle Corporation.Connected to:Oracle9i Release 9.2.0.1.0 - ProductionJServer Release 9.2.0.1.0 - ProductionSQL> insert into gaojf1 select * from gaojf1;118456 rows created.SQL> /236912 rows created.SQL> /473824 rows created.SQL> /947648 rows created.SQL> commit;Commit complete.SQL> select count(*) from gaojf1;COUNT(*)----------1895296SQL> /1895296 rows created.SQL> /技术社区3790592 rows created.(如果能够完全恢复,此表应该有3790592*2列)SQL> commit;Commit complete.期间,查看日志信息如下:Wed Jul 26 13:02:54 2006Thread 1 opened at log sequence 1Current log# 3 seq# 1 mem# 0: /opt/oracle/oradata/cicro/redo03.log Successful open of redo thread 1.Wed Jul 26 13:03:56 2006Thread 1 advanced to log sequence 2Current log# 1 seq# 2 mem# 0: /opt/oracle/oradata/cicro/redo01.logWed Jul 26 13:05:41 2006Thread 1 advanced to log sequence 3Current log# 2 seq# 3 mem# 0: /opt/oracle/oradata/cicro/redo02.logWed Jul 26 13:09:04 2006Thread 1 advanced to log sequence 4Current log# 3 seq# 4 mem# 0: /opt/oracle/oradata/cicro/redo03.logWed Jul 26 13:09:29 2006Thread 1 advanced to log sequence 5Current log# 1 seq# 5 mem# 0: /opt/oracle/oradata/cicro/redo01.log 可以看到,redo文件在不断的循环重写,当一个redo写完后继续写第二个redo,然后是第三个,当第三个写完后继续回来重写第一个,依此类推。
Oracle数据库文件损坏修复(断电情况下)
现场情况:1、数据库没有作归档,2、数据都存放在system表空间3、没有备份状况:操作系统由于磁盘原因出现宕机,用户强行按电源关闭系统,数据库无法启动。
处理:Sql代码1.SQL> recover database;2.ORA-00283: recovery session canceled due to errors3.ORA-12801: error signaled in parallel query server P0024.ORA-10562: Error occurred while applying redo to data block (file# 1, block#4568)5.ORA-10564: tablespace SYSTEM6.ORA-01110: data file 1: '/opt/oracle/oradata/orcl/system01.dbf'7.ORA-10561: block type 'TRANSACTION MANAGED INDEX BLOCK', data object# 5768.ORA-00600: internal error code, arguments: [6101]9.检查日志信息如下:Oracle代码1.Mon Nov 1915:38:5020072.ALTER DATABASE RECOVER database3.Mon Nov 1915:38:5020074.Media Recovery Start5. parallel recovery started with 3 processes6.Mon Nov 1915:38:5020077.Recovery of Online Redo Log: Thread 1 Group 3 Seq 16 Reading mem 08. Mem# 0 errs 0: /opt/oracle/oradata/orcl/redo03.log9.Mon Nov 1915:38:50200710.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p002_7917.trc:11.ORA-00600: internal error code, arguments: [6101], [0], [17], [0], [], [], [], []12.Mon Nov 1915:38:50200713.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p000_7913.trc:14.ORA-00600: internal error code, arguments: [3020], [2], [882],[8389490], [], [], [], []15.ORA-10567: Redo is inconsistent with data block (file# 2, block# 882)16.ORA-10564: tablespace UNDOTBS117.ORA-01110: data file 2: '/opt/oracle/oradata/orcl/undotbs01.dbf'18.ORA-10560: block type 'KTU UNDO BLOCK'19.Mon Nov 1915:38:51200720.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p000_7913.trc:21.ORA-00600: internal error code, arguments: [3020], [2], [882],[8389490], [], [], [], []22.ORA-10567: Redo is inconsistent with data block (file# 2, block# 882)23.ORA-10564: tablespace UNDOTBS124.ORA-01110: data file 2: '/opt/oracle/oradata/orcl/undotbs01.dbf'25.ORA-10560: block type 'KTU UNDO BLOCK'26.Mon Nov 1915:38:51200727.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p002_7917.trc:28.ORA-10562: Error occurred while applying redo to data block (file# 1, block# 4568)29.ORA-10564: tablespace SYSTEM30.ORA-01110: data file 1: '/opt/oracle/oradata/orcl/system01.dbf'31.ORA-10561: block type 'TRANSACTION MANAGED INDEX BLOCK', data object# 57632.ORA-00600: internal error code, arguments: [6101], [0], [17], [0], [], [], [], []33.Mon Nov 1915:38:54200734.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p001_7915.trc:35.ORA-00600: internal error code, arguments: [kddummy_blkchk], [1], [1658], [6101], [], [], [], []36.Mon Nov 1915:38:54200737.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p001_7915.trc:38.ORA-10562: Error occurred while applying redo to data block (file# 1, block# 1658)39.ORA-10564: tablespace SYSTEM40.ORA-01110: data file 1: '/opt/oracle/oradata/orcl/system01.dbf'41.ORA-10561: block type 'TRANSACTION MANAGED DATA BLOCK', data object# 23742.ORA-00607: Internal error occurred while making a change to a data block43.ORA-00600: internal error code, arguments: [kddummy_blkchk], [1], [1658], [6101], [], [], [], []44.Mon Nov 1915:38:54200745.Media Recovery failed with error 1280146.ORA-283 signalled during: ALTER DATABASE RECOVER database ...从上面信息中抓取了一个信息:Oracle代码1.ORA-10562: Error occurred while applying redo to data block (file# 1, block# 1658)针对这个错误解决如下:Oracle代码1.ORA-10562: Error occurred while applying redo to data block (file# string, block# string)2.Cause: See other errors on error stack.3.Action: Investigate why the error occurred and how important isthe data block. Media and standby database recovery usually ca n continue if user allows recovery to corrupt this data block。
oracle 故障恢复案例
oracle 故障恢复案例Oracle故障恢复案例1. 数据库实例崩溃恢复某公司的Oracle数据库实例突然崩溃,导致所有业务无法正常运行。
经过专业技术人员的分析,发现是由于服务器硬件故障导致的。
为了恢复数据库,技术人员采取了备份恢复的方式,通过使用备份数据文件和重做日志文件,成功将数据库实例恢复到崩溃前的状态。
2. 数据文件损坏的恢复某公司的数据库中的一个数据文件损坏,导致部分数据无法正常访问。
为了解决这个问题,技术人员首先通过文件系统级别的工具检查数据文件的完整性,并确定了损坏的范围。
然后,他们使用备份数据文件和重做日志文件进行恢复,成功修复了损坏的数据文件,并使数据库恢复正常。
3. 表空间故障的恢复某公司的数据库中的一个表空间突然出现故障,导致表空间中的所有表无法访问。
为了解决这个问题,技术人员首先通过Oracle的故障自诊断工具诊断表空间故障的原因,并确定了故障的范围。
然后,他们使用备份的表空间文件和重做日志文件进行恢复,成功修复了故障的表空间,并使其正常运行。
4. 数据库日志文件损坏的恢复某公司的数据库日志文件突然损坏,导致数据库无法正常启动。
为了恢复数据库,技术人员首先检查了日志文件的完整性,并确定了损坏的范围。
然后,他们使用备份的日志文件进行恢复,成功修复了损坏的日志文件,并使数据库恢复正常。
5. 控制文件丢失的恢复某公司的数据库控制文件丢失,导致数据库无法正常启动。
为了解决这个问题,技术人员首先通过文件系统级别的工具检查控制文件的完整性,并确定了丢失的范围。
然后,他们使用备份的控制文件进行恢复,成功恢复了丢失的控制文件,并使数据库正常启动。
6. 数据库块损坏的恢复某公司的数据库中的一个数据块突然损坏,导致数据库无法正常读取该块的数据。
为了解决这个问题,技术人员首先通过Oracle的故障自诊断工具诊断数据块故障的原因,并确定了损坏的范围。
然后,他们使用备份的数据块进行恢复,成功修复了损坏的数据块,并使数据库恢复正常。
控制文件丢失的恢复
一般情况下数据库的DBA都会对controlfile 进行多路复用,这样可以保证控制文件的安全性,对于数据库而言只要数据文件和redolog、archivelog不丢,数据都是可以恢复的,只是controlfile丢失,会比较麻烦。
环境:control01.ctl、control02.ctl、control03.ctl1、3个controlfile中的一个或者两个丢失,关闭数据库后,从没有没丢失的那个controlfile进行拷贝。
2、3个控制文件全丢失,可以进行重构控制文件,一般情况下我们会对控制文件进行二进制文件备份(alter database backup controlfile to trace as '*****' 备份成二进制文件)(alter database backup controlfile to '***' 是直接备份控制文件 )以下是备份出来的二进制文件的内容:有两种情况,1、完全恢复的时候用(红色)2、不完全恢复的时候用(紫红)-- The following are current System-scope REDO Log Archival related-- parameters and can be included in the database initialization file.-- LOG_ARCHIVE_DEST=''-- LOG_ARCHIVE_DUPLEX_DEST=''-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf-- DB_UNIQUE_NAME="orcl"-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'-- LOG_ARCHIVE_MAX_PROCESSES=2-- STANDBY_FILE_MANAGEMENT=MANUAL-- STANDBY_ARCHIVE_DEST=?/dbs/arch-- FAL_CLIENT=''-- FAL_SERVER=''-- LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/oradata/orcl/arch'-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOEXPEDITE NOVERIFY SYNC'-- LOG_ARCHIVE_DEST_1='REGISTER NOALTERNATE NODEPENDENCY'-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'-- LOG_ARCHIVE_DEST_STATE_1=ENABLE-- Below are two sets of SQL statements, each of which creates a new-- control file and uses it to open the database. The first set opens-- the database with the NORESETLOGS option and should be used only if-- the current versions of all online logs are available. The second -- set opens the database with the RESETLOGS option and should be used -- if online logs are unavailable.-- The appropriate set of statements can be copied from the trace into -- a script file, edited as necessary, and executed when there is a-- need to re-create the control file.-- Set #1. NORESETLOGS case-- The following commands will create a new control file and use it-- to open the database.-- Data used by Recovery Manager will be lost.-- Additional logs may be required for media recovery of offline-- Use this only if the current versions of all online logs are-- available.-- 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 NOMOUNTCREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/u01/app/oracle/oradata/orcl/redo01.log' SIZE 50M,GROUP 2 '/u01/app/oracle/oradata/orcl/redo02.log' SIZE 50M,GROUP 3 '/u01/app/oracle/oradata/orcl/redo03.log' SIZE 50M-- STANDBY LOGFILEDATAFILE'/u01/app/oracle/oradata/orcl/system01.dbf','/u01/app/oracle/oradata/orcl/undotbs01.dbf','/u01/app/oracle/oradata/orcl/sysaux01.dbf','/u01/app/oracle/oradata/orcl/users01.dbf','/u01/app/oracle/oradata/orcl/example01.dbf','/u01/app/oracle/oradata/orcl/app1_01.dbf','/u01/app/oracle/oradata/orcl/app02_01.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.-- Recovery is required if any of the datafiles are restored backups,-- or if the last shutdown was not normal or immediate.RECOVER DATABASE-- All logs need archiving and a log switch is needed.ALTER SYSTEM ARCHIVE LOG ALL;-- Database can now be opened normally.ALTER DATABASE OPEN;-- 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/orcl/temp01.dbf'-- End of tempfile additions.-- Set #2. RESETLOGS case-- 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.-- 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 PERFORMANCESTARTUP NOMOUNTCREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/u01/app/oracle/oradata/orcl/redo01.log' SIZE 50M,GROUP 2 '/u01/app/oracle/oradata/orcl/redo02.log' SIZE 50M,GROUP 3 '/u01/app/oracle/oradata/orcl/redo03.log' SIZE 50M-- STANDBY LOGFILEDATAFILE'/u01/app/oracle/oradata/orcl/system01.dbf','/u01/app/oracle/oradata/orcl/undotbs01.dbf','/u01/app/oracle/oradata/orcl/sysaux01.dbf','/u01/app/oracle/oradata/orcl/users01.dbf','/u01/app/oracle/oradata/orcl/example01.dbf','/u01/app/oracle/oradata/orcl/app1_01.dbf','/u01/app/oracle/oradata/orcl/app02_01.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.-- 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/orcl/temp01.dbf'-- End of tempfile additions.执行以上脚本对controlfile进行重构时,是在数据库未启动的时候进行。
Oracle数据库基于用户管理的控制文件的备份与恢复
时间:2010.1.6 来源:网络编辑:联动北方技术论坛在Oracle数据库中,控制文件是非常重要的。
它用于记录和维护数据库。
当恢复数据库时,服务器进程和后台进程需要从控制文件中读取各种备份相关的信息。
如果控制文件损坏,则会导致这些备份信息的丢失。
尽管使用多元化控制文件可以防止控制文件损坏,但因为控制文件的重要性,应该定期备份控制文件。
当数据库配置发生改变时,一定要备份控制文件。
涉及到数据库配置改变的命令:1.alter database [add|drop] logfile2.3.alter database [add|drop] logfile member4.5.alter database [add|drop] logfile group6.7.alter database [noarchivelog|archivelog]8.9.alter database rename file10.11.create tablespace12.13.alter tablespace [add|rename] datafile14.15.alter tablespace [read write|read only]16.17.drop tablespace控制文件的备份,三种方式1)使用OS命令进行拷贝1)open状态下,使用alter database命令生成控制文件副本2)open状态下,使用alter database backup controlfile to trace命令将控制文件备份到跟踪文件控制文件的恢复,两种方式1)mount状态下,使用RECOVER DATABASE USING BACKUP CONTROLFILE2)mount状态下,生成跟踪文件并进行恢复2--2示例:1.[oracle@localhost ~]$ rlsqlplus / as sysdba2.3.SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 1 21:40:03 20114.5.Copyright (c) 1982, 2005, Oracle. All rights reserved.6.7.Connected to an idle instance.8.9.SQL> startup10.11.ORACLE instance started.12.13.Total System Global Area 528482304 bytes14.15.Fixed Size 1220360 bytes16.17.Variable Size 176161016 bytes18.19.Database Buffers 343932928 bytes20.21.Redo Buffers 7168000 bytes22.23.Database mounted.24.25.Database opened.--open状态下生成控制文件副本1.SQL> alter database backup controlfile to2.3. 2 '/oracle/10g/oracle/bakup/database/oralife.ctl';4.5.alter database backup controlfile to6.7.*8.9.ERROR at line 1:10.11.ORA-01580: error creating control backup file12.13./oracle/10g/oracle/bakup/database/oralife.ctl14.15.ORA-27038: created file already exists16.17.Additional information: 118.19.SQL> alter database backup controlfile to20.21. 2 '/oracle/10g/oracle/bakup/database/oralife.ctl' reuse; --reuse用于覆盖原有控制文件副本23.Database altered.--手动删除所有控制文件模拟文件丢失1.SQL> ho rm /oracle/10g/oracle/product/10.2.0/oradata/oralife/*.ctl;--使用evan登录,并添加数据1.SQL> conn evan/evan2.3.Connected.4.5.SQL> select * from t_evan;6.7.TEXT8.9.--------------------------------------------------------------------------------10.11.oracle12.13.java14.15.spring16.17.hibernate18.19.hibernate20.21.SQL> insert into t_evan values('added');22.23. 1 row created.24.25.SQL> commit;26.mit complete.28.29.SQL> conn / as sysdba30.31.Connected.32.33.SQL> shutdown immediate34.35.ORA-00210: cannot open the specified control file36.37.ORA-00202: control file: '/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl'39.ORA-27041: unable to open file40.41.Linux Error: 2: No such file or directory42.43.Additional information: 344.45.SQL> shutdown abort46.47.ORACLE instance shut down.--alter_oralife.log出现这样的信息:1.Mon Aug 1 23:13:51 20112.3.ORA-00202: control file: '/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl'4.5.ORA-27037: unable to obtain file status6.7.Linux Error: 2: No such file or directory8.9.Additional information: 3--拷贝控制文件到目标路径1.SQL>ho cp /oracle/10g/oracle/bakup/database/oralife.ctl /oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl2.3.SQL> alter system set control_files='/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl'scope = spfile; --修改control_files参数,指定可用的控制文件4.5.System altered.6.7.SQL> startup force mount8.9.ORACLE instance started.10.11.Total System Global Area 528482304 bytes12.13.Fixed Size 1220360 bytes14.15.Variable Size 138412280 bytes16.17.Database Buffers 381681664 bytes18.19.Redo Buffers 7168000 bytes20.21.Database mounted.--生成trace文件1.SQL> alter database backup controlfile to trace noresetlogs;2.3.Database altered.4.5.SELECT c.VALUE || '/' || d.instance_name || '_ora_' || a.spid || '.trc' TRACE6.7.FROM v$process a, v$session b, v$parameter c, v$instance d8.9.WHERE a.addr = b.paddr10.11.AND b.audsid = USERENV ('sessionid')12.13.AND = 'user_dump_dest';14.15.TRACE16.17.--------------------------------------------------------------------------------18.19./oracle/10g/oracle/product/10.2.0/db_1/admin/oralife/udump/oralife_ora_4558.trc20.21.SQL> shutdown immediate22.23.ORA-01109: database not open24.25.Database dismounted.26.27.ORACLE instance shut down.--打开trace文件,去掉注释,在shutdown状态下执行脚本,创建控制文件--用evan登录验证数据1.SQL> conn evan/evan2.3.Connected.4.5.SQL> select * from t_evan;6.7.TEXT8.9.--------------------------------------------------------------------------------10.11.oracle12.13.java14.15.spring16.17.hibernate18.19.hibernate20.21.added22.23. 6 rows selected.可见数据没有丢失。
损坏控制文件的恢复方法
一般情况下是利用控制文件的副本,我们创建数据库的时候不是一般都建立3个控制文件吗,这是用于进行冗余保护的,如果只有一个控制文件是好的,那么我们只需要将已损坏的控制文件删除,然后将好的这个控制文件复制到已损坏的控制文件的目录下,重命名成已损坏的控制文件即可(注意一下复制的位置,如果目标文件夹所在的磁盘已经损坏的情况下,我们就得把控制文件复制到好的磁盘上,并且还要修改control_files参数重新定位控制文件的位置)。
还有一种情况就是所有控制文件都损坏了,那么就得利用控制文件的备份进行恢复。
所以,我们在数据库创建好后第一件事就是对控制文件进行备份,在数据库物理结构变化之后也得备份控制文件。
使用命令ALTER DATABASE BACKUP CONTROLFILE TO TRACE,会有一个转储文件会放在user_dump_dest参数定义的目录中,里面有重建控制文件的脚步,按照转储文件里面写的做就可以了。
一、损坏单个控制文件损坏单个控制文件是比较容易恢复的,因为一般的数据库系统,控制文件都不是一个,而且所有的控制文件都互为镜相,只要拷贝一个好的控制文件替换坏的控制文件就可以了。
1、控制文件损坏,最典型的就是启动数据库出错,不能mount数据库SQL>startupORA-00205: error in identifying controlfile, check alert log for more info查看报警日志文件,有如下信息alter database mountMon May 26 11:59:52 2003ORA-00202: controlfile: 'D:Oracleoradatachencontrol01.ctl'ORA-27041: unable to open fileOSD-04002: unable to open fileO/S-Error: (OS 2) 系统找不到指定的文件。
控制文件损坏的恢复
一、损坏单个控制文件损坏单个控制文件是比较容易恢复的,因为一般的数据库系统,控制文件都不是一个,而且所有的控制文件都互为镜相,只要拷贝一个好的控制文件替换坏的控制文件就可以了。
1、控制文件损坏,最典型的就是启动数据库出错,不能mount数据库SQL>startupORA-00205: error in identifying controlfile, check alert logfor more info查看报警日志文件,有如下信息alter database mountMon May 26 11:59:52 2003ORA-00202: controlfile: 'D:Oracleoradatachencontrol01.ctl' ORA-27041: unable to open fileOSD-04002: unable to open fileO/S-Error: (OS 2) 系统找不到指定的文件。
2、停止数据库SQL>shutdown immediate3、拷贝一个好的控制文件替换坏的控制文件或修改init.ora中的控制文件参数,取消这个坏的控制文件。
4、重新启动数据SQL>startup说明:1、损失单个控制文件是比较简单的,因为数据库中所有的控制文件都是镜相的,只需要简单的拷贝一个好的就可以了2、建议镜相控制文件在不同的磁盘上3、建议多做控制文件的备份,长期保留一份由alter databasebackup control file to trace产生的控制文件的文本备份二、损坏全部控制文件损坏多个控制文件,或者人为的删除了所有的控制文件,通过控制文件的复制已经不能解决问题,这个时候需要重新建立控制文件。
同时注意,alter database backup control file to trace可以产生一个控制文件的文本备份。
以下是详细重新创建控制文件的步骤1、关闭数据库SQL>shutdown immediate;2、删除所有控制文件,模拟控制文件的丢失3、启动数据库,出现错误,并不能启动到mount下SQL>startupORA-00205: error in identifying controlfile, check alert logfor more info查看报警日志文件,有如下信息alter database mountMon May 26 11:53:15 2003ORA-00202: controlfile: 'D:Oracleoradatachencontrol01.ctl' ORA-27041: unable to open fileOSD-04002: unable to open fileO/S-Error: (OS 2) 系统找不到指定的文件。
Oracle数据库恢复实例
Oracle 数据库恢复实例一理解什么是数据库恢复当我们使用一个数据库时,总希望数据库的内容是可靠的、正确的,但由于计算机系统的故障(硬件故障、软件故障、网络故障、进程故障和系统故障)影响数据库系统的操作,影响数据库中数据的正确性,甚至破坏数据库,使数据库中全部或部分数据丢失。
因此当发生上述故障后,希望能重构这个完整的数据库,该处理称为数据库恢复。
恢复过程大致可以分为复原(Restore)与恢复(Recover)过程。
数据库恢复可以分为以下两类:1.1实例故障的一致性恢复当实例意外地(如掉电、后台进程故障等)或预料地(发出SHUTDOUM ABORT语句)中止时出现实例故障,此时需要实例恢复。
实例恢复将数据库恢复到故障之前的事务一致状态。
如果在在线后备发现实例故障,则需介质恢复。
在其它情况Oracle在下次数据库起动时(对新实例装配和打开),自动地执行实例恢复。
如果需要,从装配状态变为打开状态,自动地激发实例恢复,由下列处理:(1)为了解恢复数据文件中没有记录的数据,进行向前滚。
该数据记录在在线日志,包括对回滚段的内容恢复。
(2)回滚未提交的事务,按步1重新生成回滚段所指定的操作。
(3)释放在故障时正在处理事务所持有的资源。
(4)解决在故障时正经历一阶段提交的任何悬而未决的分布事务。
1.2介质故障或文件错误的不一致恢复介质故障是当一个文件、一个文件的部分或磁盘不能读或不能写时出现的故障。
文件错误一般指意外的错误导致文件被删除或意外事故导致文件的不一致。
这种状态下的数据库都是不一致的,需要DBA手工来进行数据库的恢复,这种恢复有两种形式,决定于数据库运行的归档方式和备份方式。
(1)完全介质恢复可恢复全部丢失的修改。
一般情况下需要有数据库的备份且数据库运行在归档状态下并且有可用归档日志时才可能。
对于不同类型的错误,有不同类型的完全恢复可使用,其决定于毁坏文件和数据库的可用性。
(2)不完全介质恢复是在完全介质恢复不可能或不要求时进行的介质恢复。
controlfile丢失,oracle进行恢复
DATA FILE #8:
(name #11) E:\USER1.DBF
creation size=0 block size=8192 status=0xe head=11 tail=11 dup=1
tablespace 7, index=8 krfil=8 prev_file=0
5 MAXINSTANCES 16
6 MAXLOGHISTORY 1815
7 LOGFILE
8 GROUP 1 'E:\ORACLE\ORADATA\TEST\REDO03.LOG' SIZE 1M,
9 GROUP 2 'E:\ORACLE\ORADATA\TEST\REDO02.LOG' SIZE 1M,
如果正常shutdown后,stop scn会等于scn
DATA FILE #8:
(name #11) E:\USER1.DBF
creation size=0 block size=8192 status=0xe headspace 7, index=8 krfil=8 prev_file=0
这时controlfile 里也是一样
DATA FILE #8:
(name #4) E:\USER1.DBF
creation size=0 block size=8192 status=0x12 head=4 tail=4 dup=1
tablespace 7, index=8 krfil=8 prev_file=0
18 'E:\ORACLE\ORADATA\TEST\DR01.DBF',
19 'E:\USER1.DBF'
数据库REDOLOG和CONTROLFILE同时损坏的应对措施
数据库REDOLOG和CONTROLFILE同时损坏的应对措施根据生产环境中一次实际的故障进行重现,并整理了套处理流程。
模拟的是当ORACLE数据库REDO_LOG和CONTROL_FILE同时丢失的场景,以及后续一系列的应对措施。
其中有些细微的地方可能我的理解不是很透彻,但大体流程无碍且经过实际的多次的测试。
1、因为重做日志文件和控制文件丢失,那么只能对数据库进行不完全恢复了。
既然是恢复,肯定得存在历史的备份数据,一份旧的控制文件备份和归档日志备份:RMAN> backup current controlfile;启动 backup 于 05-10月-13使用通道 ORA_DISK_1通道 ORA_DISK_1: 正在启动全部数据文件备份集通道 ORA_DISK_1: 正在指定备份集内的数据文件备份集内包括当前控制文件通道 ORA_DISK_1: 正在启动段 1 于 05-10月-13通道 ORA_DISK_1: 已完成段 1 于 05-10月-13段句柄=G:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\SHADOW\ BACKUPSET\2013_10_05\O1_MF_NCNNF_TAG20131005T185036 _94ZVR900_.BKP 标记=TAG20131005T185036通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:04完成 backup 于 05-10月-13RMAN> backup archivelog all;启动 backup 于 05-10月-13当前日志已存档使用通道 ORA_DISK_1通道 ORA_DISK_1: 正在启动归档日志备份集通道 ORA_DISK_1: 正在指定备份集内的归档日志输入归档日志线程=1 序列=3 RECID=17 STAMP=828039216 输入归档日志线程=1 序列=4 RECID=19 STAMP=828039228 输入归档日志线程=1 序列=5 RECID=21 STAMP=828039232 输入归档日志线程=1 序列=6 RECID=23 STAMP=828039279 通道 ORA_DISK_1: 正在启动段 1 于 05-10月-13通道 ORA_DISK_1: 已完成段 1 于 05-10月-13段句柄=G:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\SHADOW\ BACKUPSET\2013_10_05\O1_MF_ANNNN_TAG20131005T18544 0_94ZVZTFO_.BKP 标记=TAG20131005T185440通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:01完成 backup 于 05-10月-132、此时就可以关闭数据库,并手动删除相关目录下的所有重做日志文件及控制文件,物理删除即可,步骤省略:SQL> shutdown immediate;数据库已经关闭。
ORACLE数据库如何恢复
ORACLE数据库如何恢复(邝俊标)ORACLE数据库备份与恢复与ORACLE的结构密切相关,大家先弄清ORACLE 物理结构有哪些?逻辑结构是有哪些?它们的作用是什么?弄明白这些以后,具体怎么备份、怎么恢复就需要了解下ORACLE本身是怎么管理数据库的有那些相关的ORACLE系统表?ORACLE的后台进程是怎么管理的?最后就要知道相关的ORACLE命令、语法,根据系统提示错误灵活处理了。
ORACLE 恢复主要有下面的几种问题:一、数据文件丢失恢复:二、OS备份下的基于时间的恢复三、损坏联机日志的恢复四、损坏当前联机日志恢复五损坏控制文件的恢复六、损坏回滚数据文件的恢复七、损坏临时数据文件的恢复一、数据文件丢失恢复:1、查看报警文件或动态视图v$recover_fileSQL>select * from v$recover_file;2、脱机数据文件SQL> alter database datafile 'file#' offline drop;3、打开数据库,拷贝备份回来(restore),恢复(recover)该数据文件,并联机SQL> alter database open;4、拷贝备份从备份处copy d:\databak\ users01.dbf d:\oracle\oradata\orcl;5、恢复该数据文件SQL> recover datafile 'file#';SQL> recover database; (多个数据文件丢失,恢复整个数据库)6、恢复成功,联机该数据文件SQL> alter database datafile 'file#' online;说明:1) 采用热备份,需要运行在归档模式下,可以实现数据库的完全恢复,也就是说,从备份后到数据库崩溃时的数据都不会丢失。
2) 可以采用全备份数据库的方式备份,对于特殊情况,也可以只备份特定的数据文件,如只备份用户表空间(一般情况下对于某些写特别频繁的数据文件,可以单独加大备份频率)3) 如果在恢复过程中,发现损坏的是多个数据文件,即可以采用一个一个数据文件的恢复方法(第5步中需要对数据文件一一脱机,第6步中需要对数据文件分别恢复),也可以采用整个数据库的恢复方法。
总结了10种 Oracle 文件损坏及恢复的过程
总结了10种Oracle 文件损坏及恢复的过程2008年04月09日星期三22:49一、数据库服务器基本情况OS:RHEL 3CPU:4个Intel(R) Xeon(TM) MP CPU 2.70GHzMem:8GSwap:16GDisk:120GOracle Database 10g Enterprise Edition Release 10.1.0.3.0二、备份方式数据库以archive模式运行,RMAN多级增量备份。
策略如下:设置控制文件自动备份。
每三个月做一个数据库的全备份(包括所有得数据库和只读表空间),并备份归档日志。
每一个月做一次零级备份(不包含只读表空间),并备份归档日志。
每周做一次一级备份,并备份归档日志。
每天做一次二级备份,并备份归档日志。
三、恢复案例所有恢复的前提:已经做过数据库全备份(包括归档日志),控制文件和spfile自动备份。
1.损坏一个数据文件(1)故障模拟删除数据文件:rm /u02/oradata/dbnms/users01.dbf关闭数据库:shutdown immediate;ORA-01116: error in opening database file 4ORA-01110: data file 4: '/u02/oradata/dbnms/users01.dbf'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3强行关闭:sutdown abort;启动数据库:startup;ORA-01157: cannot identify/lock data file 4 - see DBWR trace fileORA-01110: data file 4: '/u02/oradata/dbnms/users01.dbf'(2)恢复步骤rman target sys@dbnms catalog rmanuser@catarun{allocate channel c1 type disk;restore datafile 4;recover datafile 4;sql 'alter database datafile 4 online';sql 'alter database open';release channel c1;}sqlplus sys as sysdbaselect instance_name,status from v$instance;INSTANCE_NAME STA TUS---------------- ------------dbnms OPEN恢复成功2.损坏全部数据文件(1)故障模拟删除数据文件:rm /u02/oradata/dbnms/*.dbf强行关闭:sutdown abort;启动数据库:startup;ORA-01157: cannot identify/lock data file 1 - see DBWR trace fileORA-01110: data file 1: '/u02/oradata/dbnms/system01.dbf'(2)恢复步骤rman target sys@dbnms catalog rmanuser@catarun{allocate channel c1 type disk;restore database;recover database;sql 'alter database open';release channel c1;}sqlplus sys as sysdbaselect instance_name,status from v$instance;INSTANCE_NAME STA TUS---------------- ------------dbnms OPEN恢复临时文件:alter database tempfile '/u02/oradata/dbnms/temp01.dbf' drop;alter tablespace temp add tempfile '/u02/oradata/dbnms/temp01.dbf' size 50M autoextend on next 5M maxsize unlimited;恢复成功3.损坏非当前联机日志成员(1)故障模拟删除日志文件:rm /u02/oradata/dbnms/redo01.log关闭数据库:shutdown immediate;启动数据库:startup;select * from v$logfile;GROUP# STATUS TYPE MEMBER IS_---------- ------- ------- ------------------------------ ---3 ONLINE /u02/oradata/dbnms/redo03.log NO2 STALE ONLINE /u02/oradata/dbnms/redo02.log NO1 INV ALID ONLINE /u02/oradata/dbnms/redo01.log NO1 STALE ONLINE /u02/oradata/dbnms/redo11.log NO1 STALE ONLINE /u02/oradata/dbnms/redo21.log NO2 STALE ONLINE /u02/oradata/dbnms/redo12.log NO3 ONLINE /u02/oradata/dbnms/redo13.log NO2 STALE ONLINE /u02/oradata/dbnms/redo22.log NO3 ONLINE /u02/oradata/dbnms/redo23.log NO4 ONLINE /u02/oradata/dbnms/redo31.log NO4 ONLINE /u02/oradata/dbnms/redo32.log NOGROUP# STATUS TYPE MEMBER IS_---------- ------- ------- ------------------------------ ---4 ONLINE /u02/oradata/dbnms/redo33.log NO(2)恢复步骤alter database drop logfile member '/u02/oradata/dbnms/redo01.log';alter database add logfile member '/u02/oradata/dbnms/redo01.log' to group 1; 恢复成功4.损坏非当前联机日志组(1)故障模拟删除日志文件组1的所有文件:rm /u02/oradata/dbnms/redo01.logrm /u02/oradata/dbnms/redo11.logrm /u02/oradata/dbnms/redo21.log关闭数据库:shutdown immediate;启动数据库:startup;Database mounted.ORA-00313: open failed for members of log group 1 of thread 1ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo11.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo21.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo01.log'(2)恢复步骤alter database clear logfile group 1;如果该日志组还没有归档,则用:alter database clear unarchived logfile group 1;打开数据库:alter database open;恢复成功5.损坏全部联机日志(1)故障模拟删除日志文件:rm /u02/oradata/dbnms/*.log关闭数据库:shutdown immediate;启动数据库:startup;Database mounted.ORA-00313: open failed for members of log group 1 of thread 1ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo11.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo21.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo01.log'(2)恢复步骤shutdown immediate;create pfile from spfile;cd $ORACLE_HOME/dbsvi initdbnms.ora加一个参数:_allow_resetlogs_corruption=truecreate spfile from pfile;startup;Database mounted.ORA-00313: open failed for members of log group 1 of thread 1ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo11.log' ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo21.log' ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo01.log' recover database until cancel;alter database open resetlogs;同步catalog:rman target sys@dbnms catalog rmanuser@catareset database;new incarnation of database registered in recovery catalogstarting full resync of recovery catalogfull resync complete做一个full备份:/home/oracle/dbbat/backup_full.sh恢复成功6.损坏一个控制文件(1)故障模拟删除控制文件:rm /u02/oradata/dbnms/control01.ctl关闭数据库:shutdown immediate;ORA-00210: cannot open the specified controlfileORA-00202: controlfile: '/u02/oradata/dbnms/control01.ctl'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3(2)恢复步骤拷贝一个好的控制文件:cp control02.ctl control01.ctlshutdown immediate;startup;Database mounted.ORA-01122: database file 1 failed verification checkORA-01110: data file 1: '/u02/oradata/dbnms/system01.dbf'ORA-01207: file is more recent than controlfile - old controlfilerman target sys@dbnms catalog rmanuser@catarun{allocate channel c1 type disk;restore database;recover database;sql 'alter database open';release channel c1;}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:04RMAN-11003: failure during parse/execution of SQL statement: alter database openORA-00322: log 3 of thread 1 is not current copyORA-00312: online log 3 thread 1: '/u02/oradata/dbnms/redo03.log'ORA-00312: online log 3 thread 1: '/u02/oradata/dbnms/redo13.log'ORA-00312: online log 3 thread 1: '/u02/oradata/dbnms/redo23.log'alter database clear unarchived logfile group 3;alter database open;恢复成功7.损坏全部控制文件(1)故障模拟删除控制文件:rm /u02/oradata/dbnms/control01.ctl关闭数据库:shutdown immediate;ORA-00210: cannot open the specified controlfileORA-00202: controlfile: '/u02/oradata/dbnms/control01.ctl'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3(2)恢复步骤shutdown abort;startup nomount;rman target sys catalog rmanuser@catarun{allocate channel c1 type disk;restore controlfile;restore database;sql 'alter database mount';recover database;sql 'alter database open resetlogs';release channel c1;}RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 09/08/2005 17:43:31RMAN-06054: media recovery requesting unknown log: thread 1 seq 9 lowscn 670233alter database open resetlogs;做一个full备份:/home/oracle/dbbat/backup_full.sh恢复成功8.损坏临时数据文件(1)故障模拟删除临时数据文件:rm /u02/oradata/dbnms/temp01.dbf关闭数据库:shutdown immediate;启动数据库:startup;(2)恢复步骤alter database tempfile '/u02/oradata/dbnms/temp01.dbf' drop;ERROR at line 1:ORA-01516: nonexistent log file, datafile, or tempfile"/u02/oradata/dbnms/temp01.dbf"alter tablespace temp add tempfile '/u02/oradata/dbnms/temp01.dbf' size 50M autoextend on next 5M maxsize unlimited;恢复成功9.损坏spfile参数文件(1)故障模拟删除spfile文件:rm $ORACLE_HOME/dbs/spfiledbnms.ora关闭数据库:shutdown immediate;启动数据库:startup;(2)恢复步骤startup nomount;rman target sys catalog rmanuser@catarestore spfile;shutdown immediate;startup;恢复成功10.损坏全部文件(包括全部数据文件、控制文件、临时数据文件、联机日志文件)(1)故障模拟删除全部文件:rm /u02/oradata/dbnms/*关闭数据库:shutdown immediate;ORA-03113: end-of-file on communication channel(2)恢复步骤sqlplus sys as sysdbastartup nomount;rman target sys catalog rmanuser@cata还原控制文件:restore controlfile;还原数据库:restore database;mount 数据库:alter database mount;恢复数据库:recover database;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 09/09/2005 10:33:13RMAN-06054: media recovery requesting unknown log: thread 1 seq 19 lowscn 718284用resetlogs方式打开数据库:alter database open resetlogs;database openednew incarnation of database registered in recovery catalogstarting full resync of recovery catalogfull resync complete重建临时文件:sqlplus sys as sysdbaalter database tempfile '/u02/oradata/dbnms/temp01.dbf' drop;ERROR at line 1:ORA-01516: nonexistent log file, datafile, or tempfile"/u02/oradata/dbnms/temp01.dbf"alter tablespace temp add tempfile '/u02/oradata/dbnms/temp01.dbf' size 50M autoextend on next 5M maxsize unlimited;执行一次全库备份:/home/oracle/dbbat/backup_full.sh恢复成功。
总结了10种_Oracle_文件损坏及恢复的过程
总结了10种Oracle 文件损坏及恢复的过程2008年04月09日星期三22:49一、数据库服务器基本情况OS:RHEL 3CPU:4个Intel(R) Xeon(TM) MP CPU 2.70GHzMem:8GSwap:16GDisk:120GOracle Database 10g Enterprise Edition Release 10.1.0.3.0二、备份方式数据库以archive模式运行,RMAN多级增量备份。
策略如下:设置控制文件自动备份。
每三个月做一个数据库的全备份(包括所有得数据库和只读表空间),并备份归档日志。
每一个月做一次零级备份(不包含只读表空间),并备份归档日志。
每周做一次一级备份,并备份归档日志。
每天做一次二级备份,并备份归档日志。
三、恢复案例所有恢复的前提:已经做过数据库全备份(包括归档日志),控制文件和spfile自动备份。
1.损坏一个数据文件(1)故障模拟删除数据文件:rm /u02/oradata/dbnms/users01.dbf关闭数据库:shutdown immediate;ORA-01116: error in opening database file 4ORA-01110: data file 4: '/u02/oradata/dbnms/users01.dbf'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3强行关闭:sutdown abort;启动数据库:startup;ORA-01157: cannot identify/lock data file 4 - see DBWR trace fileORA-01110: data file 4: '/u02/oradata/dbnms/users01.dbf'(2)恢复步骤rman target sys@dbnms catalog rmanuser@catarun{allocate channel c1 type disk;restore datafile 4;recover datafile 4;sql 'alter database datafile 4 online';sql 'alter database open';release channel c1;}sqlplus sys as sysdbaselect instance_name,status from v$instance;INSTANCE_NAME STA TUS---------------- ------------dbnms OPEN恢复成功2.损坏全部数据文件(1)故障模拟删除数据文件:rm /u02/oradata/dbnms/*.dbf强行关闭:sutdown abort;启动数据库:startup;ORA-01157: cannot identify/lock data file 1 - see DBWR trace fileORA-01110: data file 1: '/u02/oradata/dbnms/system01.dbf'(2)恢复步骤rman target sys@dbnms catalog rmanuser@catarun{allocate channel c1 type disk;restore database;recover database;sql 'alter database open';release channel c1;}sqlplus sys as sysdbaselect instance_name,status from v$instance;INSTANCE_NAME STA TUS---------------- ------------dbnms OPEN恢复临时文件:alter database tempfile '/u02/oradata/dbnms/temp01.dbf' drop;alter tablespace temp add tempfile '/u02/oradata/dbnms/temp01.dbf' size 50M autoextend on next 5M maxsize unlimited;恢复成功3.损坏非当前联机日志成员(1)故障模拟删除日志文件:rm /u02/oradata/dbnms/redo01.log关闭数据库:shutdown immediate;启动数据库:startup;select * from v$logfile;GROUP# STATUS TYPE MEMBER IS_---------- ------- ------- ------------------------------ ---3 ONLINE /u02/oradata/dbnms/redo03.log NO2 STALE ONLINE /u02/oradata/dbnms/redo02.log NO1 INV ALID ONLINE /u02/oradata/dbnms/redo01.log NO1 STALE ONLINE /u02/oradata/dbnms/redo11.log NO1 STALE ONLINE /u02/oradata/dbnms/redo21.log NO2 STALE ONLINE /u02/oradata/dbnms/redo12.log NO3 ONLINE /u02/oradata/dbnms/redo13.log NO2 STALE ONLINE /u02/oradata/dbnms/redo22.log NO3 ONLINE /u02/oradata/dbnms/redo23.log NO4 ONLINE /u02/oradata/dbnms/redo31.log NO4 ONLINE /u02/oradata/dbnms/redo32.log NOGROUP# STATUS TYPE MEMBER IS_---------- ------- ------- ------------------------------ ---4 ONLINE /u02/oradata/dbnms/redo33.log NO(2)恢复步骤alter database drop logfile member '/u02/oradata/dbnms/redo01.log';alter database add logfile member '/u02/oradata/dbnms/redo01.log' to group 1; 恢复成功4.损坏非当前联机日志组(1)故障模拟删除日志文件组1的所有文件:rm /u02/oradata/dbnms/redo01.logrm /u02/oradata/dbnms/redo11.logrm /u02/oradata/dbnms/redo21.log关闭数据库:shutdown immediate;启动数据库:startup;Database mounted.ORA-00313: open failed for members of log group 1 of thread 1ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo11.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo21.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo01.log'(2)恢复步骤alter database clear logfile group 1;如果该日志组还没有归档,则用:alter database clear unarchived logfile group 1;打开数据库:alter database open;恢复成功5.损坏全部联机日志(1)故障模拟删除日志文件:rm /u02/oradata/dbnms/*.log关闭数据库:shutdown immediate;启动数据库:startup;Database mounted.ORA-00313: open failed for members of log group 1 of thread 1ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo11.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo21.log'ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo01.log'(2)恢复步骤shutdown immediate;create pfile from spfile;cd $ORACLE_HOME/dbsvi initdbnms.ora加一个参数:_allow_resetlogs_corruption=truecreate spfile from pfile;startup;Database mounted.ORA-00313: open failed for members of log group 1 of thread 1ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo11.log' ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo21.log' ORA-00312: online log 1 thread 1: '/u02/oradata/dbnms/redo01.log' recover database until cancel;alter database open resetlogs;同步catalog:rman target sys@dbnms catalog rmanuser@catareset database;new incarnation of database registered in recovery catalogstarting full resync of recovery catalogfull resync complete做一个full备份:/home/oracle/dbbat/backup_full.sh恢复成功6.损坏一个控制文件(1)故障模拟删除控制文件:rm /u02/oradata/dbnms/control01.ctl关闭数据库:shutdown immediate;ORA-00210: cannot open the specified controlfileORA-00202: controlfile: '/u02/oradata/dbnms/control01.ctl'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3(2)恢复步骤拷贝一个好的控制文件:cp control02.ctl control01.ctlshutdown immediate;startup;Database mounted.ORA-01122: database file 1 failed verification checkORA-01110: data file 1: '/u02/oradata/dbnms/system01.dbf'ORA-01207: file is more recent than controlfile - old controlfilerman target sys@dbnms catalog rmanuser@catarun{allocate channel c1 type disk;restore database;recover database;sql 'alter database open';release channel c1;}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:04RMAN-11003: failure during parse/execution of SQL statement: alter database openORA-00322: log 3 of thread 1 is not current copyORA-00312: online log 3 thread 1: '/u02/oradata/dbnms/redo03.log'ORA-00312: online log 3 thread 1: '/u02/oradata/dbnms/redo13.log'ORA-00312: online log 3 thread 1: '/u02/oradata/dbnms/redo23.log'alter database clear unarchived logfile group 3;alter database open;恢复成功7.损坏全部控制文件(1)故障模拟删除控制文件:rm /u02/oradata/dbnms/control01.ctl关闭数据库:shutdown immediate;ORA-00210: cannot open the specified controlfileORA-00202: controlfile: '/u02/oradata/dbnms/control01.ctl'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3(2)恢复步骤shutdown abort;startup nomount;rman target sys catalog rmanuser@catarun{allocate channel c1 type disk;restore controlfile;restore database;sql 'alter database mount';recover database;sql 'alter database open resetlogs';release channel c1;}RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 09/08/2005 17:43:31RMAN-06054: media recovery requesting unknown log: thread 1 seq 9 lowscn 670233alter database open resetlogs;做一个full备份:/home/oracle/dbbat/backup_full.sh恢复成功8.损坏临时数据文件(1)故障模拟删除临时数据文件:rm /u02/oradata/dbnms/temp01.dbf关闭数据库:shutdown immediate;启动数据库:startup;(2)恢复步骤alter database tempfile '/u02/oradata/dbnms/temp01.dbf' drop;ERROR at line 1:ORA-01516: nonexistent log file, datafile, or tempfile"/u02/oradata/dbnms/temp01.dbf"alter tablespace temp add tempfile '/u02/oradata/dbnms/temp01.dbf' size 50M autoextend on next 5M maxsize unlimited;恢复成功9.损坏spfile参数文件(1)故障模拟删除spfile文件:rm $ORACLE_HOME/dbs/spfiledbnms.ora关闭数据库:shutdown immediate;启动数据库:startup;(2)恢复步骤startup nomount;rman target sys catalog rmanuser@catarestore spfile;shutdown immediate;startup;恢复成功10.损坏全部文件(包括全部数据文件、控制文件、临时数据文件、联机日志文件)(1)故障模拟删除全部文件:rm /u02/oradata/dbnms/*关闭数据库:shutdown immediate;ORA-03113: end-of-file on communication channel(2)恢复步骤sqlplus sys as sysdbastartup nomount;rman target sys catalog rmanuser@cata还原控制文件:restore controlfile;还原数据库:restore database;mount 数据库:alter database mount;恢复数据库:recover database;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 09/09/2005 10:33:13RMAN-06054: media recovery requesting unknown log: thread 1 seq 19 lowscn 718284用resetlogs方式打开数据库:alter database open resetlogs;database openednew incarnation of database registered in recovery catalogstarting full resync of recovery catalogfull resync complete重建临时文件:sqlplus sys as sysdbaalter database tempfile '/u02/oradata/dbnms/temp01.dbf' drop;ERROR at line 1:ORA-01516: nonexistent log file, datafile, or tempfile"/u02/oradata/dbnms/temp01.dbf"alter tablespace temp add tempfile '/u02/oradata/dbnms/temp01.dbf' size 50M autoextend on next 5M maxsize unlimited;执行一次全库备份:/home/oracle/dbbat/backup_full.sh恢复成功。
Oracle备份恢复-控制文件损坏的各种场景恢复专题
Oracle备份恢复-控制⽂件损坏的各种场景恢复专题⽹上有很多对控制⽂件损坏恢复的⽂章,但个⼈觉得介绍的恢复⽅法⽐较零散、不够全⾯,并且为什么要⽤这种⽅法来做恢复没有说的很具体,对很多刚接触这部分的朋友可能不是太好理解。
现在这篇⽂章就主要通过三部分来介绍控制⽂件恢复相关的内容:1、控制⽂件损坏的场景,以及不同场景在满⾜不同的条件时可以⽤哪些⽅法来恢复的介绍;2、针对不同恢复⽅法给出具体的恢复思路;3、模拟⼏种恢复⽅法的操作;⼀、不同场景在满⾜不同的条件时的恢复⽅法:⼆、针对不同的恢复⽅法给出具体的恢复思路:2.1、通过重新拷贝冗余的控制⽂件1、在线或者关闭数据库后损坏了其中部分控制⽂件;2、shutdown abort关闭数据库;3、拷贝其中⼀个完好的控制⽂件;4、startup启动数据库。
2.2、通过备份控制⽂件进⾏完全恢复1、在线或者关闭数据库后损坏了所有控制⽂件;2、shutdown abort关闭数据库;3、startup nomount启动数据库;4、restore controlfile from ‘xxx’;从备份中还原控制⽂件;5、alter database mount;5、recover database using backup controlfile until cancel,在执⾏时选择auto⾃动应⽤所有的归档⽂件;6、再次执⾏recover database using backup controlfile until cancel,选择应⽤未归档的redo⽂件;7、alter database open resetlogs;2.3、通过备份控制⽂件进⾏不完全恢复1、在线或者关闭数据库后损坏了所有控制⽂件;2、shutdown abort关闭数据库;3、startup nomount启动数据库;4、restore controlfile from ‘xxx’;从备份中还原控制⽂件;5、alter database mount;6、recover database using backup controlfile until cancel,在执⾏时选择auto⾃动应⽤尽可能多的归档⽂件;7、alter database open resetlogs;2.4、通过备份控制⽂件进⾏重建的恢复(noresetlogs⽅式)1、在线或者关闭数据库后损坏了所有控制⽂件;2、shutdown abort关闭数据库;3、startup nomount启动数据库;4、restore controlfile from ‘xxx’;从备份中还原控制⽂件;5、alter database mount;6、alter database backup controlfile to trace,⽣成创建控制⽂件的脚本;7、shutdown immediate并启动到startup nomount状态;8、使⽤noresetlogs⽅式创建控制⽂件;9、recover database恢复数据库;10、恢复完后通过alter database open打开数据库;2.5、通过备份控制⽂件进⾏重建的恢复(resetlogs⽅式)1、在线或者关闭数据库后损坏了所有控制⽂件;2、shutdown abort关闭数据库;3、startup nomount启动数据库;4、restore controlfile from ‘xxx’;从备份中还原控制⽂件;5、alter database mount;6、alter database backup controlfile to trace,⽣成创建控制⽂件的脚本;7、shutdown immediate并启动到startup nomount状态8、使⽤resetlogs⽅式创建控制⽂件;9、如果未归档的redo⽂件可⽤时,则直接recover database,然后选⽤未归档的redo⽂件应⽤,最后通过alter database open resetlogs⽅式打开数据库。
Oracle数据库文件损坏修复(断电情况下)
现场情况:1、数据库没有作归档,2、数据都存放在system表空间3、没有备份状况:操作系统由于磁盘原因出现宕机,用户强行按电源关闭系统,数据库无法启动。
处理:Sql代码1.SQL> recover database;2.ORA-00283: recovery session canceled due to errors3.ORA-12801: error signaled in parallel query server P0024.ORA-10562: Error occurred while applying redo to data block (file# 1, block#4568)5.ORA-10564: tablespace SYSTEM6.ORA-01110: data file 1: '/opt/oracle/oradata/orcl/system01.dbf'7.ORA-10561: block type 'TRANSACTION MANAGED INDEX BLOCK', data object# 5768.ORA-00600: internal error code, arguments: [6101]9.检查日志信息如下:Oracle代码1.Mon Nov 1915:38:5020072.ALTER DATABASE RECOVER database3.Mon Nov 1915:38:5020074.Media Recovery Start5. parallel recovery started with 3 processes6.Mon Nov 1915:38:5020077.Recovery of Online Redo Log: Thread 1 Group 3 Seq 16 Reading mem 08. Mem# 0 errs 0: /opt/oracle/oradata/orcl/redo03.log9.Mon Nov 1915:38:50200710.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p002_7917.trc:11.ORA-00600: internal error code, arguments: [6101], [0], [17], [0], [], [], [], []12.Mon Nov 1915:38:50200713.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p000_7913.trc:14.ORA-00600: internal error code, arguments: [3020], [2], [882],[8389490], [], [], [], []15.ORA-10567: Redo is inconsistent with data block (file# 2, block# 882)16.ORA-10564: tablespace UNDOTBS117.ORA-01110: data file 2: '/opt/oracle/oradata/orcl/undotbs01.dbf'18.ORA-10560: block type 'KTU UNDO BLOCK'19.Mon Nov 1915:38:51200720.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p000_7913.trc:21.ORA-00600: internal error code, arguments: [3020], [2], [882],[8389490], [], [], [], []22.ORA-10567: Redo is inconsistent with data block (file# 2, block# 882)23.ORA-10564: tablespace UNDOTBS124.ORA-01110: data file 2: '/opt/oracle/oradata/orcl/undotbs01.dbf'25.ORA-10560: block type 'KTU UNDO BLOCK'26.Mon Nov 1915:38:51200727.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p002_7917.trc:28.ORA-10562: Error occurred while applying redo to data block (file# 1, block# 4568)29.ORA-10564: tablespace SYSTEM30.ORA-01110: data file 1: '/opt/oracle/oradata/orcl/system01.dbf'31.ORA-10561: block type 'TRANSACTION MANAGED INDEX BLOCK', data object# 57632.ORA-00600: internal error code, arguments: [6101], [0], [17], [0], [], [], [], []33.Mon Nov 1915:38:54200734.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p001_7915.trc:35.ORA-00600: internal error code, arguments: [kddummy_blkchk], [1], [1658], [6101], [], [], [], []36.Mon Nov 1915:38:54200737.Errors in file /opt/oracle/admin/orcl/bdump/orcl_p001_7915.trc:38.ORA-10562: Error occurred while applying redo to data block (file# 1, block# 1658)39.ORA-10564: tablespace SYSTEM40.ORA-01110: data file 1: '/opt/oracle/oradata/orcl/system01.dbf'41.ORA-10561: block type 'TRANSACTION MANAGED DATA BLOCK', data object# 23742.ORA-00607: Internal error occurred while making a change to a data block43.ORA-00600: internal error code, arguments: [kddummy_blkchk], [1], [1658], [6101], [], [], [], []44.Mon Nov 1915:38:54200745.Media Recovery failed with error 1280146.ORA-283 signalled during: ALTER DATABASE RECOVER database ...从上面信息中抓取了一个信息:Oracle代码1.ORA-10562: Error occurred while applying redo to data block (file# 1, block# 1658)针对这个错误解决如下:Oracle代码1.ORA-10562: Error occurred while applying redo to data block (file# string, block# string)2.Cause: See other errors on error stack.3.Action: Investigate why the error occurred and how important isthe data block. Media and standby database recovery usually ca n continue if user allows recovery to corrupt this data block。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Oracle案例:损坏控制文件的恢复方法
一:损坏单个控制文件
损坏单个控制文件是比较容易恢复的,因为一般的数据库系统,控制文件都不是一个,而且所有的控制文件都互为镜相,只要拷贝一个好的控制文件替换坏的控制文件就可以了。
1、控制文件损坏,最典型的就是启动数据库出错,不能mount数据库
SQL>startup
ORA-00205: error in identifying controlfile, check alert log for more info
查看报警日志文件,有如下信息
alter database mount
Mon May 26 11:59:52 2003
ORA-00202: controlfile: 'D:\Oracle\oradata\chen\control01.ctl'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) 系统找不到指定的文件。
2、停止数据库
SQL>shutdown immediate
3、拷贝一个好的控制文件替换坏的控制文件或修改init.ora中的控制文件参数,取消这个坏的控制文件。
4、重新启动数据
SQL>startup
说明:
1、损失单个控制文件是比较简单的,因为数据库中所有的控制文件都是镜相的,只需要简
单的拷贝一个好的就可以了
2、建议镜相控制文件在不同的磁盘上
3、建议多做控制文件的备份,长期保留一份由alter database backup control file to trace产生的控制文件的文本备份
二:损坏全部控制文件
损坏多个控制文件,或者人为的删除了所有的控制文件,通过控制文件的复制已经不能解决问题,这个时候需要重新建立控制文件。
同时注意,alter database backup control file to trace可以产生一个控制文件的文本备份。
以下是详细重新创建控制文件的步骤
1、关闭数据库
SQL>shutdown immediate;
2、删除所有控制文件,模拟控制文件的丢失
3、启动数据库,出现错误,并不能启动到mount下
SQL>startup
ORA-00205: error in identifying controlfile, check alert log for more info
查看报警日志文件,有如下信息
alter database mount
Mon May 26 11:53:15 2003
ORA-00202: controlfile: 'D:\Oracle\oradata\chen\control01.ctl'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) 系统找不到指定的文件。
4、关闭数据库
SQL>shutdown immediate;
5、在internal或sys下运行如下创建控制文件的脚本,注意完整列出联机日志或数据文件的路径,或修改由alter database backup control file to trace备份控制文件时产生的脚本,去掉多余的注释即可。
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 254
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:\ORACLE\ORADATA\TEST\REDO01.LOG' SIZE 1M,
GROUP 2 'D:\ORACLE\ORADATA\TEST\REDO02.LOG' SIZE 1M,
GROUP 3 'D:\ORACLE\ORADATA\TEST\REDO03.LOG' SIZE 1M
DATAFILE
'D:\ORACLE\ORADATA\TEST\SYSTEM01.DBF',
'D:\ORACLE\ORADATA\TEST\RBS01.DBF',
'D:\ORACLE\ORADATA\TEST\USERS01.DBF',
'D:\ORACLE\ORADATA\TEST\TEMP01.DBF',
'D:\ORACLE\ORADATA\TEST\TOOLS01.DBF',
'D:\ORACLE\ORADATA\TEST\INDX01.DBF'
CHARACTER SET ZHS16GBK;
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
--if the last shutdown was not normal or immediate
--noarchive
-- RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE
--archive
-- RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL
-- Database can now be opened normally.
ALTER DATABASE OPEN;
--if recover database until cancel
--ALTER DATABASE OPEN RESETLOGS;
6、如果没有错误,数据库将启动到open状态下。
说明:
1、重建控制文件用于恢复全部控制文件的损坏,需要注意其书写的正确性,保证包含了所有的数据文件与联机日志
2、经常有这样一种情况,因为一个磁盘损坏,我们不能再恢复(store)数据文件到这个磁盘,
因此在store到另外一个盘的时候,我们就必须重新创建控制文件,用于识别这个新的数据文件,这里也可以用这种方法用于恢复。