导航

ORACLE误删除ASM磁盘修复

Posted on 2017-01-05 00:36  张鑫的园子  阅读(1274)  评论(0编辑  收藏  举报

  在数据库运维中,总会遇到一些粗心大意的DBA,一不小心删除一些东西,这里举例讲解在误删除ASM磁盘之后,如果用KFED工具进行恢复:

[grid@RAC1 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 5 00:06:04 2017

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 Real Application Clusters and Automatic Storage Management options

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

NAME                           PATH                           HEADER_STATU
------------------------------ ------------------------------ ------------
DATA_0001                      /dev/mapper/mpathc             MEMBER
DATA_0004                      /dev/mapper/mpathd             MEMBER
DATA_0003                      /dev/mapper/mpathf             MEMBER
DATA_0000                      /dev/mapper/mpathb             MEMBER
DATA1_0001                     /dev/mapper/mpathh             MEMBER
DATA_0002                      /dev/mapper/mpathg             MEMBER
DATA1_0002                     /dev/mapper/mpathi             MEMBER
DATA1_0000                     /dev/mapper/mpathe             MEMBER

8 rows selected.

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

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


------------------------------------------------------------------------------------------------------------------------

关闭数据连接:

SQL> alter diskgroup DATA dismount force;

Diskgroup altered.

SQL> drop diskgroup DATA force including contents;
drop diskgroup DATA force including contents
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15073: diskgroup DATA is mounted by another ASM instance
dismount 需要两边都dismount SQL
> drop diskgroup DATA force including contents; Diskgroup dropped. SQL> select name,path,header_status from v$asm_disk; NAME PATH HEADER_STATU ------------------------------ ------------------------------ ------------ /dev/mapper/mpathc FORMER /dev/mapper/mpathd FORMER /dev/mapper/mpathf FORMER /dev/mapper/mpathb FORMER /dev/mapper/mpathg FORMER DATA1_0001 /dev/mapper/mpathh MEMBER DATA1_0002 /dev/mapper/mpathi MEMBER DATA1_0000 /dev/mapper/mpathe MEMBER 8 rows selected. [grid@RAC1 ~]$ crs_stat -t CRS-0184: Cannot communicate with the CRS daemon. ############################################################################################################### 使用kfed进行恢复 [grid@RAC1 ~]$ kfed read /dev/mapper/mpathc > /tmp/mpathc-meta [root@RAC1 tmp]# vi mpathc-meta
用vi打开生成的文件,修改下面一行数据 kfdhdb.hdrsts:
4 ; 0x027: KFDHDR_FORMER 修改为: kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER [grid@RAC1 ~]$ kfed merge /dev/mapper/mpathc text=/tmp/mpathc-meta 将所有5块磁盘进行同样的操作。 SQL> select name,path,header_status from v$asm_disk; NAME PATH HEADER_STATU ------------------------------ ------------------------------ ------------ /dev/mapper/mpathc MEMBER /dev/mapper/mpathd MEMBER /dev/mapper/mpathf MEMBER /dev/mapper/mpathb MEMBER /dev/mapper/mpathg MEMBER DATA1_0001 /dev/mapper/mpathh MEMBER DATA1_0002 /dev/mapper/mpathi MEMBER DATA1_0000 /dev/mapper/mpathe MEMBER SQL> alter diskgroup DATA mount; Diskgroup altered. 两个节点都需要进行mount。 SQL> select name,path,header_status from v$asm_disk; NAME PATH HEADER_STATU ------------------------------ ------------------------------ ------------ DATA_0001 /dev/mapper/mpathc MEMBER DATA_0004 /dev/mapper/mpathd MEMBER DATA_0003 /dev/mapper/mpathf MEMBER DATA_0000 /dev/mapper/mpathb MEMBER DATA1_0001 /dev/mapper/mpathh MEMBER DATA_0002 /dev/mapper/mpathg MEMBER DATA1_0002 /dev/mapper/mpathi MEMBER DATA1_0000 /dev/mapper/mpathe MEMBER 8 rows selected. [grid@RAC1 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac1        
ora.DATA1.dg   ora....up.type ONLINE    ONLINE    rac1        
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1        
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac1        
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1        
ora.cvu        ora.cvu.type   ONLINE    OFFLINE               
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    rac1        
ora.oc4j       ora.oc4j.type  ONLINE    OFFLINE               
ora.ons        ora.ons.type   ONLINE    ONLINE    rac1        
ora....SM1.asm application    ONLINE    ONLINE    rac1        
ora....C1.lsnr application    ONLINE    ONLINE    rac1        
ora.rac1.gsd   application    OFFLINE   OFFLINE               
ora.rac1.ons   application    ONLINE    ONLINE    rac1        
ora.rac1.vip   ora....t1.type ONLINE    ONLINE    rac1        
ora.rac2.vip   ora....t1.type ONLINE    OFFLINE               
ora....ry.acfs ora....fs.type ONLINE    ONLINE    rac1        
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac1