Oracle 11g的ASM有两个有意思的特性,我们看看他们能带给我们什么?
1.Fast mirror resync
原来当diskgroup中的盘发生故障时,Oracle会将这个盘标记为offline状态,并在一定的时间内从diskgroup中drop掉这块磁盘。如果disk只是临时性的故障,那么当故障恢复时,需要同步这块盘的全部内容,尤其是当某个failure group的全部磁盘都出现问题,比如我们的存储某个节点临时性断电,这时要重新build整个failure group中的所有磁盘,这个操作会非常耗费系统的资源,而是同步的过程会很长。
fast mirror resync这个特性在发生故障时,记录数据变化,然后当磁盘恢复时,只需要同步这些变化内容,让同步的时间变得很短。DISK_REPAIR_TIME
这个参数控制可以恢复的时间长短,如果故障超过这个时间,Oracle将从diskgroup中drop这块盘。
比较有意思的问题,第一个是Oracle如何记录这些变化?文档中并没有明确说明,但是我猜测是用位图方式来实现,即用位图来标识哪个extent发生了变化,然后当故障恢复时同步这个extent即可,因为位图占用的空间很小,这样就可以记录很长时间的变化。第二个是如果整个磁盘都坏掉,换了一块新的磁盘,这时必须同步这个磁盘的所有内容,fast mirror resync就失效了。
2.Preferred mirror read
ASM中mirror有primary copy和secondary copy,ASM总是读primary copy的内容,但是ASM会将不同extent的primary和secondary copy放在不同的failure group中,比如extent 1的primary在failgroup1,secondary在failgroup2,而extent2则刚好相反,用这种方式来实现负载均衡。
Preferred mirror read可以控制Oracle优先读取某个failure group上的copy,这个特性在RAC上很有用,我们可以控制RAC的节点优先读取离自己最“近”的存储,我突发奇想,设计一个两节点的RAC系统,利用iscsi来共享自己的磁盘给对方,然后利用这个特性,控制每个节点去读自己的本地磁盘。
下图这个方案,我们选用两台PC server,没有共享的存储,每台PC24块盘,如果追求吞吐量,用SAS/SATA盘,如果追求IOPS,可以用ssd盘。用iscsi将本地磁盘输出给地方节点,形成共享存储,RAC节点间互连可以用直连或交换方式。ASM中分别将两个PC的磁盘定位为单独的failgroup,利用preferred mirror read,让每个节点优先读取自己的本地failgroup中的extent copy.
ASM Preferred Mirror Read
Your ASM configuration may involve remote mirroring to disks that are a fair distance away. When some of your disk mirrors are far away then those disks may not be the best set of disks for a given instance to read from. For example, you might have a Real Application Cluster database with local and remote mirrored disks. In this case, you want to have the RAC instances primarily read from the local disks to ensure the best performance. ASM preferred mirror read is designed to indicate to Oracle which disk failgroup is the preferred read disk group.
ASM preferred mirror read is only available if you are using RAC. Also preferred mirror read is generally used only with clustered ASM instances, but this is not a requirement. To take advantage of ASM preferred mirror read, you should configure each disk failure group with specific geographically located set of disks. Use the Oracle 11g parameter, asm_preferred_read_failure_groups, to configure a databse instance with a list of preferred disk failure group names to use when that instance accesses ASM disks. The format of the values of the asm_preferred_read_failure_groups parameter is diskgroupname.failuregroupname where diskgroupname is the name of the disk group that the failure group belongs to and failuregroupname is the preferred failure groups name. Include multiple diskgroup/failgroup names by separating each preferred read group defined with a comma as seen in this example:
asm_preferred_read_failure_groups=dgroup1.fdisk2, dgroup2.fdisk2
In the event ASM cannot read from the preferred disk failure group, then the non-preferred failure groups will be read. To determine if a given disk file group is a preferred disk group you can use the PREFERRED_READ column of the V$ASM_DISK view.