kfed 磁盘组 误删除恢复

2024年 5月 30日 94.6k 0

查看现在磁盘组的信息
set linesize 1000
col path for a30
select GROUP_NUMBER,DISK_NUMBER,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB,NAME,PATH from v$asm_disk order by 1,2;
SQL>
GROUP_NUMBER DISK_NUMBER STATE REDUNDA OS_MB TOTAL_MB FREE_MB NAME PATH
------------ ----------- -------- ------- ---------- ---------- ---------- ------------------------------ ------------------------------
0 5 NORMAL UNKNOWN 5120 0 0 /dev/asm-diska
1 0 NORMAL UNKNOWN 10240 10240 6270 ARCH_0000 /dev/asm-diskc
2 0 NORMAL UNKNOWN 10240 10240 4249 DATA_0000 /dev/asm-diskb
3 0 NORMAL UNKNOWN 2048 2048 1740 OCR_VOTE_0000 /dev/asm-diskd
3 1 NORMAL UNKNOWN 2048 2048 1739 OCR_VOTE_0001 /dev/asm-diske
3 2 NORMAL UNKNOWN 2048 2048 1739 OCR_VOTE_0002 /dev/asm-diskf
创建磁盘组
SQL>
set line 300
col name for a15
select GROUP_NUMBER,NAME,STATE,TYPE,TOTAL_MB,FREE_MB from v$asm_diskgroup;SQL> SQL> SQL>
GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB
------------ --------------- ----------- ------ ---------- ----------
1 ARCH MOUNTED EXTERN 10240 6267
2 DATA MOUNTED EXTERN 10240 4249
3 OCR_VOTE MOUNTED NORMAL 6144 5218
4 TEST MOUNTED EXTERN 5120 5025
SQL>
col path for a30
select GROUP_NUMBER,DISK_NUMBER,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB,NAME,PATH from v$asm_disk order by 1,2;
SQL> SQL>
GROUP_NUMBER DISK_NUMBER STATE REDUNDA OS_MB TOTAL_MB FREE_MB NAME PATH
------------ ----------- -------- ------- ---------- ---------- ---------- --------------- ------------------------------
1 0 NORMAL UNKNOWN 10240 10240 6267 ARCH_0000 /dev/asm-diskc
2 0 NORMAL UNKNOWN 10240 10240 4249 DATA_0000 /dev/asm-diskb
3 0 NORMAL UNKNOWN 2048 2048 1740 OCR_VOTE_0000 /dev/asm-diskd
3 1 NORMAL UNKNOWN 2048 2048 1739 OCR_VOTE_0001 /dev/asm-diske
3 2 NORMAL UNKNOWN 2048 2048 1739 OCR_VOTE_0002 /dev/asm-diskf
4 0 NORMAL UNKNOWN 5120 5120 5025 TEST_0000 /dev/asm-diska
查询数据文件
SQL> set pagesize 0
SQL> select name from v$dbfile;
+DATA/rac11g/datafile/users.259.1084042585
+DATA/rac11g/datafile/undotbs1.258.1084042585
+DATA/rac11g/datafile/sysaux.257.1084042585
+DATA/rac11g/datafile/system.256.1084042585
+DATA/rac11g/datafile/example.265.1084042679
+DATA/rac11g/datafile/undotbs2.266.1084042817
+DATA/rac11g/datafile/test.271.1084444975
+DATA/rac11g/datafile/jt_sjgc.272.1092405397
+DATA/rac11g/datafile/jt_netcargps.273.1092405397
+DATA/rac11g/datafile/jt_busgps.274.1092405399
+DATA/rac11g/datafile/jt_taxigps.275.1092405399
+DATA/rac11g/datafile/audit_data.276.1133477037

create tablespace zc datafile '+test' size 10M;
create user zc identified by "zc" default tablespace zc;
grant dba to zc;
conn zc/zc
create table t1 as select level as id from dual connect by level/tmp/sdg01
块号1备份
kfed read /dev/sdg blkn=1 >/tmp/sdg02
aun1备份
kfed read /dev/sdg aun=1 >/tmp/sdg03
模拟问题
删除磁盘组,模拟误操作:
SQL> drop diskgroup test including contents;
drop diskgroup test including contents
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15027: active use of diskgroup "TEST" precludes its dismount
停库后继续删除:
[oracle@rac1 ~]$ srvctl status database -d rac11g
Instance rac11g is running on node rac1
Instance rac11g2 is running on node rac2
[oracle@rac1 ~]$ srvctl stop database -d rac11g
You have mail in /var/spool/mail/oracle
[oracle@rac1 ~]$ srvctl status database -d rac11g
Instance rac11g is not running on node rac1
Instance rac11g2 is not running on node rac2
You have mail in /var/spool/mail/oracle
''
成功删除掉 test 磁盘组:
另外节点dismount然后drop
SQL> drop diskgroup test including contents;
Diskgroup dropped.
SQL>
启动数据库报错:
[oracle@rac1 ~]$ srvctl start database -d rac11g
PRCR-1079 : Failed to start resource ora.rac11g.db
CRS-5017: The resource action "ora.TEST.dg start" encountered the following error:
ORA-15032: not all alterations performed
ORA-15017: diskgroup "TEST" cannot be mounted
ORA-15040: diskgroup is incomplete
. For details refer to "(:CLSN00107:)" in "/u01/11.2.0/grid/log/rac2/agent/crsd/oraagent_grid//oraagent_grid.log".
CRS-2674: Start of 'ora.TEST.dg' on 'rac2' failed
CRS-2632: There are no more servers to try to place resource 'ora.rac11g.db' on that would satisfy its placement policy
CRS-5017: The resource action "ora.rac11g.db start" encountered the following error:
ORA-01157: cannot identify/lock data file 13 - see DBWR trace file
ORA-01110: data file 13: '+TEST/rac11g/datafile/zc.256.1162077921'
. For details refer to "(:CLSN00107:)" in "/u01/11.2.0/grid/log/rac1/agent/crsd/oraagent_oracle//oraagent_oracle.log".
CRS-2674: Start of 'ora.rac11g.db' on 'rac1' failed

