Oracle数据库中各种类型的文件损坏与修复过程详解(1)(2)
5.损坏全部联机日志
(1)故障模拟
删除日志文件:rm /u02/oradata/dbnms/*.log
关闭数据库:shutdown immediate;
启动数据库:startup;
- Database mounted.
- ORA-00313: open failed for members of log group 1 of thread 1
- ORA-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/dbs
- vi initdbnms.ora
加一个参数:_allow_resetlogs_corruption=true
- create spfile from pfile;
- startup;
- Database mounted.
- ORA-00313: open failed for members of log group 1 of thread 1
- ORA-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@cata
- reset database;
- new incarnation of database registered in recovery catalog
- starting full resync of recovery catalog
- full 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 controlfile
- ORA-00202: controlfile: '/u02/oradata/dbnms/control01.ctl'
- ORA-27041: unable to open file
- Linux Error: 2: No such file or directory
- Additional information: 3
(2)恢复步骤
拷贝一个好的控制文件:
- cp control02.ctl control01.ctl
- shutdown immediate;
- startup;
- Database mounted.
- ORA-01122: database file 1 failed verification check
- ORA-01110: data file 1: '/u02/oradata/dbnms/system01.dbf'
- ORA-01207: file is more recent than controlfile - old controlfile
- rman target sys@dbnms catalog rmanuser@cata
- run{
- 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:04
- RMAN-11003: failure during parse/execution of SQL statement: alter database open
- ORA-00322: log 3 of thread 1 is not current copy
- ORA-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 controlfile
- ORA-00202: controlfile: '/u02/oradata/dbnms/control01.ctl'
- ORA-27041: unable to open file
- Linux Error: 2: No such file or directory
- Additional information: 3
(2)恢复步骤
- shutdown abort;
- startup nomount;
- rman target sys catalog rmanuser@cata
- run{
- 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:31
- RMAN-06054: media recovery requesting unknown log: thread 1 seq 9 lowscn 670233
- alter 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@cata
- restore spfile;
- shutdown immediate;
- startup;
恢复成功
10.损坏全部文件(包括全部数据文件、控制文件、临时数据文件、联机日志文件)
(1)故障模拟
删除全部文件:rm /u02/oradata/dbnms/*
关闭数据库:shutdown immediate;
- ORA-03113: end-of-file on communication channel
(2)恢复步骤
- sqlplus sys as sysdba
- startup 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:13
- RMAN-06054: media recovery requesting unknown log: thread 1 seq 19 lowscn 718284
用resetlogs方式打开数据库:alter database open resetlogs;
- database opened
- new incarnation of database registered in recovery catalog
- starting full resync of recovery catalog
- full resync complete
重建临时文件:
- sqlplus sys as sysdba
- 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;
执行一次全库备份:/home/oracle/dbbat/backup_full.sh,恢复成功。
关于Oracle数据库损坏文件的修复方法就就介绍到这里了,希望本次的介绍能够带给您一些收获吧!