Oracle RAC环境ASM磁盘组被强制删除,使用kfed工具完美恢复误删除磁盘组案例
在某些情况下,可能因为误操作,不小先drop diskgroup,这个时候千万别紧张,出现此类故障,可以通过kfed进行完美恢复(数据0丢失).如果进一步损坏了相关asm disk,那后续恢复就很麻烦了,可能需要使用dul扫描磁盘来进行抢救性恢复,而且可能导致数据丢失.
1.创建Oracle环境中的测试磁盘组
[grid@oracleplus ~]$ sqlplus / as sysasmSQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 30 15:12:08 2015Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Automatic Storage Management optionSQL> select name,path,header_status from v$asm_disk;NAME PATH HEADER_STATU------------------------------ ------------------------------ ------------ /dev/asm-disk3 CANDIDATEDATA_0000 /dev/asm-disk1 MEMBERDATA_0001 /dev/asm-disk2 MEMBERSQL> create diskgroup oracleplus external redundancy disk '/dev/asm-disk3';Diskgroup created.SQL> select name,path,header_status from v$asm_disk;NAME PATH HEADER_STATU------------------------------ ------------------------------ ------------oracleplus_0000 /dev/asm-disk3 MEMBERDATA_0000 /dev/asm-disk1 MEMBERDATA_0001 /dev/asm-disk2 MEMBER
使用/dev/asm-disk3这个磁盘创建磁盘组oracleplus
创建表,存储在oracleplus磁盘组中[oracle@oracleplus ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 30 15:14:55 2015Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, Automatic Storage Management, OLAP, Data Miningand Real Application Testing optionsSQL> create tablespace oracleplus datafile '+oracleplus' size 100M;Tablespace created.SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------+DATA/oracleplus/datafile/system.256.878224279+DATA/oracleplus/datafile/sysaux.257.878224279+DATA/oracleplus/datafile/undotbs1.258.878224279+DATA/oracleplus/datafile/users.259.878224279+oracleplus/oracleplus/datafile/oracleplus.256.878397315SQL> create table t_oracleplus tablespace oracleplus 2 as select * from dba_objects;Table created.SQL> select count(*) from t_oracleplus; COUNT(*)---------- 86259
通过在磁盘组中创建表空间,从而实现表oracleplus存放在测试磁盘组中
2.尝试删除磁盘组oracleplus
SQL> drop diskgroup oracleplus;drop diskgroup oracleplus*ERROR at line 1:ORA-15039: diskgroup not droppedORA-15053: diskgroup "oracleplus" contains existing filesSQL> drop diskgroup oracleplus including contents;drop diskgroup oracleplus including contents*ERROR at line 1:ORA-15039: diskgroup not droppedORA-15027: active use of diskgroup "oracleplus" precludes its dismount[grid@oracleplus ~]$ asmcmdASMCMD> lsofDB_Name Instance_Name Path oracleplus oracleplus +data/oracleplus/controlfile/current.260.878224379 oracleplus oracleplus +data/oracleplus/datafile/sysaux.257.878224279 oracleplus oracleplus +data/oracleplus/datafile/system.256.878224279 oracleplus oracleplus +data/oracleplus/datafile/undotbs1.258.878224279 oracleplus oracleplus +data/oracleplus/datafile/users.259.878224279 oracleplus oracleplus +data/oracleplus/onlinelog/group_1.261.878224381 oracleplus oracleplus +data/oracleplus/onlinelog/group_2.262.878224383 oracleplus oracleplus +data/oracleplus/onlinelog/group_3.263.878224385 oracleplus oracleplus +data/oracleplus/tempfile/temp.264.878224395 oracleplus oracleplus +oracleplus/oracleplus/datafile/oracleplus.256.878397315
由于oracleplus磁盘组被实例使用,因此磁盘组无法删除,报ORA-15027错误
由于oracleplus磁盘组中有文件,因此磁盘组无法删除,报ORA-15053错误如果这两个阻止你误删除磁盘组的警告依然不能救你,那我也不好多说啥了,只能向我一样继续往下3.关闭数据库实例,删除磁盘组
SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> drop diskgroup oracleplus;drop diskgroup oracleplus*ERROR at line 1:ORA-15039: diskgroup not droppedORA-15053: diskgroup "oracleplus" contains existing filesSQL> drop diskgroup oracleplus including contents;Diskgroup dropped.SQL> select name,path,header_status from v$asm_disk;NAME PATH HEADER_STATU------------------------------ ------------------------------ ------------ /dev/asm-disk3 FORMERDATA_0000 /dev/asm-disk1 MEMBERDATA_0001 /dev/asm-disk2 MEMBERSQL> alter diskgroup oracleplus mount;alter diskgroup oracleplus mount*ERROR at line 1:ORA-15032: not all alterations performedORA-15017: diskgroup "oracleplus" cannot be mountedORA-15063: ASM discovered an insufficient number of disks for diskgroup"oracleplus"
磁盘组被drop之后,无法正常mount,mount之时报ORA-15063凑无
4.使用kfed工具恢复删除磁盘组
[grid@oracleplus ~]$ kfed read /dev/asm-disk3 >/tmp/disk3-0-0[grid@oracleplus ~]$ kfed read /dev/asm-disk3 blkn=1 >/tmp/disk3-0-1[grid@oracleplus ~]$ kfed read /dev/asm-disk3 aun=1 >/tmp/disk3-1-0通过vi修改这些/tmp/disk3-*中的部分值[grid@oracleplus ~]$ kfed merge /dev/asm-disk3 text=/tmp/disk3-0-0[grid@oracleplus ~]$ kfed merge /dev/asm-disk3 blkn=1 text=/tmp/disk3-0-1[grid@oracleplus ~]$ kfed merge /dev/asm-disk3 aun=1 text=/tmp/disk3-1-0
查询修复后的asm disk
SQL> col path for a30SQL> set lines 150SQL> select name,path,header_status from v$asm_disk;NAME PATH HEADER_STATU------------------------------ ------------------------------ ------------ /dev/asm-disk3 MEMBERDATA_0000 /dev/asm-disk1 MEMBERDATA_0001 /dev/asm-disk2 MEMBER
5.尝试mount oracleplus 磁盘组
SQL> alter diskgroup oracleplus mount;Diskgroup altered.SQL> select name,path,header_status from v$asm_disk;NAME PATH HEADER_STATU------------------------------ ------------------------------ ------------oracleplus_0000 /dev/asm-disk3 MEMBERDATA_0000 /dev/asm-disk1 MEMBERDATA_0001 /dev/asm-disk2 MEMBER
测试恢复后磁盘组
SQL> startup ORACLE instance started.Total System Global Area 952020992 bytesFixed Size 2258960 bytesVariable Size 306186224 bytesDatabase Buffers 637534208 bytesRedo Buffers 6041600 bytesDatabase mounted.Database opened.SQL> select count(*) from t_oracleplus; COUNT(*)---------- 86259
这里证明,当磁盘组被误删除后,立即停止进一步损坏,可以通过kfed进行完美恢复
--------------------------------------ORACLE-DBA----------------------------------------
最权威、专业的Oracle案例资源汇总之案例:Oracle非常规恢复 ASM磁盘组diskgroup被删除使用kfed进行完美恢复
原文唯一网址: