RedHat Linux 安装配置Multipath多路径识别iSCSI存储设备
关于RedHat Linux上的多路径Multipath,以及为了方便学习在本机电脑上安装了Openfiler模拟存储,配置多块网卡实现多路径冗余识别存储。在这里以我个人的理解简单的描述我所认知的理论知识。
Multipath是Linux系统上开源免费的多路径软件,实现服务器可以通过多条物理路径连接到块存储。
Openfiler是底层以Linux系统模拟的存储架构,可以配置多块网卡,同时可以配置软件Raid。
多路径是避免设备之间单条链路的单点故障隐患,同时可以实现流量分摊,实现性能提升。
当因为主机HBA卡、线缆、交换机或者存储设备的RAID控制器故障等原因造成一条物理路径失效时,服务器可以将通过此物理路径的I/O转移到其他正常的物理路径上面,而应用程序不会觉察到底层的改变,从而提高系统的可用性。
在这里通过模拟现网环境配置Multipath实现多路径冗余;
实验环境:
Redhat Enterprise Linux 7.2 //安装配置Multipath多路径识别ISCSI存储设备;
Openfileresa-2.99.1-x86_64 //配置多网卡,模拟配置ISCSI存储;
在VMworkstation上Openfiler系统已经安装完成并且配置了四块物理网卡用于实现存储多路径,相应的IP地址已经配置规划;
首先配置存储设备的磁盘阵列Raid,由于在这里用的是模拟存储设备没有相应的RAID控制器,所以在这里配置软件Raid,模拟现网中存储设备的配置;
在Openfiler中配置添加逻辑卷,以及分配相应的空间大小给卷组。在这里配置了四个lv磁盘组,为了便于后续Oracle ASM使用;
创建相应的ISCSI并关联LUN,并且配置允许192.168.60.0/24网段访问,在此Openfiler存储相应的配置就完成了;
在Redhat Linux上首先挂载并配置YUM源,安装iscsi initiator软件;
[root@bogon ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@bogon ~]# vi /etc/yum.conf
[local]
baseurl=file:///mnt
gpgcheck=0
enabled=1
[root@bogon ~]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository 'local' is missing name in configuration, using id
local | 4.1 kB 00:00:00
(1/2): local/group_gz | 136 kB 00:00:00
(2/2): local/primary_db | 3.6 MB 00:00:00
repo id repo name status
local local 4,620
repolist: 4,620
[root@bogon ~]# cd /mnt/Packages/
[root@bogon Packages]# rpm -ivh iscsi-initiator-utils-6.2.0.873-32.el7.x86_64.rpm
warning: iscsi-initiator-utils-6.2.0.873-32.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
package iscsi-initiator-utils-6.2.0.873-32.el7.x86_64 is already installed
启动iSCSI相关服务,并且配置开机启动项;
[root@bogon Packages]# systemctl list-unit-files | grep iscsi
iscsi-shutdown.service static
iscsi.service enabled
iscsid.service disabled
iscsiuio.service disabled
iscsid.socket enabled
iscsiuio.socket enabled
[root@bogon Packages]# systemctl enable iscsi.service
扫描并识别ISCSI存储信息,由于Openfiler所用端口号为3260,所以在此扫描添加端口号;
[root@bogon Packages]# iscsiadm -m discovery -t st -p 192.168.60.11:3260
192.168.60.11:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06
192.168.60.12:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06
192.168.60.13:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06
192.168.60.14:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06
修改配置ISCSI软件开机扫描信息;
12 vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2006-01.com.openfiler:tsn.6524fccc7d06
对扫描到的ISCSI识别存储进行登陆;
[root@bogon Packages]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.6524fccc7d06 -p 192.168.60.11:3260 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.11,3260] (multiple)
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.11,3260] successful.
[root@bogon Packages]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.6524fccc7d06 -p 192.168.60.12:3260 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.12,3260] (multiple)
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.12,3260] successful.
[root@bogon Packages]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.6524fccc7d06 -p 192.168.60.13:3260 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.13,3260] (multiple)
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.13,3260] successful.
[root@bogon Packages]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.6524fccc7d06 -p 192.168.60.14:3260 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.14,3260] (multiple)
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.6524fccc7d06, portal: 192.168.60.14,3260] successful.
查看ISCSI当前登陆会话是否正常;
[root@bogon Packages]# iscsiadm -m session
tcp: [1] 192.168.60.11:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06 (non-flash)
tcp: [2] 192.168.60.12:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06 (non-flash)
tcp: [3] 192.168.60.13:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06 (non-flash)
tcp: [4] 192.168.60.14:3260,1 iqn.2006-01.com.openfiler:tsn.6524fccc7d06 (non-flash)
安装Multipath多路径软件,并配置开机自动启动;
[root@bogon Packages]# rpm -ivh device-mapper-libs-1.02.107-5.el7.x86_64.rpm
warning: device-mapper-libs-1.02.107-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
package device-mapper-libs-7:1.02.107-5.el7.x86_64 is already installed
[root@bogon Packages]# rpm -ivh device-mapper-multipath-0.4.9-85.el7.x86_64.rpm
warning: device-mapper-multipath-0.4.9-85.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
package device-mapper-multipath-0.4.9-85.el7.x86_64 is already installed
[root@bogon Packages]# systemctl enable multipathd.service
[root@bogon Packages]# systemctl list-unit-files | grep multipath
multipathd.service enabled
[root@bogon Packages]# modprobe dm-multipath
[root@bogon Packages]# modprobe dm-round-robin
[root@bogon Packages]# systemctl start multipathd.service
查看并生成Multipath配置文件;
[root@bogon Packages]# multipath -ll
Jun 09 11:28:53 | /etc/multipath.conf does not exist, blacklisting all devices.
Jun 09 11:28:53 | A default multipath.conf file is located at
Jun 09 11:28:53 | /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
Jun 09 11:28:53 | You can run /sbin/mpathconf to create or modify /etc/multipath.conf
[root@bogon Packages]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/multipath.conf
[root@bogon Packages]#multipath start
查看多路径所产生的磁盘并获取其WWID,为配置Multipath.conf做准备;
[root@bogon Packages]# fdisk -l | grep " 10.7 GB"
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdd: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdh: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdj: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdk: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdl: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdn: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdo: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sdp: 10.7 GB, 10737418240 bytes, 20971520 sectors
[root@bogon Packages]# fdisk -l | grep " 21.5 GB"
Disk /dev/sde: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdi: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdm: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdq: 21.5 GB, 21474836480 bytes, 41943040 sectors
[root@bogon Packages]# ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx. 1 root root 9 Jun 9 11:09 ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001 -> ../../sr0
lrwxrwxrwx. 1 root root 10 Jun 9 11:09 dm-name-rhel-root -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Jun 9 11:09 dm-name-rhel-swap -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Jun 9 11:09 dm-uuid-LVM-lqbtrHjC1YDN1WRYptlr8UJDHwBSKqgAgdEPZJZeAyoqfX9sJjEm7gO9aIji71Gb -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Jun 9 11:09 dm-uuid-LVM-lqbtrHjC1YDN1WRYptlr8UJDHwBSKqgAweG1tRVIKfpakJ0csD3TE1coXJbDB8r2 -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Jun 9 11:09 lvm-pv-uuid-JuUZYx-8bPC-zoP1-4riV-qVxw-4qhJ-2ddb6j -> ../../sda2
lrwxrwxrwx. 1 root root 9 Jun 9 11:23 scsi-14f504e46494c45524e77537957762d34737a312d4d716339 -> ../../sdn
lrwxrwxrwx. 1 root root 9 Jun 9 11:23 scsi-14f504e46494c4552554c536b71612d474539552d4942357a -> ../../sdo
lrwxrwxrwx. 1 root root 9 Jun 9 11:23 scsi-14f504e46494c45526a33566a58622d6b6d4b562d73776f64 -> ../../sdq
lrwxrwxrwx. 1 root root 9 Jun 9 11:23 scsi-14f504e46494c45527748533276382d707978772d686c7a43 -> ../../sdp
[root@bogon Packages]#multipath -v3
..........
14f504e46494c45524e77537957762d34737a312d4d716339 33:0:0:0 sdb 8:16 1 undef
14f504e46494c4552554c536b71612d474539552d4942357a 33:0:0:1 sdc 8:32 1 undef
14f504e46494c45527748533276382d707978772d686c7a43 33:0:0:2 sdd 8:48 1 undef
14f504e46494c45526a33566a58622d6b6d4b562d73776f64 33:0:0:3 sde 8:64 1 undef
14f504e46494c45524e77537957762d34737a312d4d716339 34:0:0:0 sdf 8:80 1 undef
14f504e46494c4552554c536b71612d474539552d4942357a 34:0:0:1 sdg 8:96 1 undef
14f504e46494c45527748533276382d707978772d686c7a43 34:0:0:2 sdh 8:112 1 undef
14f504e46494c45526a33566a58622d6b6d4b562d73776f64 34:0:0:3 sdi 8:128 1 undef
14f504e46494c45524e77537957762d34737a312d4d716339 35:0:0:0 sdj 8:144 1 undef
14f504e46494c4552554c536b71612d474539552d4942357a 35:0:0:1 sdk 8:160 1 undef
14f504e46494c45527748533276382d707978772d686c7a43 35:0:0:2 sdl 8:176 1 undef
14f504e46494c45526a33566a58622d6b6d4b562d73776f64 35:0:0:3 sdm 8:192 1 undef
14f504e46494c45524e77537957762d34737a312d4d716339 36:0:0:0 sdn 8:208 1 undef
14f504e46494c4552554c536b71612d474539552d4942357a 36:0:0:1 sdo 8:224 1 undef
14f504e46494c45527748533276382d707978772d686c7a43 36:0:0:2 sdp 8:240 1 undef
14f504e46494c45526a33566a58622d6b6d4b562d73776f64 36:0:0:3 sdq 65:0 1 undef
在此上面的查找WWID,可以识别为:
14f504e46494c45524e77537957762d34737a312d4d716339 sdb sdf sdj sdn 10.7GB
14f504e46494c4552554c536b71612d474539552d4942357a sdc sdg sdk sdo 10.7GB
14f504e46494c45527748533276382d707978772d686c7a43 sdd sdh sdl sdp 10.7GB
14f504e46494c45526a33566a58622d6b6d4b562d73776f64 sde sdi sdm sdq 21.5GB
紧接着就可以配置Multipath.conf配置文件了;
[root@bogon Packages]# vi /etc/multipath.conf
defaults {
user_friendly_names yes
find_multipaths yes
}
#blacklist {
# wwid 26353900f02796769
# devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
# devnode "^hd[a-z]"
#}
multipaths {
multipath {
wwid 14f504e46494c45524e77537957762d34737a312d4d716339
alias oracle-grid
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c4552554c536b71612d474539552d4942357a
alias oracle-sys
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c45527748533276382d707978772d686c7a43
alias oracle-arch
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c45526a33566a58622d6b6d4b562d73776f64
alias oracle-data
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
}
devices {
device {
vendor "openfiler"
product "virtual-disk"
path_grouping_policy multibus
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
failback 15
rr_weight priorities
no_path_retry queue
}
}
配置完成后重新启动Multipath并检查是否正常;
[root@bogon Packages]# multipath stop
[root@bogon Packages]# multipath start
[root@bogon Packages]# multipath -F
[root@bogon Packages]# multipath -v2
create: oracle-grid (14f504e46494c45524e77537957762d34737a312d4d716339) undef OPNFILER,VIRTUAL-DISK
size=10G features='0' hwhandler='0' wp=undef
`-+- policy='round-robin 0' prio=1 status=undef
|- 33:0:0:0 sdb 8:16 undef ready running
|- 34:0:0:0 sdf 8:80 undef ready running
|- 35:0:0:0 sdj 8:144 undef ready running
`- 36:0:0:0 sdn 8:208 undef ready running
create: oracle-sys (14f504e46494c4552554c536b71612d474539552d4942357a) undef OPNFILER,VIRTUAL-DISK
size=10G features='0' hwhandler='0' wp=undef
`-+- policy='round-robin 0' prio=1 status=undef
|- 33:0:0:1 sdc 8:32 undef ready running
|- 34:0:0:1 sdg 8:96 undef ready running
|- 35:0:0:1 sdk 8:160 undef ready running
`- 36:0:0:1 sdo 8:224 undef ready running
create: oracle-arch (14f504e46494c45527748533276382d707978772d686c7a43) undef OPNFILER,VIRTUAL-DISK
size=10G features='0' hwhandler='0' wp=undef
`-+- policy='round-robin 0' prio=1 status=undef
|- 33:0:0:2 sdd 8:48 undef ready running
|- 34:0:0:2 sdh 8:112 undef ready running
|- 35:0:0:2 sdl 8:176 undef ready running
`- 36:0:0:2 sdp 8:240 undef ready running
create: oracle-data (14f504e46494c45526a33566a58622d6b6d4b562d73776f64) undef OPNFILER,VIRTUAL-DISK
size=20G features='0' hwhandler='0' wp=undef
`-+- policy='round-robin 0' prio=1 status=undef
|- 33:0:0:3 sde 8:64 undef ready running
|- 34:0:0:3 sdi 8:128 undef ready running
|- 35:0:0:3 sdm 8:192 undef ready running
`- 36:0:0:3 sdq 65:0 undef ready running
[root@bogon Packages]# multipath -ll
oracle-sys (14f504e46494c4552554c536b71612d474539552d4942357a) dm-3 OPNFILER,VIRTUAL-DISK
size=10G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:1 sdc 8:32 active ready running
|- 34:0:0:1 sdg 8:96 active ready running
|- 35:0:0:1 sdk 8:160 active ready running
`- 36:0:0:1 sdo 8:224 active ready running
oracle-data (14f504e46494c45526a33566a58622d6b6d4b562d73776f64) dm-5 OPNFILER,VIRTUAL-DISK
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:3 sde 8:64 active ready running
|- 34:0:0:3 sdi 8:128 active ready running
|- 35:0:0:3 sdm 8:192 active ready running
`- 36:0:0:3 sdq 65:0 active ready running
oracle-arch (14f504e46494c45527748533276382d707978772d686c7a43) dm-4 OPNFILER,VIRTUAL-DISK
size=10G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:2 sdd 8:48 active ready running
|- 34:0:0:2 sdh 8:112 active ready running
|- 35:0:0:2 sdl 8:176 active ready running
`- 36:0:0:2 sdp 8:240 active ready running
oracle-grid (14f504e46494c45524e77537957762d34737a312d4d716339) dm-2 OPNFILER,VIRTUAL-DISK
size=10G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:0 sdb 8:16 active ready running
|- 34:0:0:0 sdf 8:80 active ready running
|- 35:0:0:0 sdj 8:144 active ready running
`- 36:0:0:0 sdn 8:208 active ready running
检查相应的多路径对应是否正常;
[root@bogon Packages]# cd /dev/mapper/
[root@bogon mapper]# ls -lsa
total 0
0 drwxr-xr-x. 2 root root 180 Jun 9 12:05 .
0 drwxr-xr-x. 20 root root 3940 Jun 9 12:05 ..
0 crw-------. 1 root root 10, 236 Jun 9 11:09 control
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:05 oracle-arch -> ../dm-4
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:05 oracle-data -> ../dm-5
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:05 oracle-grid -> ../dm-2
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:05 oracle-sys -> ../dm-3
0 lrwxrwxrwx. 1 root root 7 Jun 9 11:09 rhel-root -> ../dm-0
0 lrwxrwxrwx. 1 root root 7 Jun 9 11:09 rhel-swap -> ../dm-1
格式化相应的磁盘,为后续ASM磁盘使用;
[root@bogon mapper]# fdisk -c /dev/mapper/oracle-arch
[root@bogon mapper]# fdisk -c /dev/mapper/oracle-data
[root@bogon mapper]# fdisk -c /dev/mapper/oracle-grid
[root@bogon mapper]# fdisk -c /dev/mapper/oracle-sys
[root@bogon mapper]# kpartx -a /dev/mapper/oracle-arch
[root@bogon mapper]# kpartx -a /dev/mapper/oracle-sys
[root@bogon mapper]# kpartx -a /dev/mapper/oracle-data
[root@bogon mapper]# kpartx -a /dev/mapper/oracle-grid
[root@bogon mapper]# ls -lsa
total 0
0 drwxr-xr-x. 2 root root 260 Jun 9 12:22 .
0 drwxr-xr-x. 20 root root 4020 Jun 9 12:22 ..
0 crw-------. 1 root root 10, 236 Jun 9 11:09 control
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:16 oracle-arch -> ../dm-4
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:21 oracle-arch1 -> ../dm-6
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:17 oracle-data -> ../dm-5
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:22 oracle-data1 -> ../dm-8
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:17 oracle-grid -> ../dm-2
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:22 oracle-grid1 -> ../dm-9
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:17 oracle-sys -> ../dm-3
0 lrwxrwxrwx. 1 root root 7 Jun 9 12:22 oracle-sys1 -> ../dm-7
0 lrwxrwxrwx. 1 root root 7 Jun 9 11:09 rhel-root -> ../dm-0
0 lrwxrwxrwx. 1 root root 7 Jun 9 11:09 rhel-swap -> ../dm-1