多路冗余multipath
拓扑
++++++++++++++
+ Server +
++++++++++++++
eth0: 192.168.122.10/24 | eth1: 172.16.1.1/24
___________________|____________________
|
++++++++++++ ++++++++++++
virbr0 virbr1 +
++++++++++++ ++++++++++++
|_______________________________________|
|
eth0: 192.168.122.20/24 | eth1:172.16.1.2/24
++++++++++++
+ ISCSI Storage +
+ /dev/sdb1
++++++++++++
配置 ISCSI Storage
# yum install scsi-target-utils
# vim /etc/tgt/targets.conf
backing-store/dev/sdb
vendor_idiscsi
product_idstorage1
initiator-address172.16.1.1
initiator-address192.168.122.10
# service tgtd restart
配置 Server
# yum install iscsi-initiator-utils
# service iscsi start
# iscsiadm -m discovery -t sendtargets -p172.16.1.1:3260
# iscsiadm -m discovery -t sendtargets -p192.168.122.10:3260
# iscsiadm -m node -T iqn.2013-08.com.uplooking:iscsi.target1-l
虽然login设备一次,但是fdisk查看可以看到新增了2个设备sdb、sdc,而sdb、sdc又是同一个ISCSI设备
# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot Start End Blocks IdSystem
/dev/sda1 * 1 13 104391 83Linux
/dev/sda2 14 2610 20860402+ 8eLinux LVM
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
# yum install device-mapperdevice-mapper-multipath
# vim /etc/multipath.conf
默认情况下,multipath会把所有设备都加入到黑名单(devnode"*"),也就是禁止使用。所以需要注释掉这部分内容
#blacklist{
# devnode "*"
#}
以下内容defaults部分默认是注释掉的,将注释去掉,启用这一个部分
##
##Here is an example of how to configure some standard options.
##
#
defaults{
udev_dir /dev
polling_interval 10
selector "round-robin0"
path_grouping_policy multibus
getuid_callout "/sbin/scsi_id -g -u -s/block/%n"
prio_callout /bin/true
path_checker readsector0
rr_min_io 100
max_fds 8192
rr_weight priorities
failback immediate
no_path_retry fail
user_friendly_names yes
}
# service multipathd restart
# multipath -ll
mpath0 (1IET_00010001) dm-2 iscsi,storage1
[size=20G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=0][active]
\_ 3:0:0:1 sdb 8:16 [active][ready]
\_ 4:0:0:1 sdc 8:32 [active][ready]
# ls -l /dev/mapper/mpath0
brw-rw---- 1 root disk 253, 2 Feb 22 23:39/dev/mapper/mpath0
# dmsetup table
mpath0: 0 41943040 multipath 0 0 1 1round-robin 0 2 1 8:16 100 8:32 100
# dmsetup ls --tree
mpath0p1 (253:3)
└─mpath0(253:2)
├─ (8:32)
└─ (8:16)
测试:
ISCSI Storage 关闭 eth1
# ifdown eth1
Server 查看状态
# multipath -l
mpath0 (1IET_00010001) dm-2 iscsi,storage1
[size=20G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=0][active]
\_ 3:0:0:1 sdb 8:16 [failed][undef]
\_ 4:0:0:1 sdc 8:32 [active][undef]
、