备份控制文件:backup current controlfile;
还原控制文件:restore controfile from '备份集';
恢复控制文件:recover database;
================实验=====================================================================
利用rman备份控制文件:
RMAN> backup current controlfile;
Starting backup at 25-FEB-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 25-FEB-11
channel ORA_DISK_1: finished piece 1 at 25-FEB-11
piece handle=/home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp tag=TAG20110225T090210 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-FEB-11
切换日志 模拟数据库正在做交易 说明我们备份的控制文件是老的了.
SQL> alter system switch logfile;(3次)
System altered.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/ora10g/control01.ctl
/u01/oracle/oradata/ora10g/control02.ctl
/u01/oracle/oradata/ora10g/control03.ctl
损坏控制文件:
SQL> ! rm /u01/oracle/oradata/ora10g/control01.ctl /u01/oracle/oradata/ora10g/control02.ctl /u01/oracle/oradata/ora10g/control03.ctl
重启库,报错ORA-00205:
SQL> startup force
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
发现控制文件丢失:
SQL> ! ls /u01/oracle/oradata/ora10g/control*
ls: /u01/oracle/oradata/ora10g/control*: 没有那个文件或目录
SQL> shut immediate
利用rman去恢复控制文件:
[oracle@dba ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Feb 25 09:16:39 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
在rman里,先启动数据库到nomount状态:
RMAN> startup nomount
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
此时无法查看rman的备份信息,因为此信息存储在控制文件中:
RMAN> list backup;
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 02/25/2011 09:16:49
ORA-01507: database not mounted 备份信息存在于控制文件 无法读取
还原控制文件:
RMAN> restore controlfile from '/home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp';
Starting restore at 25-FEB-11
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:02
output filename=/u01/oracle/oradata/ora10g/control01.ctl
output filename=/u01/oracle/oradata/ora10g/control02.ctl
output filename=/u01/oracle/oradata/ora10g/control03.ctl
Finished restore at 25-FEB-11
加载数据库:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
查看当前数据库中的控制文件状态和数据文件头状态
SQL> select checkpoint_change# from v$database;
CHECKPOINT_CHANGE#
------------------
493002
SQL> select checkpoint_change#,last_change# from v$datafile;
CHECKPOINT_CHANGE# LAST_CHANGE#
----------------- ------------
493002
493002
493002
493002
493002
SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
493349
493349
493349
493349
493349
文件头的记录比控制文件高 ,说明控制文件是老的需要恢复,此时可以手动在sqlplus里恢复,要手动告诉数据库使用老的控制文件恢复
也可以在rman里恢复,rman更智能,只需recover database命令,此命令无论控制文件还是数据文件需要恢复rman都会自己判断
------------ 方法1: 在sqlplus里操作 ---------------------------------------------------------------------------------------------------------------------------------------
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 resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oracle/oradata/ora10g/system01.dbf'
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
SQL> reocver database using backup controlfile;
SQL> alter database open resetlogs;
Database altered.
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
当采用resetlog打开数据库,控制文件是新的,原来的rman备份信息都没有了, 因为rman的信息在控制文件里,
新建控制文件没有rman备份信息,将原来备份可以注册到新的控制文件
catalog start with '/home/oracle/rman_bak/' ——此命令将扫描/home/oracle/rman_bak/目录下的所有备份文件集的头,将信息注册到控制文件
[oracle@dba ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Feb 25 09:44:32 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4062876933)
RMAN> list backup;
using target database control file instead of recovery catalog
注册备份文件集到新的控制文件:
RMAN> catalog start with '/home/oracle/rman_bak/';
searching for all files that match the pattern /home/oracle/rman_bak/
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/rman_bak/4_file.bak
File Name: /home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp
File Name: /home/oracle/rman_bak/ORA10G_4062876933_5_1_20110225.bkp
File Name: /home/oracle/rman_bak/users01.dbf
File Name: /home/oracle/rman_bak/ORA10G_4062876933_6_1_20110225.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/rman_bak/4_file.bak
File Name: /home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp
File Name: /home/oracle/rman_bak/ORA10G_4062876933_5_1_20110225.bkp
File Name: /home/oracle/rman_bak/users01.dbf
File Name: /home/oracle/rman_bak/ORA10G_4062876933_6_1_20110225.bkp
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 368.00K DISK 00:00:00 25-FEB-11
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20110225T084233
Piece Name: /home/oracle/rman_bak/4_file.bak
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
4 Full 492237 25-FEB-11 /u01/oracle/oradata/ora10g/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 6.77M DISK 00:00:00 25-FEB-11
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20110225T090210
Piece Name: /home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp
Control File Included: Ckp SCN: 493311 Ckp time: 25-FEB-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 368.00K DISK 00:00:00 25-FEB-11
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20110225T084707
Piece Name: /home/oracle/rman_bak/ORA10G_4062876933_5_1_20110225.bkp
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
4 Full 492437 25-FEB-11 /u01/oracle/oradata/ora10g/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 80.00K DISK 00:00:00 25-FEB-11
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20110225T085155
Piece Name: /home/oracle/rman_bak/ORA10G_4062876933_6_1_20110225.bkp
SPFILE Included: Modification time: 25-FEB-11
rman的配置信息也没有了 要重新定义
RMAN> configure channel device type disk format '/home/oracle/rman_bak/%d_%I_%s_%p_%T.bkp';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/home/oracle/rman_bak/%d_%I_%s_%p_%T.bkp';
new RMAN configuration parameters are successfully stored
-------------- 方法2: 从rman里恢复---------------------------------------------------------------------------------------------------------------------------------------------
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/25/2011 09:21:57
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN> alter database open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/25/2011 09:22:02
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oracle/oradata/ora10g/system01.dbf'
RMAN> recover database;
Starting recover at 25-FEB-11
Starting implicit crosscheck backup at 25-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 25-FEB-11
Starting implicit crosscheck copy at 25-FEB-11
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 25-FEB-11
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 4 is already on disk as file /u01/oracle/oradata/ora10g/redo03.log
archive log thread 1 sequence 5 is already on disk as file /u01/oracle/oradata/ora10g/redo01.log
archive log thread 1 sequence 6 is already on disk as file /u01/oracle/oradata/ora10g/redo02.log
archive log filename=/home/oracle/arc1/3_1_744004808.arc thread=1 sequence=3
archive log filename=/u01/oracle/oradata/ora10g/redo03.log thread=1 sequence=4
archive log filename=/u01/oracle/oradata/ora10g/redo01.log thread=1 sequence=5
archive log filename=/u01/oracle/oradata/ora10g/redo02.log thread=1 sequence=6
media recovery complete, elapsed time: 00:00:02
Finished recover at 25-FEB-11
恢复到此 数据库已经把所有日志都应用了,数据没丢,但这是不完全恢复。
虽然我们知道已经全恢复了,但数据库不知道恢复的终点, 所以是不完全恢复。
此时要resetlogs打开数据 但我们知道已经全部恢复了 这个resetlogs没必要 已经一致了 重建控制文件即可
恢复完成,重建控制文件:
SQL> alter database backup controlfile to trace as '/u01/oracle/recctl.sql';
Database altered.
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "ORA10G" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/oracle/oradata/ora10g/redo01.log' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/ora10g/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/ora10g/redo03.log' SIZE 50M
DATAFILE
'/u01/oracle/oradata/ora10g/system01.dbf',
'/u01/oracle/oradata/ora10g/undotbs01.dbf',
'/u01/oracle/oradata/ora10g/sysaux01.dbf',
'/u01/oracle/oradata/ora10g/users01.dbf',
'/u01/oracle/oradata/ora10g/mytest01.dbf'
CHARACTER SET AL32UTF8
;
Control file created.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/oracle/oradata/ora10g/system01.dbf'
SQL> recover database ;
Media recovery complete.
SQL> alter database open;
Database altered.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
还原控制文件:restore controfile from '备份集';
恢复控制文件:recover database;
================实验=====================================================================
利用rman备份控制文件:
RMAN> backup current controlfile;
Starting backup at 25-FEB-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 25-FEB-11
channel ORA_DISK_1: finished piece 1 at 25-FEB-11
piece handle=/home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp tag=TAG20110225T090210 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-FEB-11
切换日志 模拟数据库正在做交易 说明我们备份的控制文件是老的了.
SQL> alter system switch logfile;(3次)
System altered.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/ora10g/control01.ctl
/u01/oracle/oradata/ora10g/control02.ctl
/u01/oracle/oradata/ora10g/control03.ctl
损坏控制文件:
SQL> ! rm /u01/oracle/oradata/ora10g/control01.ctl /u01/oracle/oradata/ora10g/control02.ctl /u01/oracle/oradata/ora10g/control03.ctl
重启库,报错ORA-00205:
SQL> startup force
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
发现控制文件丢失:
SQL> ! ls /u01/oracle/oradata/ora10g/control*
ls: /u01/oracle/oradata/ora10g/control*: 没有那个文件或目录
SQL> shut immediate
利用rman去恢复控制文件:
[oracle@dba ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Feb 25 09:16:39 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
在rman里,先启动数据库到nomount状态:
RMAN> startup nomount
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
此时无法查看rman的备份信息,因为此信息存储在控制文件中:
RMAN> list backup;
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 02/25/2011 09:16:49
ORA-01507: database not mounted 备份信息存在于控制文件 无法读取
还原控制文件:
RMAN> restore controlfile from '/home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp';
Starting restore at 25-FEB-11
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:02
output filename=/u01/oracle/oradata/ora10g/control01.ctl
output filename=/u01/oracle/oradata/ora10g/control02.ctl
output filename=/u01/oracle/oradata/ora10g/control03.ctl
Finished restore at 25-FEB-11
加载数据库:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
查看当前数据库中的控制文件状态和数据文件头状态
SQL> select checkpoint_change# from v$database;
CHECKPOINT_CHANGE#
------------------
493002
SQL> select checkpoint_change#,last_change# from v$datafile;
CHECKPOINT_CHANGE# LAST_CHANGE#
----------------- ------------
493002
493002
493002
493002
493002
SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
493349
493349
493349
493349
493349
文件头的记录比控制文件高 ,说明控制文件是老的需要恢复,此时可以手动在sqlplus里恢复,要手动告诉数据库使用老的控制文件恢复
也可以在rman里恢复,rman更智能,只需recover database命令,此命令无论控制文件还是数据文件需要恢复rman都会自己判断
------------ 方法1: 在sqlplus里操作 ---------------------------------------------------------------------------------------------------------------------------------------
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 resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oracle/oradata/ora10g/system01.dbf'
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
SQL> reocver database using backup controlfile;
SQL> alter database open resetlogs;
Database altered.
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
当采用resetlog打开数据库,控制文件是新的,原来的rman备份信息都没有了, 因为rman的信息在控制文件里,
新建控制文件没有rman备份信息,将原来备份可以注册到新的控制文件
catalog start with '/home/oracle/rman_bak/' ——此命令将扫描/home/oracle/rman_bak/目录下的所有备份文件集的头,将信息注册到控制文件
[oracle@dba ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Feb 25 09:44:32 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4062876933)
RMAN> list backup;
using target database control file instead of recovery catalog
注册备份文件集到新的控制文件:
RMAN> catalog start with '/home/oracle/rman_bak/';
searching for all files that match the pattern /home/oracle/rman_bak/
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/rman_bak/4_file.bak
File Name: /home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp
File Name: /home/oracle/rman_bak/ORA10G_4062876933_5_1_20110225.bkp
File Name: /home/oracle/rman_bak/users01.dbf
File Name: /home/oracle/rman_bak/ORA10G_4062876933_6_1_20110225.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/rman_bak/4_file.bak
File Name: /home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp
File Name: /home/oracle/rman_bak/ORA10G_4062876933_5_1_20110225.bkp
File Name: /home/oracle/rman_bak/users01.dbf
File Name: /home/oracle/rman_bak/ORA10G_4062876933_6_1_20110225.bkp
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 368.00K DISK 00:00:00 25-FEB-11
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20110225T084233
Piece Name: /home/oracle/rman_bak/4_file.bak
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
4 Full 492237 25-FEB-11 /u01/oracle/oradata/ora10g/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 6.77M DISK 00:00:00 25-FEB-11
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20110225T090210
Piece Name: /home/oracle/rman_bak/ORA10G_4062876933_7_1_20110225.bkp
Control File Included: Ckp SCN: 493311 Ckp time: 25-FEB-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 368.00K DISK 00:00:00 25-FEB-11
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20110225T084707
Piece Name: /home/oracle/rman_bak/ORA10G_4062876933_5_1_20110225.bkp
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
4 Full 492437 25-FEB-11 /u01/oracle/oradata/ora10g/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 80.00K DISK 00:00:00 25-FEB-11
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20110225T085155
Piece Name: /home/oracle/rman_bak/ORA10G_4062876933_6_1_20110225.bkp
SPFILE Included: Modification time: 25-FEB-11
rman的配置信息也没有了 要重新定义
RMAN> configure channel device type disk format '/home/oracle/rman_bak/%d_%I_%s_%p_%T.bkp';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/home/oracle/rman_bak/%d_%I_%s_%p_%T.bkp';
new RMAN configuration parameters are successfully stored
-------------- 方法2: 从rman里恢复---------------------------------------------------------------------------------------------------------------------------------------------
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/25/2011 09:21:57
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN> alter database open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/25/2011 09:22:02
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/oracle/oradata/ora10g/system01.dbf'
RMAN> recover database;
Starting recover at 25-FEB-11
Starting implicit crosscheck backup at 25-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 25-FEB-11
Starting implicit crosscheck copy at 25-FEB-11
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 25-FEB-11
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 4 is already on disk as file /u01/oracle/oradata/ora10g/redo03.log
archive log thread 1 sequence 5 is already on disk as file /u01/oracle/oradata/ora10g/redo01.log
archive log thread 1 sequence 6 is already on disk as file /u01/oracle/oradata/ora10g/redo02.log
archive log filename=/home/oracle/arc1/3_1_744004808.arc thread=1 sequence=3
archive log filename=/u01/oracle/oradata/ora10g/redo03.log thread=1 sequence=4
archive log filename=/u01/oracle/oradata/ora10g/redo01.log thread=1 sequence=5
archive log filename=/u01/oracle/oradata/ora10g/redo02.log thread=1 sequence=6
media recovery complete, elapsed time: 00:00:02
Finished recover at 25-FEB-11
恢复到此 数据库已经把所有日志都应用了,数据没丢,但这是不完全恢复。
虽然我们知道已经全恢复了,但数据库不知道恢复的终点, 所以是不完全恢复。
此时要resetlogs打开数据 但我们知道已经全部恢复了 这个resetlogs没必要 已经一致了 重建控制文件即可
恢复完成,重建控制文件:
SQL> alter database backup controlfile to trace as '/u01/oracle/recctl.sql';
Database altered.
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "ORA10G" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/oracle/oradata/ora10g/redo01.log' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/ora10g/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/ora10g/redo03.log' SIZE 50M
DATAFILE
'/u01/oracle/oradata/ora10g/system01.dbf',
'/u01/oracle/oradata/ora10g/undotbs01.dbf',
'/u01/oracle/oradata/ora10g/sysaux01.dbf',
'/u01/oracle/oradata/ora10g/users01.dbf',
'/u01/oracle/oradata/ora10g/mytest01.dbf'
CHARACTER SET AL32UTF8
;
Control file created.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/oracle/oradata/ora10g/system01.dbf'
SQL> recover database ;
Media recovery complete.
SQL> alter database open;
Database altered.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29101923/viewspace-1434413/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29101923/viewspace-1434413/