如何使用udev给rac asm

如何使用udev给rac asm,第1张

机器上面使用的磁盘

[root@rac-db2 ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track,

5221 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector

size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal):

512 bytes / 512 bytes

Disk identifier: 0x00081b38

Device Boot

Start

End Blocks Id

System

/dev/sda1

*

15100

40960000 83

Linux

/dev/sda2

5100

5222 982016 82 Linux swap /

Solaris

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130

cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size

(logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512

bytes / 512 bytes

Disk identifier: 0x4af1bcf1

Device Boot

Start

End Blocks Id System

Disk /dev/sdc: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130

cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size

(logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512

bytes / 512 bytes

Disk identifier: 0x45528f9a

Device Boot

Start

End Blocks Id System

Disk /dev/sdd: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130

cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size

(logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512

bytes / 512 bytes

Disk identifier: 0xf65dbdac

Device Boot

Start

End Blocks Id System

Disk /dev/sde: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130

cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size

(logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512

bytes / 512 bytes

Disk identifier: 0xe0e7f25c

Device Boot

Start

End Blocks Id System

Disk /dev/sdf: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130

cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size

(logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512

bytes / 512 bytes

Disk identifier: 0x4b720782

Device Boot

Start

End Blocks Id System

其中sdb sdc sdd sde sdf是给oracle asm使用的磁盘

下面是配置udev的过程:

1、得到每个磁盘对应的scsi id号,使用命令如下:

[root@rac-db1 ~]# scsi_id -g -u

/dev/sdb

36000c29a982d7d5fe0af684b22046b34

[root@rac-db1 ~]# scsi_id

-g -u /dev/sdc

36000c294085e61228085d870db2173af

[root@rac-db1

~]# scsi_id -g -u

/dev/sdd

36000c29a1a053b53514c7202e9fd2658

[root@rac-db1 ~]# scsi_id

-g -u /dev/sde

36000c29ffa47abfd932ddf3a2f598633

[root@rac-db1

~]# scsi_id -g -u /dev/sdf

36000c292926acffd78b0a49f27d62c51

2、编辑udev的配置文件

编辑文件/etc/udev/rules.d/99-oracle-asmdevices.rules,内容如下:

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p",

RESULT=="36000c29a982d7d5fe0af684b22046b34", NAME="asmgrid_disk1",

OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi",

PROGRAM=="/sbin/scsi_id -g -u -s %p",

RESULT=="36000c294085e61228085d870db2173af", NAME="asmgrid_disk2",

OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi",

PROGRAM=="/sbin/scsi_id -g -u -s %p",

RESULT=="36000c29a1a053b53514c7202e9fd2658", NAME="asmgrid_disk3",

OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi",

PROGRAM=="/sbin/scsi_id -g -u -s %p",

RESULT=="36000c29ffa47abfd932ddf3a2f598633", NAME="asmgrid_disk4",

OWNER="grid", GROUP="asmadmin", MODE="0660"

KERNEL=="sd*", BUS=="scsi",

PROGRAM=="/sbin/scsi_id -g -u -s %p",

RESULT=="36000c292926acffd78b0a49f27d62c51", NAME="asmgrid_disk5",

OWNER="grid", GROUP="asmadmin", MODE="0660"

3、加载配置文件

[root@rac-db1 /]# udevadm control reload-rules

4、重启udev服务

[root@rac-db1 /]# start_udev

Starting udev: [ OK ]

5、检查配置结果

[root@rac-db1 /]# ls -l /dev/asm*

brw-rw---- 1 grid asmadmin 8, 16 Aug 31

11:11 /dev/asmgrid_disk1

brw-rw---- 1 grid asmadmin 8, 32 Aug 31 11:11

/dev/asmgrid_disk2

brw-rw---- 1 grid asmadmin 8, 48 Aug 31 11:11

/dev/asmgrid_disk3

brw-rw---- 1 grid asmadmin 8, 64 Aug 31 11:11

/dev/asmgrid_disk4

brw-rw---- 1 grid asmadmin 8, 80 Aug 31 11:11

/dev/asmgrid_disk5

[root@rac-db1 proc]# udevadm info --query=all --path=/block/sdc

P:

/devices/pci0000:00/0000:00:11.0/0000:02:05.0/host3/target3:0:1/3:0:1:0/block/sdc

N:

asmgrid_disk2

W: 50

S: block/8:32

S:

disk/by-id/scsi-36000c294085e61228085d870db2173af

S:

disk/by-path/pci-0000:02:05.0-scsi-0:0:1:0

S:

disk/by-id/wwn-0x6000c294085e61228085d870db2173af

E: UDEV_LOG=3

E:

DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:05.0/host3/target3:0:1/3:0:1:0/block/sdc

E:

MAJOR=8

E: MINOR=32

E: DEVNAME=/dev/asmgrid_disk2

E: DEVTYPE=disk

E:

SUBSYSTEM=block

E: ID_SCSI=1

E: ID_VENDOR=VMware

E:

ID_VENDOR_ENC=VMware\x20\x20

E: ID_MODEL=Virtual_disk

E:

ID_MODEL_ENC=Virtual\x20disk\x20\x20\x20\x20

E: ID_REVISION=1.0

E:

ID_TYPE=disk

E: ID_SERIAL_RAW=36000c294085e61228085d870db2173af

E:

ID_SERIAL=36000c294085e61228085d870db2173af

E:

ID_SERIAL_SHORT=6000c294085e61228085d870db2173af

E:

ID_WWN=0x6000c294085e6122

E: ID_WWN_VENDOR_EXTENSION=0x8085d870db2173af

E:

ID_WWN_WITH_EXTENSION=0x6000c294085e61228085d870db2173af

E:

ID_SCSI_SERIAL=6000c294085e61228085d870db2173af

E: ID_BUS=scsi

E:

ID_PATH=pci-0000:02:05.0-scsi-0:0:1:0

E: ID_PART_TABLE_TYPE=dos

E:

LVM_SBIN_PATH=/sbin

E: UDISKS_PRESENTATION_NOPOLICY=0

E:

UDISKS_PARTITION_TABLE=1

E: UDISKS_PARTITION_TABLE_SCHEME=mbr

E:

UDISKS_PARTITION_TABLE_COUNT=0

E: DEVLINKS=/dev/block/8:32

/dev/disk/by-id/scsi-36000c294085e61228085d870db2173af

/dev/disk/by-path/pci-0000:02:05.0-scsi-0:0:1:0

/dev/disk/by-id/wwn-0x6000c294085e61228085d870db2173af

[root@rac-db1 proc]#

配置了udev后, *** 作系统fdisk命令看不到asm使用的磁盘

[root@rac-db1 proc]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track,

5221 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector

size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal):

512 bytes / 512 bytes

Disk identifier: 0x000cc4c1

Device Boot

Start

End Blocks Id

System

/dev/sda1

*

15100

40960000 83

Linux

/dev/sda2

5100

5222 982016 82 Linux swap /

Solaris

对于rac中其他节点,把99-oracle-asmdevices.rules copy过去,再执行步骤3,4就可以了。

步骤如下:

1. 编辑/etc/scsi_id.config文件,如果该文件不存在,则创建该文件,添加如下行:

options=--whitelisted --replace-whitespace

备注:在我的测试中,此步骤可以省略。

2. 获取需要绑定为ASM Disk的磁盘uuid,比如我们要使用/dev/sdc和/dev/sdd作为ASM磁盘,那么:

# scsi_id --whitelisted --replace-whitespace --device=/dev/sdc

1ATA_VBOX_HARDDISK_VB36a9e548-1838194a

# scsi_id --whitelisted --replace-whitespace --device=/dev/sdd

1ATA_VBOX_HARDDISK_VB9808fc7f-cdf35030

3. 编写udev rules文件,PROGRAM中写scsi_id命令,RESULT中写上面命令中返回的uuid,这跟OEL5中没什么区别,只是scsi_id命令的语法发生变化了。

vi /etc/udev/rules.d/99-oracle-asmdevices.rules

KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB36a9e548-1838194a", NAME="asm-disk1", OWNER="grid", GROUP="dba", MODE="0660"

KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB9808fc7f-cdf35030", NAME="asm-disk2", OWNER="grid", GROUP="dba", MODE="0660"

4. 用udevadm进行测试,注意udevadm命令不接受/dev/sdc这样的挂载设备名,必须是使用/sys/block/sdc这样的原始设备名。

udevadm test /sys/block/sdc

udevadm info --query=all --path=/sys/block/sdc

udevadm info --query=all --name=asm-disk1

在显示中,有类似如下输出,表示测试正确,/dev/sdc设备在udev启动以后将会绑定为/dev/asm-disk1:

udevadm_test: UDEV_LOG=6

udevadm_test: DEVPATH=/devices/pci0000:00/0000:00:0d.0/host4/target4:0:0/4:0:0:0/block/sdc

udevadm_test: MAJOR=8

udevadm_test: MINOR=32

udevadm_test: DEVNAME=/dev/asm-disk1

udevadm_test: DEVTYPE=disk

udevadm_test: ACTION=add

udevadm_test: SUBSYSTEM=block

5. 启动udev

# /sbin/start_udev

6. 检查设备是否正确绑定

# ls -l /dev/asm*

brw-rw---- 1 grid dba 8, 32 Oct 26 21:24 /dev/asm-disk1

brw-rw---- 1 grid dba 8, 48 Oct 26 21:17 /dev/asm-disk2

然后创建ASM磁盘

在一个节点执行以下命令

# /etc/init.d/oracleasm enable

# /etc/init.d/oracleasm configure

# /etc/init.d/oracleasm createdisk DISK1 /dev/sdb5

# /etc/init.d/oracleasm createdisk DISK2 /dev/sdb6

# /etc/init.d/oracleasm createdisk DISK3 /dev/sdb7

将在以下路径/dev/oracleasm/disks/下产生ASM磁盘DISK1,DISK2,DISK3.

在其它节点执行以下命令,扫描ASM磁盘.

# /etc/init.d/oracleasm enable

# /etc/init.d/oracleasm configure

# /etc/init.d/oracleasm scandisks

# /etc/init.d/oracleasm listdisks

然后需要在每个节点上设置磁盘的访问权限,否则后面配置磁盘时无法发现磁盘.

# chown grid:dba /dev/oracleasm/disks/DISK1

# chown grid:dba /dev/oracleasm/disks/DISK2

# chown grid:dba /dev/oracleasm/disks/DISK3

由于系统重新启动后,磁盘的owner会被修改为root,为保证重启后保持磁盘owner不变,可以在/etc/udev/rule下添加一个rules文件

添加/etc/udev/rules.d/99-asmdisk-owner.rules文件,添加以下内容

NAME=="DISK1", WNER="grid" GROUP="dba", MODE="0660"

当然,asmlib并不只是用于创建asm磁盘,还具有asm存储管理功能,并为应用程序提供接口.

<<2>>使用udev管理,将从磁盘获得scsi_id,然后根据scsi_id加载成易读的设备名,保证设备名的唯一性.

如果使用虚拟机,首先需在虚拟主机的配置文件vmx文件中设置下列参数,以起用

disk.EnableUUID = "TRUE"

如果虚拟主机有通过设定更改任何参数,这个参数会自动更改为FALSE,需要重设.

启动主机后确认udev是否已安装

# rpm -qa | grep udev

udev-095-14.27.el5_7.1

执行以下命令获得scsi id信息

# /sbin/scsi_id -g -u -s /block/sdb # rhel5使用, rhel6使用:# /sbin/scsi_id -g -u -d /dev/sdb

36000c29fd07c14fdb1ca780130a5ad8e

配置udev配置文件,添加rules文件(在目录/etc/udev/rules.d/下)并授权.

# cd /etc/udev/rules.d/

# vi 99-x-asmdisk.rules

添加以下参数,注意一个行为一条规则,并且逗号(,)与下一个关键词之间有空格.

KERNEL=="sd?5", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/$parent", RESULT=="36000c29fd07c14fdb1ca780130a5ad8e", NAME="asmdisk1",

OWNER="grid", GROUP="dba", MODE="0660"

KERNEL=="sd?6", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/$parent", RESULT=="36000c29fd07c14fdb1ca780130a5ad8e", NAME="asmdisk2",

OWNER="oracle", GROUP="dba", MODE="0660"

KERNEL=="sd?7", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/$parent", RESULT=="36000c29fd07c14fdb1ca780130a5ad8e", NAME="asmdisk3",

OWNER="oracle", GROUP="dba", MODE="0660"

KERNEL=="sd?5", BUS=="scsi", NAME=="asmdisk1", WNER="grid", GROUP="dba", MODE="0660"

重新启动udev或重启节点.

# start_udev

验证是否配置正常

# ls -al /dev/asmdisk*

后续创建磁盘组时可以将搜索字符串ASM_DISKSTRING参数指向‘/dev/asmdisk*'就可以了


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11301354.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存