linux multiple path test

1.参考之前  https://blog.csdn.net/aryoyo/article/details/80706354  ISCSI配置,ISCSI initiator识别target不同ip但同一块disk

[root@oc7067507274 send_targets]# iscsiadm -m node -T iqn.2018-06.com.redhat:yo1disk -p192.168.122.198 --login
Logging in to [iface: default, target: iqn.2018-06.com.redhat:yo1disk, portal: 192.168.122.198,3260] (multiple)
Login to [iface: default, target: iqn.2018-06.com.redhat:yo1disk, portal: 192.168.122.198,3260] successful.

[root@oc7067507274 send_targets]# iscsiadm -m node -T iqn.2018-06.com.redhat:yo1disk -p192.168.122.199 --login
Logging in to [iface: default, target: iqn.2018-06.com.redhat:yo1disk, portal: 192.168.122.199,3260] (multiple)
Login to [iface: default, target: iqn.2018-06.com.redhat:yo1disk, portal: 192.168.122.199,3260] successful.

2.在initiator上查看识别到的盘为 /dev/sdb 和 /dev/sdc

[root@oc7067507274 send_targets]# lsscsi
[0:0:0:0]    disk    Generic- SD/MMC           1.00  /dev/sda 
[7:0:0:0]    storage IET      Controller       0001  -        
[7:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb 
[8:0:0:0]    storage IET      Controller       0001  -        
[8:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdc 
[root@oc7067507274 send_targets]# udevadm info -q path -n /dev/sdb
/devices/platform/host7/session7/target7:0:0/7:0:0:1/block/sdb

[root@oc7067507274 send_targets]# udevadm info -q env -p /devices/platform/host7/session7/target7:0:0/7:0:0:1/block/sdb
DEVLINKS=/dev/disk/by-id/scsi-360000000000000000e00000000010001 /dev/disk/by-id/wwn-0x60000000000000000e00000000010001 /dev/disk/by-path/ip-192.168.122.198:3260-iscsi-iqn.2018-06.com.redhat:yo1disk-lun-1
DEVNAME=/dev/sdb
DEVPATH=/devices/platform/host7/session7/target7:0:0/7:0:0:1/block/sdb
DEVTYPE=disk
ID_BUS=scsi
ID_MODEL=VIRTUAL-DISK
ID_MODEL_ENC=VIRTUAL-DISK
ID_PATH=ip-192.168.122.198:3260-iscsi-iqn.2018-06.com.redhat:yo1disk-lun-1
ID_PATH_TAG=ip-192_168_122_198_3260-iscsi-iqn_2018-06_com_redhat_yo1disk-lun-1
ID_REVISION=0001
ID_SCSI=1
ID_SCSI_SERIAL=beaf11
ID_SERIAL=360000000000000000e00000000010001
ID_SERIAL_SHORT=60000000000000000e00000000010001
ID_TYPE=disk
ID_VENDOR=IET
ID_VENDOR_ENC=IET\x20\x20\x20\x20\x20
ID_WWN=0x6000000000000000
ID_WWN_VENDOR_EXTENSION=0x0e00000000010001
ID_WWN_WITH_EXTENSION=0x60000000000000000e00000000010001
MAJOR=8
MINOR=16
MPATH_SBIN_PATH=/sbin
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=123252924


[root@oc7067507274 send_targets]# udevadm info -q path -n /dev/sdc
/devices/platform/host8/session8/target8:0:0/8:0:0:1/block/sdc
[root@oc7067507274 send_targets]# udevadm info -q env -p /devices/platform/host8/session8/target8:0:0/8:0:0:1/block/sdc
DEVLINKS=/dev/disk/by-id/scsi-360000000000000000e00000000010001 /dev/disk/by-id/wwn-0x60000000000000000e00000000010001 /dev/disk/by-path/ip-192.168.122.199:3260-iscsi-iqn.2018-06.com.redhat:yo1disk-lun-1
DEVNAME=/dev/sdc
DEVPATH=/devices/platform/host8/session8/target8:0:0/8:0:0:1/block/sdc
DEVTYPE=disk
ID_BUS=scsi
ID_MODEL=VIRTUAL-DISK
ID_MODEL_ENC=VIRTUAL-DISK
ID_PATH=ip-192.168.122.199:3260-iscsi-iqn.2018-06.com.redhat:yo1disk-lun-1
ID_PATH_TAG=ip-192_168_122_199_3260-iscsi-iqn_2018-06_com_redhat_yo1disk-lun-1
ID_REVISION=0001
ID_SCSI=1
ID_SCSI_SERIAL=beaf11
ID_SERIAL=360000000000000000e00000000010001
ID_SERIAL_SHORT=60000000000000000e00000000010001
ID_TYPE=disk
ID_VENDOR=IET
ID_VENDOR_ENC=IET\x20\x20\x20\x20\x20
ID_WWN=0x6000000000000000
ID_WWN_VENDOR_EXTENSION=0x0e00000000010001
ID_WWN_WITH_EXTENSION=0x60000000000000000e00000000010001
MAJOR=8
MINOR=32
MPATH_SBIN_PATH=/sbin
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=129511711

ll /dev/disk/by-path
也能查看disk的来源

3.安装和配置multiple path文件:

[root@oc7067507274 send_targets]# multipath -ll
May 17 15:33:11 | DM multipath kernel driver not loaded
May 17 15:33:11 | /etc/multipath.conf does not exist, blacklisting all devices.
May 17 15:33:11 | A default multipath.conf file is located at
May 17 15:33:11 | /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
May 17 15:33:11 | You can run /sbin/mpathconf --enable to create
May 17 15:33:11 | /etc/multipath.conf. See man mpathconf(8) for more details
May 17 15:33:11 | DM multipath kernel driver not loaded
[root@oc7067507274 send_targets]# 

[root@oc7067507274 send_targets]# modprobe dm-multipath
[root@oc7067507274 send_targets]# lsmod |grep -i mult
dm_multipath           27792  0 

/etc/multipath.conf  
blacklist {
devnode "^sda"
}

defaults {
user_friendly_names yes
path_grouping_policy multibus
failback immediate
no_path_retry fail
}


[root@oc7067507274 etc]# systemctl start multipathd
[root@oc7067507274 etc]# systemctl status multipathd
● multipathd.service - Device-Mapper Multipath Device Controller
   Loaded: loaded (/usr/lib/systemd/system/multipathd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-05-17 16:06:12 CST; 2s ago
  Process: 25564 ExecStart=/sbin/multipathd (code=exited, status=0/SUCCESS)
  Process: 25560 ExecStartPre=/sbin/multipath -A (code=exited, status=0/SUCCESS)
  Process: 25555 ExecStartPre=/sbin/modprobe dm-multipath (code=exited, status=0/SUCCESS)
 Main PID: 25567 (multipathd)
    Tasks: 7
   CGroup: /system.slice/multipathd.service
           └─25567 /sbin/multipathd


[root@oc7067507274 etc]# lsblk
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sdb                                             8:16   0   200M  1 disk  
└─mpathb                                      253:3    0   200M  1 mpath 
sdc                                             8:32   0   200M  1 disk  
└─mpathb                                      253:3    0   200M  1 mpath 

[root@oc7067507274 mapper]# ll -h
total 0
crw-------. 1 root root 10, 236 May 17 10:20 control
lrwxrwxrwx. 1 root root       7 May 17 10:20 luks-a8057c53-b197-4918-a975-0656396b0c43 -> ../dm-0
lrwxrwxrwx. 1 root root       7 May 17 16:41 mpathb -> ../dm-3
lrwxrwxrwx. 1 root root       7 May 17 10:20 vg_oc3573808223-lv_root -> ../dm-2
lrwxrwxrwx. 1 root root       7 May 17 10:20 vg_oc3573808223-lv_swap -> ../dm-1

4.multipath -F

   multipath -ll

 使用有点问题..未完待续

[root@oc7067507274 mapper]# fdisk /dev/mapper/mpathb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xf75bd564.

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-409599, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-409599, default 409599): 
Using default value 409599
Partition 1 of type Linux and of size 199 MiB is set

Command (m for help): w
fdisk: cannot write disk label: Operation not permitted


[root@oc7067507274 mapper]# dd if=/dev/zero of=/dev/mapper/mpathb
dd: writing to ‘/dev/mapper/mpathb’: Operation not permitted
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.00190835 s, 0.0 kB/s

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值