探索ORACLE之RMAN_07 控制文件丢失恢复
作者:吴伟龙 Name:Prodence Woo
QQ:286507175 msn:hapy-wuweilong@hotmail.com
1、 控制文件(control file)丢失恢复
基于控制文件的复合多路径性,它的丢失分为两种,一种是其中某个控制文件的损坏或丢失,另外一种是所有控制文件均丢失。基于第一种情况,只需把好的控制文件复制一份在损坏或丢失的那个控制文件路径下即可。第二种情况下则需要通过备份信息来对控制文件进行恢复或手工重建控制文件。
丢失单一控制文件的判断及恢复。
数据库无法正常关闭,因为在关闭的时候必须向控制文件中更新scn号
SQL> shutdown immediate
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/DBData/oradata/WWL/control02.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
必须强制关闭数据库
SQL> shutdown abort;
ORACLE instance shut down.
启动数据库报控制文件验证失败,检查告警日志文件
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 7168000 bytes
ORA-00205: error in identifying control file, check alert log for more info
查看告警日志,报提示找不到controlfile2
Fri Jun 22 11:54:26 2012
Errors in file /DBSoft/admin/WWL/udump/wwl_ora_4816.trc:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/DBData/oradata/WWL/control02.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
从上面的信息我们可以得出是由于控制文件丢失导致了数据库无法正常的启动和关闭,下面我们要做的就是对控制文件进行做恢复,因为我们知道控制文件具有重复多路径属性,默认会有三个控制文件。现在日志中看到的是控制文件2丢失,找不到,我们可以通过控制文件1和3来恢复2。
4.1 基于正常控制文件恢复损坏的控制文件
1、查看控制文件存在路径
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /DBSoft/oradata/WWL/control01.ctl, /DBData/oradata/WWL/control02.ctl, /DBData/oradata/WWL/control03.ctl
SQL>
我们可以从如上看到,该套数据库存在三个控制文件其中一个控制文件存放在/DBSoft目中中的oradata/wwl/目录下,另外两个控制文件存在/DBData目录中的/oradata/wwl/的目录下,从上面刚才的信息中我们可以得之是control02.ctl控制文件丢失导致数据库故障。
2、检查下控制文件是不存在还是损坏了
[oracle@wwldb WWL]$ cd /DBData/oradata/WWL/
[oracle@wwldb WWL]$ ll
total 0
[oracle@wwldb WWL]$
怪了,这个目录怎么一个控制文件都没有了呀,看看控制文件一是否存在。
[oracle@wwldb WWL]$ cd /DBSoft/oradata/WWL/
[oracle@wwldb WWL]$ ls
control01.ctl
非常万幸,controlfile1还是存在的,这样我们就可以通过controlfile1来恢复controlfile2和3了。
3、关闭数据库
SQL> shutdown abort
ORACLE instance shut down.
SQL>
4、恢复损坏丢失的控制文件
[oracle@wwldb WWL]$ ls
control01.ctl
[oracle@wwldb WWL]$ pwd
/DBSoft/oradata/WWL
[oracle@wwldb WWL]$ ls
control01.ctl
[oracle@wwldb WWL]$ cp control01.ctl /DBData/oradata/WWL/control02.ctl
[oracle@wwldb WWL]$ cp control01.ctl /DBData/oradata/WWL/control03.ctl
[oracle@wwldb WWL]$ ll /DBData/oradata/WWL/
total 13792
-rw-r----- 1 oracle oinstall 7061504 Jun 22 12:51 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 Jun 22 12:51 control03.ctl
[oracle@wwldb WWL]$
2、 启动数据库
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
SQL>
4.2 所有控制文件全部丢失。
丢失单一控制文件的判断及恢复。
数据库无法正常关闭,因为在关闭的时候必须向控制文件中更新scn号
SQL> shutdown immediate
ORA-00210: cannot open the specified control file
ORA-00202: control file: ' /DBSoft/oradata/WWL/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
必须强制关闭数据库
SQL> shutdown abort;
ORACLE instance shut down.
启动数据库报控制文件验证失败,检查告警日志文件
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 7168000 bytes
ORA-00205: error in identifying control file, check alert log for more info
查看告警日志,报提示找不到controlfile1
Fri Jun 22 13:16:07 2012
Errors in file /DBSoft/admin/WWL/udump/wwl_ora_5104.trc:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/DBSoft/oradata/WWL/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
通过RMAN来进行控制文件的恢复:
1、 强制启动数据库到nomount状态
SQL> startup force nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 109053544 bytes
Database Buffers 167772160 bytes
Redo Buffers 7168000 bytes
SQL> exit
2、 执行restore控制文件恢复
RMAN>restore controlfile;
3、 打开数据库
SQL>alter database mount;
Database altered.
SQL>alter database open;
Database altered.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20674423/viewspace-733617/ ,如需转载,请注明出处,否则将追究法律责任。