欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

配置Multipath多路径环境

程序员文章站 2022-06-01 10:30:10
...

环境介绍:

在ISCSI服务基础上修改配置实现Multipath多路径环境

ISCSI服务配置中Server eth0:192.168.4.101 Client eth0:192.168.4.102

Multipath中需要在Server和Client中再添加一块网卡eth1

Server eth1:192.168.2.101 Client eth0:192.168.2.102

1、Server端修改ISCSI的ACL配置,增加192.168.2.102的允许权限

[[email protected] ~]# tail -5 /etc/tgt/targets.conf 
<target iqn.2018-04.com.example.node1:server.target1>
	backing-store /dev/sda1
	initiator-address 192.168.4.102
	initiator-address 192.168.2.102
</target>

2、Client端通过192.169.2.101发现Server共享

[[email protected] ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.2.101 --discover

3、重启ISCSI服务,发现有两条路径连接到Server的共享存储

[[email protected] ~]# /etc/init.d/iscsi restart
停止 iscsi:                                               [确定]
正在启动 iscsi:                                           [确定]
[[email protected] ~]# lsblk 
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                          11:0    1 1024M  0 rom  
vda                         252:0    0   50G  0 disk 
├─vda1                      252:1    0  500M  0 part /boot
└─vda2                      252:2    0 49.5G  0 part 
  ├─VolGroup-lv_root (dm-0) 253:0    0 47.6G  0 lvm  /
  └─VolGroup-lv_swap (dm-1) 253:1    0    2G  0 lvm  [SWAP]
sdb                           8:16   0   20G  0 disk 
└─sdb1                        8:17   0  976M  0 part 
sdc                           8:32   0   20G  0 disk 
└─sdc1                        8:33   0  976M  0 part 

4、安装device-mapper-multipath

[[email protected] ~]# yum -y install device-mapper-multipath

5、关闭为共享存储自动命名的功能,并生成配置文件

[[email protected] ~]# mpathconf --user_friendly_names n
[[email protected] ~]# ls /etc/multipath.conf
/etc/multipath.conf

6、查看已连接的共享设备的wwid,确认设置多路径的两个目标存储设备为同一设备

[[email protected] ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdb
1IET     00010001
[[email protected] ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdc
1IET     00010001

7、修改配置文件,启动服务

[[email protected] ~]# sed -n '25,28p;102,107p' /etc/multipath.conf 
defaults {
	user_friendly_names no
	getuid_callout          "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
}
multipaths {
       multipath {
               wwid                    "1IET     00010001"
               alias                   mpa
       }
}
[[email protected] ~]# /etc/init.d/multipathd start;chkconfig multipathd on
[[email protected] ~]# ls /dev/mapper/    ##查看Multipath共享设备的别名
control  mpa  mpap1  VolGroup-lv_root  VolGroup-lv_swap

8、重启ISCSI服务查看磁盘情况

[[email protected] ~]# /etc/init.d/iscsi restar
停止 iscsi:                                               [确定]
正在启动 iscsi:                                           [确定]
[[email protected] ~]# lsblk 
NAME                        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sr0                          11:0    1 1024M  0 rom   
vda                         252:0    0   50G  0 disk  
├─vda1                      252:1    0  500M  0 part  /boot
└─vda2                      252:2    0 49.5G  0 part  
  ├─VolGroup-lv_root (dm-0) 253:0    0 47.6G  0 lvm   /
  └─VolGroup-lv_swap (dm-1) 253:1    0    2G  0 lvm   [SWAP]
sdc                           8:32   0   20G  0 disk  
└─mpa (dm-2)                253:2    0   20G  0 mpath 
  └─mpap1 (dm-3)            253:3    0  976M  0 part  /var/lib/mysql
sdb                           8:16   0   20G  0 disk  
└─mpa (dm-2)                253:2    0   20G  0 mpath 
  └─mpap1 (dm-3)            253:3    0  976M  0 part  /var/lib/mysql

9、挂载Multipath共享存储到mysql应用数据目录,也可以把挂载工作写到/etc/fstab实现开机自动挂载

[[email protected] ~]# mount /dev/mapper/mpap1 /var/lib/mysql/