linux 多路径软件DM multipath的安装和测试

多路径软件是为了解决单路径一对一的单点故障而研发的,实现由主机到存储的多条链路通讯。如果存储服务器到主机或是交换机只有一条线路的时候,当这条线路出现故障时,整个系统就无法使用,所以使用多路径可以解决这个问题,避免点单故障。
多路径软件主要是配合存储一起使用,实现故障切换和恢复、IO流量负载均衡和硬盘的虚拟 化操作。
在做DM multipath测试前需要配置存储,在这里我们使用上章节博客写的IP SAN存储设备。

测试服务器如下,另外需要安装DM multipath 多路径套件( device-mapper-multipath )
服务名称 服务器地址
服务端 :node01 192.168.137.101
客户端 :node02
192.168.137.102

使用vmvare模拟多路径,我们需要为虚拟机配置两张网卡,实现互通。在这里我们将node01配置服务端,将/dev/sdb1 通过ip scan共享。

在博客 http://blog.itpub.net/27039319/viewspace-2123341/ 基础上编辑/etc/tgt/targets.conf文件,增加新建立网卡地址192.168.20.XXX。内容如下
1.修改服务端node01的tgt服务

点击(此处)折叠或打开

  1. [root@node01 network-scripts]# vi /etc/tgt/targets.conf 
  2. backing-store /dev/sdb1
  3. initiator-address 192.168.137.102
  4. initiator-address 192.168.20.102
  5. vendor_id node
  6. product_id target4
  7. [root@node01 network-scripts]# service tgtd restart
    Stopping SCSI target daemon:                               [  OK  ]
    Starting SCSI target daemon:                               [  OK  ]
  8. [root@node01 ~]# tgt-admin  -show
    Target 1: iqn.2016-08.cn.node01.www:target4_scan
        System information:
            Driver: iscsi
            State: ready
        I_T nexus information:
        LUN information:
            LUN: 0
                Type: controller
                SCSI ID: IET     00010000
                SCSI SN: beaf10
                Size: 0 MB, Block size: 1
                Online: Yes
                Removable media: No
                Prevent removal: No
                Readonly: No
                Backing store type: null
                Backing store path: None
                Backing store flags: 
            LUN: 1
                Type: disk
                SCSI ID: IET     00010001
                SCSI SN: beaf11
                Size: 5379 MB, Block size: 512
                Online: Yes
                Removable media: No
                Prevent removal: No
                Readonly: No
                Backing store type: rdwr
                Backing store path: /dev/sdb1
                Backing store flags: 
        Account information:
        ACL information:
            192.168.137.102
            192.168.20.102
           
    [root@node01 ~]# 
2. 在客户端node02上增加 192.168.20.101线路,这样就与192.168.137.101 实现双线路

