Chinaunix首页 | 论坛 | 博客
  • 博客访问: 59776
  • 博文数量: 18
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 135
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-19 18:00
文章分类

全部博文(18)

文章存档

2016年(18)

我的朋友

分类: Oracle

2016-06-22 19:38:57

Oracle RAC环境ASM磁盘组被强制删除,使用kfed工具完美恢复误删除磁盘组案例

在某些情况下,可能因为误操作,不小先drop diskgroup,这个时候千万别紧张,出现此类故障,可以通过kfed进行完美恢复(数据0丢失).如果进一步损坏了相关asm disk,那后续恢复就很麻烦了,可能需要使用dul扫描磁盘来进行抢救性恢复,而且可能导致数据丢失.

1.创建Oracle环境中的测试磁盘组

[grid@oracleplus ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 30 15:12:08 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Automatic Storage Management option

SQL>  select name,path,header_status from v$asm_disk;

NAME                           PATH                           HEADER_STATU
------------------------------ ------------------------------ ------------
                               /dev/asm-disk3                 CANDIDATE
DATA_0000                      /dev/asm-disk1                 MEMBER
DATA_0001                      /dev/asm-disk2                 MEMBER

SQL> 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                 MEMBER
DATA_0000                      /dev/asm-disk1                 MEMBER
DATA_0001                      /dev/asm-disk2                 MEMBER

使用/dev/asm-disk3这个磁盘创建磁盘组oracleplus

创建表,存储在oracleplus磁盘组中

[oracle@oracleplus ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 30 15:14:55 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> 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.878397315

SQL> 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 dropped
ORA-15053: diskgroup "oracleplus" contains existing files

SQL> drop diskgroup oracleplus  including contents;
drop diskgroup oracleplus  including contents
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15027: active use of diskgroup "oracleplus" precludes its dismount


[grid@oracleplus ~]$ asmcmd
ASMCMD> lsof
DB_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 immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> drop diskgroup oracleplus;
drop diskgroup oracleplus
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15053: diskgroup "oracleplus" contains existing files


SQL> drop diskgroup oracleplus  including contents;

Diskgroup dropped.


SQL>  select name,path,header_status from v$asm_disk;

NAME                           PATH                           HEADER_STATU
------------------------------ ------------------------------ ------------
                               /dev/asm-disk3                 FORMER
DATA_0000                      /dev/asm-disk1                 MEMBER
DATA_0001                      /dev/asm-disk2                 MEMBER

SQL> alter diskgroup oracleplus mount;
alter diskgroup oracleplus mount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15017: diskgroup "oracleplus" cannot be mounted
ORA-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 a30
SQL> set lines 150
SQL> select name,path,header_status from v$asm_disk;

NAME                           PATH                           HEADER_STATU
------------------------------ ------------------------------ ------------
                               /dev/asm-disk3                 MEMBER
DATA_0000                      /dev/asm-disk1                 MEMBER
DATA_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                 MEMBER
DATA_0000                      /dev/asm-disk1                 MEMBER
DATA_0001                      /dev/asm-disk2                 MEMBER

测试恢复后磁盘组

SQL> startup   
ORACLE instance started.

Total System Global Area  952020992 bytes
Fixed Size                  2258960 bytes
Variable Size             306186224 bytes
Database Buffers          637534208 bytes
Redo Buffers                6041600 bytes
Database mounted.
Database opened.
SQL>  select count(*) from t_oracleplus;

  COUNT(*)
----------
     86259

这里证明,当磁盘组被误删除后,立即停止进一步损坏,可以通过kfed进行完美恢复

 


--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之案例:Oracle非常规恢复 ASM磁盘组diskgroup被删除使用kfed进行完美恢复

原文唯一网址:

关键词:

阅读(1159) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~