多路径multipath共享磁盘udev配置

1. 配置共享磁盘

1.1. 主机关机的情况下,添加4块硬盘,每块磁盘设置如下

 

 

1.2. 另外一台主机添加上面已经存在的磁盘,同样设置

 

1.3. 修改两台虚拟机的配置文件(.vmx)

disk.locking = "FALSE"

disk.EnableUUID = "TRUE"

scsi1:1.SharedBus = "Virtual"

scsi1:2.SharedBus = "Virtual"

scsi1:3.SharedBus = "Virtual"

scsi1:4.SharedBus = "Virtual"

1.4. 将两台服务器重启,检查是否添加成功

2. 多路径multipath安装及配置

2.1. 下载multipath

yum list|grep multipath

yum -y install device-mapper-multipath.x86_64

2.2. 查看磁盘uuid

lsscsi -i

2.3. 将共享存储的uuid写入下面的文件中

vi /etc/multipath/wwids

/36000c29bbd354f3357b61608127d00dc/

/36000c294832a5fe38bc642f71ad33325/

/36000c29250c0ab3e0c01145e0d1b2c1e/

/36000c29bb24affd674793982fe27222f/

2.4. 编写配置文件/etc/multipath.conf

查找multipath.conf文件

find / -name "multipath.conf"

将找到的multipath.conf拷贝到/etc目录下面

cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc

编辑/etc/multipath.conf文件,末尾添加

multipaths {

       multipath {

               wwid                    36000c29bbd354f3357b61608127d00dc

               alias                   mpathb

       }

       multipath {

               wwid                    36000c294832a5fe38bc642f71ad33325

               alias                   mpathc

       }

           multipath {

               wwid                    36000c29250c0ab3e0c01145e0d1b2c1e

               alias                   mpathd

       }

         multipath {

               wwid                    36000c29bb24affd674793982fe27222f

               alias                   mpathe

       }

}

2.5. 重启multipathd

systemctl restart multipathd.service

systemctl enable multipathd.service

systemctl status multipathd.service

2.6. 开启多路径

multipath -v3

2.7. 查看多路径是否成功

multipath -ll

 

3. udev配置

3.1. 磁盘检查

按如图所示,有4个多路径mpathb ,mpathc,mpathd, mpathe

 

3.2. 新建udev规则文件

执行如下,获取mpathb,mpathc,mpathd,mpathe的UUID

>1.log;j=1;for i in mpathb mpathc mpathd mpathe; do echo ACTION==\"add\|change\", ENV{DM_UUID}==\"$(udevadm info --query=all --name=/dev/mapper/$i |grep -i dm_uuid|awk -F'=' '{print $2}')\", , SYMLINK+=\"rac/asmdisk$j\", OWNER=\"dmdba\", GROUP=\"dinstall\", MODE=\"0660\", OPTIONS=\"nowatch\"|tee -a 1.log; let j=j+1; done;

cat 1.log > /etc/udev/rules.d/99-dm-asmdevices.rules

手动修改SYMLINK 

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

ACTION=="add|change", ENV{DM_UUID}=="mpath-36000c29bbd354f3357b61608127d00dc", , SYMLINK+="rac/asmdcr", OWNER="dmdba", GROUP="dinstall", MODE="0660", OPTIONS="nowatch"

ACTION=="add|change", ENV{DM_UUID}=="mpath-36000c294832a5fe38bc642f71ad33325", , SYMLINK+="rac/asmvote", OWNER="dmdba", GROUP="dinstall", MODE="0660", OPTIONS="nowatch"

ACTION=="add|change", ENV{DM_UUID}=="mpath-36000c29250c0ab3e0c01145e0d1b2c1e", , SYMLINK+="rac/asmlog", OWNER="dmdba", GROUP="dinstall", MODE="0660", OPTIONS="nowatch"

ACTION=="add|change", ENV{DM_UUID}=="mpath-36000c29bb24affd674793982fe27222f", , SYMLINK+="rac/asmdata01", OWNER="dmdba", GROUP="dinstall", MODE="0660", OPTIONS="nowatch"

3.3. 完成裸设备绑定,重新加载udev规则

/sbin/udevadm control --reload-rules

/sbin/udevadm trigger --type=devices --action=change

3.4. 重启主机后,检查是否绑定

ls -lsa /dev/rac/asm*

3.5. 查看裸设备大小

blockdev --getsize64 /dev/rac/asmvote

blockdev --getsize64 /dev/rac/asmdcr

blockdev --getsize64 /dev/rac/asmlog

blockdev --getsize64 /dev/rac/asmdata01

 

posted @ 2023-10-22 10:35  fangzpa  阅读(573)  评论(0编辑  收藏  举报