点击(此处)折叠或打开

  1. [root@node02 ~]# iscsiadm -m discovery -t st -p 192.168.20.101:3260    #增加新线路192.168.20.101 ,添加成功
  2. 192.168.20.101:3260,1 iqn.2016-08.cn.node01.www:target4_scan
  3. [root@node02 ~]# lsblk            #查看块信息 并无其他新信息
  4. NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0   20G  0 disk 
    ├─sda1   8:1    0  200M  0 part /boot
    ├─sda2   8:2    0   10G  0 part /
    └─sda3   8:3    0    1G  0 part [SWAP]
    sr0     11:0    1  3.6G  0 rom  
    sdb      8:16   0    5G  0 disk 
    └─sdb1   8:17   0    5G  0 part 
  5. [root@node02 ~]# tree /var/lib/iscsi/         #查看/var/lib/iscsi 目录信息,发现新增加的192.168.20.101线路信息
  6. /var/lib/iscsi/
    ├── ifaces
    ├── isns
    ├── nodes
    │   └── iqn.2016-08.cn.node01.www:target4_scan
    │       ├── 192.168.137.101,3260,1
    │       │   └── default
    │       └── 192.168.20.101,3260,1
    │           └── default
    ├── send_targets
    │   ├── 192.168.137.101,3260
    │   │   ├── iqn.2016-08.cn.node01.www:target4_scan,192.168.137.101,3260,1,default -> /var/lib/iscsi/nodes/iqn.2016-08.cn.node01.www:target4_scan/192.168.137.101,3260,1
    │   │   └── st_config
    │   └── 192.168.20.101,3260
    │       ├── iqn.2016-08.cn.node01.www:target4_scan,192.168.20.101,3260,1,default -> /var/lib/iscsi/nodes/iqn.2016-08.cn.node01.www:target4_scan/192.168.20.101,3260,1
    │       └── st_config
    ├── slp
    └── static

  7. 13 directories, 4 files
  8. [root@node02 ~]# /etc/init.d/iscsi restart               #restart iscsi服务
  9. Stopping iscsi: [ OK ]
  10. Starting iscsi: [ OK ]
  11. [root@node02 ~]# lsblk                                   #未分区,就看到新增 sdc1
  12. NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0   20G  0 disk 
    ├─sda1   8:1    0  200M  0 part /boot
    ├─sda2   8:2    0   10G  0 part /
    └─sda3   8:3    0    1G  0 part [SWAP]
    sr0     11:0    1  3.6G  0 rom  
    sdb      8:16   0    5G  0 disk 
    └─sdb1   8:17   0    5G  0 part 
    sdc      8:32   0    5G  0 disk 
    └─sdc1   8:33   0    5G  0 part 

  13. [root@node02 opt]# mount /dev/sdc1 /opt/
    [root@node02 opt]# ll
    total 0
    [root@node02 opt]# cd /opt/               #挂载sdc1 可以看到上面博客中提到的信息。在node03上写入的passwd 文件
    [root@node02 opt]# ll
    total 40
    -rw------- 1 root root   980 Aug 12 00:59 anaconda-ks.cfg
    -rw-r--r-- 1 root root 10197 Aug 12 00:59 install.log
    -rw-r--r-- 1 root root  3161 Aug 12 00:59 install.log.syslog
    drwx------ 2 root root 16384 Aug 12 00:58 lost+found
    -rw-r--r-- 1 root root   901 Aug 12 01:11 passwd
    [root@node02 opt]# 

  14. [root@node02 ~]#
  15. ########在服务端查看3260端口信息 发现新线路192.168.20.101 #######
  16. [root@node01 ~]# netstat -antup |grep 3260
    tcp        0      0 0.0.0.0:3260                0.0.0.0:*                   LISTEN      1028/tgtd           
    tcp        0      0 192.168.137.101:3260        192.168.137.102:58788       ESTABLISHED 1028/tgtd           
    tcp        0      0 192.168.20.101:3260         192.168.20.102:57592        ESTABLISHED 1028/tgtd           
    tcp        0      0 :::3260                     :::*                        LISTEN      1028/tgtd           
    [root@node01 ~]# 

3 配置multipath 多路径软件,配置多路径冗余模式