查看磁盘信息
SQL> set line 300
col name for a15
select GROUP_NUMBER,NAME,STATE,TYPE,TOTAL_MB,FREE_MB from v$asm_diskgroup;
SQL> SQL>
GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB
------------ --------------- ----------- ------ ---------- ----------
1 ARCH MOUNTED EXTERN 10240 6266
2 DATA MOUNTED EXTERN 10240 4249
3 OCR_VOTE MOUNTED NORMAL 6144 5218
SQL> col path for a30
select GROUP_NUMBER,DISK_NUMBER,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB,NAME,PATH from v$asm_disk order by 1,2;SQL>

GROUP_NUMBER DISK_NUMBER STATE REDUNDA OS_MB TOTAL_MB FREE_MB NAME PATH
------------ ----------- -------- ------- ---------- ---------- ---------- --------------- ------------------------------
0 0 NORMAL UNKNOWN 5120 0 0 /dev/asm-diska
1 0 NORMAL UNKNOWN 10240 10240 6266 ARCH_0000 /dev/asm-diskc
2 0 NORMAL UNKNOWN 10240 10240 4249 DATA_0000 /dev/asm-diskb
3 0 NORMAL UNKNOWN 2048 2048 1740 OCR_VOTE_0000 /dev/asm-diskd
3 1 NORMAL UNKNOWN 2048 2048 1739 OCR_VOTE_0001 /dev/asm-diske
3 2 NORMAL UNKNOWN 2048 2048 1739 OCR_VOTE_0002 /dev/asm-diskf
开始恢复
备份删除后的磁盘头信息
磁盘头信息备份
kfed read /dev/sdg >/tmp/sdg01xxx
块号1备份
kfed read /dev/sdg blkn=1 >/tmp/sdg02xxx
aun1备份
kfed read /dev/sdg aun=1 >/tmp/sdg03xxx
通过diff命令进行对比:
[grid@rac1 tmp]$ diff -C 1 /tmp/sdg01 /tmp/sdg01xxx|grep "kfdhdb.hdrsts"
! kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
! kfdhdb.hdrsts: 4 ; 0x027: KFDHDR_FORMER

通过对比删除前和删除后磁盘头数据的不同部分,可以看到kfdhdb.hdrsts行有差异。
尝试改回删除前磁盘头的信息:
--修改sdg01xxx文件
kfdhdb.hdrsts:状态值从4改为3,状态名称从KFDHDR_FORMER改为KFDHDR_MEMBER
[grid@rac1 tmp]$ vi /tmp/sdg01xxx

kfdhdb.hdrsts: 4 ; 0x027: KFDHDR_FORMER
改成
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfed merge /dev/sdg text=/tmp/sdg01xxx
检查磁盘组:可以看到CJC磁盘组了
SQL> set line 300
col name for a15
select GROUP_NUMBER,NAME,STATE,TYPE,TOTAL_MB,FREE_MB from v$asm_diskgroup;SQL> SQL>
GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB
------------ --------------- ----------- ------ ---------- ----------
1 ARCH MOUNTED EXTERN 10240 6266
2 DATA MOUNTED EXTERN 10240 4249
3 OCR_VOTE MOUNTED NORMAL 6144 5218
0 TEST DISMOUNTED 0 0
挂载磁盘组
alter diskgroup test mount;
SQL> alter diskgroup test mount;
Diskgroup altered.
SQL> set line 300
col name for a15
select GROUP_NUMBER,NAME,STATE,TYPE,TOTAL_MB,FREE_MB from v$asm_diskgroup;SQL> SQL>
GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB
------------ --------------- ----------- ------ ---------- ----------
1 ARCH MOUNTED EXTERN 10240 6266
2 DATA MOUNTED EXTERN 10240 4249
3 OCR_VOTE MOUNTED NORMAL 6144 5218
4 TEST MOUNTED EXTERN 5120 5007
启动数据库
[oracle@rac1 ~]$ srvctl start database -d rac11g
You have mail in /var/spool/mail/oracle
[oracle@rac1 ~]$
查看数据
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 27 23:44:10 2024
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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> select * from zc.t1;

ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论