ASM介绍与选择
Oracle ASM(自动存储管理)是Oracle数据库的数据卷管理器。ASM通过跟踪专用于Oracle数据库的存储设备并根据Oracle数据库实例的请求在这些设备上分配空间来协助用户进行磁盘管理。它有两种创建ASM共享磁盘的方式:ASMLib和UDEV:
- ASMLib
在2011年5月,甲骨文发表了一份Oracle数据库ASMLib的声明,声明中称甲骨文将不再提供Red Hat Enterprise Linux (RHEL)6的ASMLib和相关更新。
甲骨文在这份声明中表示,ASMLib更新将通过Unbreakable Linux Network (ULN)来发布,并仅对Oracle Linux客户开放。
Oracle Metalink文档:Oracle ASMLib Software Update Policy for Red Hat Enterprise Linux Supported by Red Hat [ID 1089399.1]
ASM优点:
- 总是使用direct,async IO
- 解决了永久性设备名的问题,即便在重启后设备名已经改变的情况下
- 解决了文件权限、拥有者的问题
- 减少了I/O期间从用户模式到内核模式的上下文切换,从而可能降低cpu使用率
- 减少了文件句柄的使用量
- ASMLIB API提供了传递如I/O优先级等元信息到存储设备的可能
ASM缺点:
- 对于多路径设备(multipathing)需要在/etc/sysconfig/oracleasm-_dev_oracleasm配置文件中设置ORACLEASM_SCANORDER及ORACLEASM_SCANEXCLUDE,以便ASMLIB能找到正确的设备文件,具体可以参考[Metalink Note<How To Setup ASM & ASMLIB On Native Linux Multipath Mapper disks? [ID 602952.1]>]
- 因为ASM INSTANCE使用ASMLIB提供的asm disk,所以增加了额外的层面
- 每次Linux Kernel更新,都需要替换新的ASMLIB包
- 增加了因人为错误造成宕机downtime的可能
- 使用ASMLIB意味着要花费更多时间去创建和维护
- 因为ASMLIB的存在,可能引入更多的bug,这是我们最不想看到的
- 使用ASMLIB创建的disk,其disk header并不会和普通的asm disk header有什么不同,仅仅是在头部多出了ASMLIB的属性空间。
- UDEV
udev 是Linux2.6 内核里的一个功能,它替代了原来的devfs,成为当前Linux 默认的设备管理工具。udev 以守护进程的形式运行,通过侦听内核发出来的uevent 来管理/dev目录下的设备文件。不像之前的设备管理工具,udev 在用户空间(user space) 运行,而不在内核空间(kernel space) 运行。
两者运用选择上,ASMLib由于其背景与特性基本上已经没有在新版本运用的,因为它带来许多的缺陷且性能未超过UDEV。UDEV方式将会是大家目前或未来用得最多的方式。
UDEV配置方式
- 磁盘分区
[root@RACNode01 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xf6614091.
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xf6614091
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{
K,M,G} (2048-20971519, default 20971519):
Using default value 20971519
Partition 1 of type Linux and of size 10 GiB is set
Command (m for help): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xf6614091
Device Boot Start End Blocks Id System
/dev/sdb1 2048 20971519 10484736 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
按照此方法,将其余的磁盘都进行分区配置。
- UDEV规则创建
CentOS 7
for i in b c d e f g h i ;
do
echo "KERNEL==\"sd*\", ENV{DEVTYPE}==\"disk\", SUBSYSTEM==\"block\", PROGRAM==\"/lib/udev/scsi_id -g -u -d \$devnode\",RESULT==\"`/lib/udev/scsi_id -g -u -d /dev/sd$i`\", SYMLINK+=\"asm-sd$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules
done
# 加载rules文件,重新加载udev rule
/sbin/udevadm control --reload
# 检查新的设备名称
/sbin/udevadm trigger --type=devices --action=change
# 诊断udev rule
/sbin/udevadm test /sys/block/*
CentOS 6
for i in b c d e f g h i ;
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\",RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-sd$i\", OWNER=\"grid\",GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules
done
启动UDEV
/sbin/start_udev
- 查看UDEV磁盘信息
ll -l /dev/asm*
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdb -> sdb
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdc -> sdc
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdd -> sdd
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sde -> sde
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdf -> sdf
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdg -> sdg
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdh -> sdh
lrwxrwxrwx 1 root root 3 May 26 11:11 /dev/asm-sdi -> sdi