点击(此处)折叠或打开

  1. [root@node02 opt]# yum -y install device-mapper-multipath                  #安装软件
  2. [root@node02 opt]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/        #默认情况下 无配置文件的。需要从/usr/share/doc/目录下拷贝
  3. [root@node02 opt]# /etc/init.d/multipathd restart                          #启动软件
  4. ux_socket_connect: No such file or directory
  5. Stopping multipathd daemon: [FAILED]
  6. Starting multipathd daemon: [ OK ]
  7. [root@node02 opt]#
  8. [root@node02 opt]# multipath -ll                                          #未发现多路径信息  这里需要把原有mount的卸载  
  9. [root@node02 opt]#
  10. [root@node02 opt]# umount /opt/
  11. umount: /opt: device is busy.
  12. (In some cases useful info about processes that use
  13. the device is found by lsof(8) or fuser(1))
  14. [root@node02 opt]# cd
  15. [root@node02 ~]# umount /opt/
  16. [root@node02 ~]# multipath -ll
  17. [root@node02 ~]# /etc/init.d/multipathd restart                          #卸载后重启  发现多路径信息
  18. ok
  19. Stopping multipathd daemon: [ OK ]
  20. Starting multipathd daemon: [ OK ]
  21. [root@node02 ~]# multipath -ll
  22. mpatha (1IET 00010001) dm-0 node,target4                        #'1IET 00010001'表示远程设备信息 dm-0  node 表示厂商  target4 产品信息  这种情况就可以实现单点故障切换
  23. size=5.0G features='0' hwhandler='0' wp=rw
  24. |-+- policy='round-robin 0' prio=1 status=active                #status=active  默认使用的链路
  25. | `- 36:0:0:1 sdb 8:16 active ready running
  26. `-+- policy='round-robin 0' prio=1 status=enabled               #status=enabled 有效链路,但是不是活动链路   
  27. `- 35:0:0:1 sdc 8:32 active ready running
  28. [root@node02 ~]#
  29. [root@node02 ~]# ll /dev/mapper/                                #设备文件 /dev/mapper/mpatha ,生成dm设备
  30. total 0
  31. crw-rw---- 1 root root 10, 57 Aug 12 17:26 control
  32. lrwxrwxrwx 1 root root 7 Aug 12 18:36 mpatha -> ../dm-0
  33. lrwxrwxrwx 1 root root 7 Aug 12 18:36 mpathap1 -> ../dm-1
  34. [root@node02 ~]# mount /dev/mapper/mpathap1 /opt/               #挂载mpathap1  存储可用
  35. [root@node02 ~]# ll !$
  36. ll /opt/
  37. total 40
  38. -rw------- 1 root root 980 Aug 12 00:59 anaconda-ks.cfg
  39. -rw-r--r-- 1 root root 10197 Aug 12 00:59 install.log
  40. -rw-r--r-- 1 root root 3161 Aug 12 00:59 install.log.syslog
  41. drwx------ 2 root root 16384 Aug 12 00:58 lost+found
  42. -rw-r--r-- 1 root root 901 Aug 12 01:11 passwd
  43. [root@node02 opt]# rm passwd 
    rm: remove regular file `passwd'? yes
    [root@node02 opt]# ll
    total 36
    -rw------- 1 root root   980 Aug 12 00:59 anaconda-ks.cfg
    -rw-r--r-- 1 root root 10197 Aug 12 00:59 install.log
    -rw-r--r-- 1 root root  3161 Aug 12 00:59 install.log.syslog
    drwx------ 2 root root 16384 Aug 12 00:58 lost+found
    [root@node02 opt]# 
4. 配置负载模式 编辑 /etc/multipath . conf 文件,修改如下信息

