【作者简介】
本人医疗行业DBA,精通oracle底层;会文件、触发器加密的勒索恢复、asm磁盘组不能mount及各种灾难恢复,后面将利用空闲时间将自己工作中遇到的问题及整理的资料分享给更多愿意学习和提升自己的dba。作者微信号:Oray_123
【正文】
创建一个文件,ASM 分配空间以extent 为单位。一旦文件被创建,ASM会传递extent映射表给数据库实例。
ASM实例的X$KFFXP视图就是ASM extent映射表的内容。X$KFFXP 每一行对应着mount状态磁盘组中每一个文件的每一个物理extent的信息。
X$KFFXP视图的重要字段包括:
GROUP_KFFXP 磁盘组编号。
NUMBER_KFFXP 文件序号。
INCARN_KFFXP 文件版本号。
XNUM_KFFXP 虚拟extent序号。
PXN_KFFXP 物理extent序号。
LXN_KFFXP 虚拟extent中物理extent的序号。
DISK_KFFXP 物理磁盘序号。
AU_KFFXP AU序号
在ASM实例中通过以下查询,能够看出磁盘组3内的ASM元数据文件的文件序号,名字和AU数量。
sqlplus as sysasm
select NUMBER_KFFXP "ASM file number",decode(NUMBER_KFFXP,1,'File directory',2,'Disk directory',3,'Active change directory',4,'Continuing operation directory',5,'Template directory',6,'Alias directory',7,'ADVM file directory',8,'Disk free space directory',9,'Attributes directory',10,'ASM User directory',11,'ASM user group directory',12,'Staleness directory',253,'spfile for ASM instance',254,'Stale bit map space registry',255,'Oracle Cluster Repository registry') "ASM metadata file name",count(AU_KFFXP) "Allocation units"
from x$kffxp where group_kffxp=3 and number_kffxp<256
group by NUMBER_KFFXP;
--19c
ASM file number ASM metadata file name Allocation units
--------------- -------------------------------------------------------------------- ----------------
1 File directory 3
2 Disk directory 6
3 Active change directory 69
4 Continuing operation directory 6
5 Template directory 3
6 Alias directory 3
8 Disk free space directory 3
9 Attributes directory 3
13 3
16 3
120 9
121 18
253 spfile for ASM instance 2
255 Oracle Cluster Repository registry 83
14 rows selected.
--11g
ASM file number ASM metadata file name Allocation units
--------------- -------------------------------------------------------------------- ----------------
1 File directory 3
2 Disk directory 3
3 Active change directory 255
4 Continuing operation directory 24
5 Template directory 3
6 Alias directory 3
8 Disk free space directory 3
9 Attributes directory 3
253 spfile for ASM instance 2
255 Oracle Cluster Repository registry 525
10 rows selected.
通过以上查询结果可以发现,这个磁盘组并没有包含所有类型的元数据文件(例如第十号和第十一号文件)。一个有意思的事情是,除了ASM实例的spfile,每个文件至少占用3个AU,对于这一点更多详细信息我们会在其他章节介绍。
我们再来以一个数据库控制文件为例查看下它的extent映射表:
第1步,查找DATA磁盘组内所有的数据库控制文件(以Grid所属的OS用户身份运行asmcmd命令)
[grid@hisdb01 ~]$ asmcmd find --type controlfile +DATA "*"
+DATA/ORCL/CONTROLFILE/Current.260.1030194917
第2步,检查DATA磁盘组的磁盘组序号(连接到asm实例)
set line 220
col name for a10
col state for a10
col COMPATIBILITY for a15
col database_compatibility for a15
SQL> select group_number,name,state,type,total_mb/1024 totol_gb,free_mb/1024 as free_gb,usable_file_mb/1024 usable_file_gb,allocation_unit_size/1024/1024 unit_mb,offline_disks,compatibility,database_compatibility,voting_files from v$asm_diskgroup order by 1;
GROUP_NUMBER NAME STATE TYPE TOTOL_GB FREE_GB USABLE_FILE_GB UNIT_MB OFFLINE_DISKS COMPATIBILITY DATABASE_COMPAT VO
------------ ---------- ---------- ------------ ---------- ---------- -------------- ---------- ------------- --------------- --------------- --
1 DATA MOUNTED EXTERN 58.59375 56.5605469 56.5605469 1 0 11.2.0.0.0 10.1.0.0.0 N
2 FRA MOUNTED EXTERN 9.765625 8.76367188 8.76367188 1 0 11.2.0.0.0 10.1.0.0.0 N
3 SYSTEMDG MOUNTED NORMAL 2.9296875 2.02539063 .524414063 1 0 11.2.0.0.0 10.1.0.0.0 Y
第3步,检查磁盘组1中ASM 256号文件(+DATA/ORCL/CONTROLFILE/Current.260.1030194917)的extent映射表
select XNUM_KFFXP "Virtual extent",PXN_KFFXP "Physical extent",LXN_KFFXP "Extent copy",DISK_KFFXP "Disk",AU_KFFXP "Allocation unit"
from x$kffxp
where group_kffxp=1 and number_kffxp=256 and xnum_kffxp<>2147483648
order by 1,2;
Virtual extent Physical extent Extent copy Disk Allocation unit
-------------- --------------- ----------- ---------- ---------------
0 0 0 0 52
1 1 0 1 52
2 2 0 0 53
3 3 0 1 53
4 4 0 0 54
5 5 0 1 54
6 6 0 0 55
7 7 0 1 55
8 8 0 0 56
9 9 0 1 56
10 10 0 0 57
...
Virtual extent Physical extent Extent copy Disk Allocation unit
-------------- --------------- ----------- ---------- ---------------
759 759 0 1 1040
760 760 0 0 1040
761 rows selected.
以上输出可以看出这个控制文件是1路镜像,每个虚拟extent对应1个物理extent,还可以看出这个文件每个AU的实际位置。