by acdante
ASM实例概述
Oracle官方文档描述:
About Oracle ASM Instances
An Oracle ASM instance is built on the same technology as an Oracle Database instance. An Oracle ASM instance has a System Global Area (SGA) and background processes that are similar to those of Oracle Database. However, because Oracle ASM performs fewer tasks than a database, an Oracle ASM SGA is much smaller than a database SGA. In addition, Oracle ASM has a minimal performance effect on a server. Oracle ASM instances mount disk groups to make Oracle ASM files available to database instances; Oracle ASM instances do not mount databases.
Oracle ASM is installed in the Oracle Grid Infrastructure home before Oracle Database is installed in a separate Oracle home. Oracle ASM and database instances require shared access to the disks in a disk group. Oracle ASM instances manage the metadata of the disk group and provide file layout information to the database instances.
Oracle ASM metadata is the information that Oracle ASM uses to control a disk group and the metadata resides within the disk group. Oracle ASM metadata includes the following information:
· The disks that belong to a disk group
· The amount of space that is available in a disk group
· The filenames of the files in a disk group
· The location of disk group data file extents
· A redo log that records information about atomically changing metadata blocks
· Oracle ADVM volume information
1、环境概述
3节点RAC,Oracle版本:11.2.0.4.0,操作系统:RHEL6.5_64 ASM绑定方式:UDEV
2、新增ASM磁盘组
=============================================
select name, path, mode_status, state from v$asm_disk;
1ã 创建新的DISKGROUP,指定为Normal方式,且指定2个Failgroup:f1、f2
========================================================
select GROUP_NUMBER,NAME,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,TYPE FROM V$ASM_DISKGROUP where name='REDODG';
2、将原有REDO LOG删除,添加新的REDO LOG至新增的ASM DISKGROUP上。
=======================================================
alter database add logfile thread 1 group 7 '+redodg' size 50M;
alter database add logfile thread 2 group 8 '+redodg' size 50M;
alter database add logfile thread 3 group 9 '+redodg' size 50M;
alter database add logfile thread 1 group 10 '+redodg' size 50M;
alter database add logfile thread 2 group 11 '+redodg' size 50M;
alter database add logfile thread 3 group 12 '+redodg' size 50M;
alter database add logfile thread 1 group 1 '+redodg' size 50M;
alter database add logfile thread 2 group 2 '+redodg' size 50M;
alter database add logfile thread 3 group 3 '+redodg' size 50M;
3、通过Strace跟踪LGWR进程
猜想结果:
1ã 如果LGWR同时往/dev/asm-diskf和/dev/asm-diskg两块硬盘写入数据,那么证明数据镜像操作时由数据库进程LGWR完成、
2ã 如果LGWR至向REDODG中的一块硬盘写入数据,那么继续strace ASMLIB进程,查看镜像数据写入是由谁完成的。
实际结果:
查看LGWR进程号:5909
[root@acdante-1 rules.d]# strace -f -F -t -o /tmp/lgwr.log -p 5909
手动切换日志,
SQL>alter system switch logfile;
strace日志输出:
lgwr.log日志输出:
5909 10:54:50 io_submit(140161965449216, 2, {{0x7f79fe5f7960, 0, 1, 0, 261}, {0x7f79fe5f76f0, 0, 1, 0, 260}}) = 2
可看到LGWR同时向fd为260和261的介质写入提交了相同的IO请求,
那么继续查看260和261 fd详情:
[root@acdante-1 ~]# cd /proc/5909/fd
[root@acdante-1 fd]# ls -l
total 0
lr-x------ 1 root root 64 Jan 10 09:03 0 -> /dev/null
l-wx------ 1 root root 64 Jan 10 09:03 1 -> /dev/null
lr-x------ 1 root root 64 Jan 10 09:03 10 -> /dev/zero
lrwx------ 1 root root 64 Jan 10 09:03 11 -> socket:[104040]
lr-x------ 1 root root 64 Jan 10 09:03 12 -> /u01/app/oracle/11.2/db_1/rdbms/mesg/oraus.msb
lrwx------ 1 root root 64 Jan 10 09:03 13 -> /u01/app/oracle/11.2/db_1/dbs/hc_racdb1.dat
lrwx------ 1 root root 64 Jan 10 09:03 14 -> socket:[104041]
lrwx------ 1 root root 64 Jan 10 09:03 15 -> socket:[110926]
lrwx------ 1 root root 64 Jan 10 09:03 16 -> socket:[110927]
lrwx------ 1 root root 64 Jan 10 09:03 17 -> socket:[110928]
lrwx------ 1 root root 64 Jan 10 09:03 18 -> socket:[110929]
lrwx------ 1 root root 64 Jan 10 09:03 19 -> socket:[110930]
l-wx------ 1 root root 64 Jan 10 09:03 2 -> /dev/null
lrwx------ 1 root root 64 Jan 10 09:03 20 -> socket:[110933]
lrwx------ 1 root root 64 Jan 10 09:03 21 -> socket:[110934]
lrwx------ 1 root root 64 Jan 10 09:03 22 -> socket:[110935]
lrwx------ 1 root root 64 Jan 10 09:03 23 -> socket:[110936]
lrwx------ 1 root root 64 Jan 10 09:03 24 -> socket:[110939]
lrwx------ 1 root root 64 Jan 10 09:03 25 -> socket:[110940]
lrwx------ 1 root root 64 Jan 10 09:03 256 -> /dev/asm-diske
lrwx------ 1 root root 64 Jan 10 09:03 257 -> /dev/asm-diskc
lrwx------ 1 root root 64 Jan 10 09:03 258 -> /dev/asm-diskd
lrwx------ 1 root root 64 Jan 10 09:03 259 -> /dev/asm-diskb
lr-x------ 1 root root 64 Jan 10 09:03 26 -> /u01/app/oracle/11.2/db_1/rdbms/mesg/oraus.msb
lrwx------ 1 root root 64 Jan 10 09:45 260 -> /dev/asm-diskf
lrwx------ 1 root root 64 Jan 10 09:45 261 -> /dev/asm-diskg
l-wx------ 1 root root 64 Jan 10 09:19 27 -> socket:[1585988]
l-wx------ 1 root root 64 Jan 10 09:19 28 -> socket:[1585989]
lrwx------ 1 root root 64 Jan 10 09:45 29 -> socket:[1596685]
lrwx------ 1 root root 64 Jan 10 09:03 3 -> /u01/app/11.2/grid/log/acdante-1/agent/crsd/oraagent_oracle/oraagent_oracleOUT.log
l-wx------ 1 root root 64 Jan 10 09:03 4 -> /u01/app/11.2/grid/log/acdante-1/agent/crsd/oraagent_oracle/oraagent_oracle.log
lr-x------ 1 root root 64 Jan 10 09:03 5 -> /dev/null
lr-x------ 1 root root 64 Jan 10 09:03 6 -> /dev/null
lr-x------ 1 root root 64 Jan 10 09:03 7 -> /dev/null
lrwx------ 1 root root 64 Jan 10 09:03 8 -> socket:[104039]
lr-x------ 1 root root 64 Jan 10 09:03 9 -> /proc/5909/fd
[root@acdante-1 fd]#
4、分析结论
通过strace追踪LGWR进程的输出日志,可看到260和261分别对应的是/dev/asm-diskf和/dev/asm-diskg。
对比ASM DISKGROUP,260和261所对应的 设备为REDODG磁盘组中的两个Failgroup,LGWR自己完成了primary extent和mirror extent的IO操作。
至此已经可以得出结论,在RAC中,使用ASM磁盘存放数据,所有通过Oracle的数据写入ASM磁盘操作,都是由DB实例自己的进程完成了,包括ASM磁盘组的mirror extent和primary extent(在ASM磁盘组冗余方式为Normal或High时)。而ASM只负责元数据的IO操作和维护,以及向Oracle实例提供数据块分布信息。
参考链接:
1、Oracle官方文档:Automatic Storage Management Administrator's Guide