点击(此处)折叠或打开

  1. [root@node02 opt]# vim /etc/multipath.conf
  2. multipaths {
  3.         multipath {
  4.                 wwid "1IET 00010001"                        #wwid 可以通过scsi_id生成  同时也multipath -ll 看到 mpatha (1IET     00010001) 远程存储信息
  5.                 alias yellow                                #dm 别名 ,可以随便修改
  6.                 path_grouping_policy multibus
  7.                 path_checker readsector0
  8.                 path_selector "round-robin 0"
  9.                 failback manual
  10.                 rr_weight priorities                        #权重信息
  11.                 no_path_retry 5
  12.         }
  13. }
  14. [root@node02 ~]# /lib/udev/scsi_id  --page=0x83 --whitelisted --device=/dev/sdb  #生成wwid
    1IET     00010001
    [root@node02 ~]# /lib/udev/scsi_id  --page=0x83 --whitelisted --device=/dev/sdc
    1IET     00010001
    [root@node02 ~]# multipath -ll
    Aug 12 19:26:35 | multipath.conf line 67, invalid keyword: path_checker
    mpatha (1IET     00010001) dm-0 node,target4
    size=5.0G features='0' hwhandler='0' wp=rw
    |-+- policy='round-robin 0' prio=1 status=active
    | `- 36:0:0:1 sdb 8:16 active ready running
    `-+- policy='round-robin 0' prio=1 status=enabled
      `- 35:0:0:1 sdc 8:32 active ready running
    [root@node02 ~]# 
  15. [root@node02 opt]# /etc/init.d/multipathd  restart      #重启multipath服务
    ok
    Stopping multipathd daemon:                                [  OK  ]
    Starting multipathd daemon:                                [  OK  ]
    [root@node02 opt]# /etc/init.d/iscsi restart            #重启  识别scsi
    Stopping iscsi:                                            [  OK  ]
    Starting iscsi:                                            [  OK  ]
    [root@node02 opt]# multipath -ll
    Aug 12 20:05:52 | multipath.conf line 67, invalid keyword: path_checker
    yellow (1IET     00010001) dm-0 node,target4
    size=5.0G features='1 queue_if_no_path' hwhandler='0' wp=rw
    `-+- policy='round-robin 0' prio=1 status=active            #启用负载均衡模式
      |- 38:0:0:1 sdb 8:16 active ready running
      `- 37:0:0:1 sdc 8:32 active ready running
    [root@node02 opt]# 
  16. [root@node02 opt]# ll /dev/mapper/                          #查看/dev/mapper 下的设备信息 由原来的mpathp 变更为multipath.conf 文件中更新的别名 yellow了
    total 0
    crw-rw---- 1 root root 10, 57 Aug 12 17:26 control
    lrwxrwxrwx 1 root root      7 Aug 12 20:05 yellow -> ../dm-0
    lrwxrwxrwx 1 root root      7 Aug 12 20:05 yellowp1 -> ../dm-1
    [root@node02 ~]# umount /opt/
    [root@node02 ~]# mount /dev/mapper/yellowp1 /opt/           #重新挂载dm
    [root@node02 ~]# cd !$
    cd /opt/
    [root@node02 opt]# ll
    total 40
    -rw------- 1 root root   980 Aug 12 00:59 anaconda-ks.cfg
    -rw-r--r-- 1 root root 10197 Aug 12 00:59 install.log
    -rw-r--r-- 1 root root  3161 Aug 12 00:59 install.log.syslog
    drwx------ 2 root root 16384 Aug 12 00:58 lost+found
    -rw-r--r-- 1 root root   901 Aug 12 20:08 passwd
    [root@node02 opt]# 
5. 模拟故障 ,分别关闭网卡eth0和eth1  看看链路高可用性,切换过程大概需要1分钟时间

点击(此处)折叠或打开

  1. [root@node01 ~]# ifdown eth1
  2. [root@node01 ~]#

  3. [root@node02 opt]# multipath -ll
  4. Aug 12 20:16:57 | multipath.conf line 67, invalid keyword: path_checker
  5. yellow (1IET 00010001) dm-0 node,target4
  6. size=5.0G features='1 queue_if_no_path' hwhandler='0' wp=rw
  7. `-+- policy='round-robin 0' prio=1 status=active 
  8. |- 38:0:0:1 sdb 8:16 failed faulty running                                          #状态改变
  9. `- 37:0:0:1 sdc 8:32 active ready running
  10. [root@node02 opt]# ll
  11. total 40
  12. -rw------- 1 root root 980 Aug 12 00:59 anaconda-ks.cfg
  13. -rw-r--r-- 1 root root 10197 Aug 12 00:59 install.log
  14. -rw-r--r-- 1 root root 3161 Aug 12 00:59 install.log.syslog
  15. drwx------ 2 root root 16384 Aug 12 00:58 lost+found
  16. -rw-r--r-- 1 root root 901 Aug 12 20:08 passwd
  17. [root@node02 opt]# cp /etc/localtime /opt/                                          #测试写入  正常
  18. [root@node02 opt]# ll
  19. total 44
  20. -rw------- 1 root root 980 Aug 12 00:59 anaconda-ks.cfg
  21. -rw-r--r-- 1 root root 10197 Aug 12 00:59 install.log
  22. -rw-r--r-- 1 root root 3161 Aug 12 00:59 install.log.syslog
  23. -rw-r--r-- 1 root root 405 Aug 12 20:17 localtime
  24. drwx------ 2 root root 16384 Aug 12 00:58 lost+found
  25. -rw-r--r-- 1 root root 901 Aug 12 20:08 passwd


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27039319/viewspace-2123385/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27039319/viewspace-2123385/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值