关于Linux Multipath配置,网上还是很多的,自己再来梳理一下,当前环境为RedHat6,HP P2000存储
1. 安装软件。
查看是否安装 rpm -qa |grep device-mapper device-mapper-multipath-libs-0.4.9-31.el6.x86_64 device-mapper-event-libs-1.02.53-8.el6.x86_64 device-mapper-event-1.02.53-8.el6.x86_64 device-mapper-1.02.53-8.el6.x86_64 device-mapper-multipath-0.4.9-31.el6.x86_64
如果没有安装,请安装,命令如下
# yum –y install device-mapper device-mapper-multipath
# chkconfig multipathd on
2. 初始化模块。
# modprobe dm-multipath
# modprobe dm-round-robin
# lsmod |grep dm_multipath
dm_multipath 17756 3 dm_round_robin
dm_mod 82839 38 dm_multipath,dm_mirror,dm_log
3. 查找 HBA 卡的 wwid.
# multipath -v3 | grep uid
Aug 14 09:39:30 | sda: getuid = /lib/udev/scsi_id --whitelisted --device=/dev/%n (controller setting)
Aug 14 09:39:30 | sda: uid = 3600c0ff0001982fa95fcfe5101000000 (callout)
Aug 14 09:39:30 | sdb: getuid = /lib/udev/scsi_id --whitelisted --device=/dev/%n (controller setting)
Aug 14 09:39:30 | sdb: uid = 3600c0ff0001982fa95fcfe5101000000 (callout)
uuid hcil dev dev_t pri dm_st chk_st vend/prod
4. 配置多路径。
# vi /etc/multipath.conf
blacklist {
devnode "^sdc"
}
defaults {
user_friendly_names no
}
multipaths {
multipath {
wwid 3600c0ff0001982fa95fcfe5101000000
alias mpath0
path_grouping_policy multibus
path_selector "round-robin 0"
}
}
devices {
device {
vendor "HP"
product "Virtual disk"
path_grouping_policy multibus
getuid_callout "/sbin/scsi_id -g -u -s /block/%n"
path_checker readsector0
path_selector "round-robin 0"
}
}
5. 启动多路径软件。
# service multipathd start
# chkconfig multipathd on
# multipath -F # 删除现有路径。
# multipath -v2 # 格式化路径。
# multipath -ll # 查看多路径,目前是主备模式。
mpath0 (3600c0ff0001982fa95fcfe5101000000) dm-0 HP,P2000 G3 SAS
size=9.1T features='1 queue_if_no_path' hwhandler='0' wp=rw
|- - policy='round-robin 0' prio=130 status=active
| - 3:0:0:1 sda 8:0 active ready running
- - policy='round-robin 0' prio=10 status=enabled
- 4:0:0:1 sdb 8:16 active ready running
6. 重启测试。
# reboot
# multipath -ll # 依然是主备模式。
# service multipathd start # 再次重启 multipathd.
# multipath -ll # 变成主主模式。
size=9.1T features='1 queue_if_no_path' hwhandler='0' wp=rw
- - policy='round-robin 0' prio=70 status=active
|- 3:0:0:1 sda 8:0 active ready running # 需要重启一次才会变成主主?
`- 4:0:0:1 sdb 8:16 active ready running
7. 创建用户逻辑卷。
# pvcreate /dev/mapper/mpath0
# vgcreate -s 256m datavg /dev/mapper/mpath0
# lvcreate --size 2000G --name lv_src vg_data
# mkfs.ext4 /dev/mapper/vg_data-lv_src
# mkdir /src
# mount -t ext4 /dev/mapper/vg_data-lv_src /src
8. 负载均衡测试。
# cd /src
# dd if=/dev/zero of=test.img
# iostat 1
Device: tps Blk_read/s Blk_wrtn/s
sda 2020.00 8.00 466272.00 # 两条线路都有数据传输,主主模式起作用。
sdb 2024.00 0.00 368952.00 # 如果只有一条线路传输数据,就是主备模式。
sdc 0.00 0.00 0.00
dm-0 4044.00 8.00 834776.00 # 合并后的路径,数据等于两条