We used two CentOS 7 VMs to configure the Set up an iSCSI Target and Initiator and configure multipath settings.
network-vm1
Network1 : 10.1.1.11
Network2 : 10.1.2.20
network-vm2
Network1 : 10.1.1.12
Network2 : 10.1.2.21
iSCSI Target Creation
An iSCSI target can be a dedicated physical device in a network, or it can be an iSCSI software-configured logical device on a networked storage server. The target is the end point in SCSI bus communication. Storage on the target, accessed by an initiator, is defined by LUNs.
Login network-vm2 server and install scsi-target-utils.
Install RPEL release repo.
[[email protected] ~]# yum install epel-release -y
[[email protected] ~]# yum install scsi-target-utils -y
Make sure you enabled the port 3260 in firewall.
example in iptables [[email protected] ~]# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT
Start and enable the target service.
[[email protected] ~]# service tgtd start [[email protected] ~]# systemctl enable tgtd
Attach storage for the LUNs and create partition.
[[email protected] ~]# fdisk /dev/sdb 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 0xdd5037ae. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): First sector (2048-104857599, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): Using default value 104857599 Partition 1 type Linux and size 50 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Create the target in /etc/tgt/targets.conf file.
[[email protected] ~]# vi /etc/tgt/targets.conf default-driver iscsi <target iqn.2015-06.com.example.test:target1> backing-store /dev/sdb1 </target>
Restart the target service.
[[email protected] ~]# service tgtd restart Redirecting to /bin/systemctl restart tgtd.service
Verify your configurations.
[[email protected] ~]# tgt-admin --show Target 1: iqn.2017-03.com.apporbit.test:target1 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 SWP: No Thin-provisioning: No Backing store type: null Backing store path: None Backing store flags: LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 53686 MB, Block size: 512 Online: Yes Removable media: No Prevent removal: No Readonly: No SWP: No Thin-provisioning: No Backing store type: rdwr Backing store path: /dev/sdb1 Backing store flags: Account information: ACL information: ALL
Install iSCSI Initiator and configure it
Login your network-vm2 server and Install iscsi-initiator-utils
[[email protected] ~]# yum install iscsi-initiator-utils -y
Discover the target. Use the target’s IP address.
[[email protected] ~]# iscsiadm -m discovery -t sendtargets -p 10.1.1.11 10.1.1.11:3260,1 iqn.2017-03.com.gopal.test:target1 [[email protected] ~]# iscsiadm -m discovery -t sendtargets -p 10.1.2.20 10.1.2.20:3260,1 iqn.2017-03.com.gopal.test:target1
Connect to the target.
[[email protected] ~]# iscsiadm -m node -T iqn.2017-03.com.gopal.test:target1 --login Logging in to [iface: default, target: iqn.2017-03.com.gopal.test:target1, portal: 10.1.1.11,3260] (multiple) Login to [iface: default, target: iqn.2017-03.com.gopal.test:target1, portal: 10.1.1.11,3260] successful. [[email protected] ~]#
Login to all the targets
[[email protected] ~]# iscsiadm -m node -l
Check the list of drives.
[[email protected] ~]# fdisk -l Disk /dev/sdb: 53.7 GB, 53686042624 bytes, 104855552 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
If you want to create a file system and mount.
[[email protected] ~]# mkfs.ext4 /dev/sdb [[email protected] ~]# mount /dev/sdb /opt/iscsi-drive [[email protected] ~]# blkid /dev/sdb /dev/sdb: UUID="3b7e58de-1342-4fbb-98fc-9e5d5888e770" TYPE="ext4"
Configuring Multipath for ISCSI storage LUNS in centos 7
I am using network-vm2 server to configure multipath.
Install multipath packages and start it.
[[email protected] ~]# yum install device-mapper-multipath -y [[email protected] ~]# systemctl start multipathd
Verify the iscsi targets
[[email protected] ~]# iscsiadm -m discovery -t sendtargets -p 10.1.1.11 10.1.1.11:3260,1 iqn.2017-03.com.gopal.test:target1 [[email protected] ~]# iscsiadm -m discovery -t sendtargets -p 10.1.2.20 10.1.2.20:3260,1 iqn.2017-03.com.gopal.test:target1
Login to all the targets
[[email protected] ~]# iscsiadm -m node -l Logging in to [iface: default, target: iqn.2017-03.com.gopal.test:target1, portal: 10.1.2.20,3260] (multiple) Login to [iface: default, target: iqn.2017-03.com.gopal.test:target1, portal: 10.1.2.20,3260] successful.
Configure basic Multipath
[[email protected] ~]# mpathconf --enable --with_multipathd y
add entries
[[email protected] ~]# vi /etc/multipath.conf defaults { polling_interval 10 path_selector "round-robin 0" path_grouping_policy multibus path_checker readsector0 rr_min_io 100 max_fds 8192 rr_weight priorities failback immediate no_path_retry fail user_friendly_names yes }
[[email protected] ~]# multipath -ll mpatha (360000000000000000e00000000010001) dm-2 IET ,VIRTUAL-DISK size=50G features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 3:0:0:1 sdb 8:16 active ready running `- 4:0:0:1 sdc 8:32 active ready running
Adding Target partition to multipath
Adding Multipath Alias for the Iscsi LUNs in /etc/multipath.conf
multipaths { multipath { wwid 360000000000000000e00000000010001 alias LUN0 } }
Restart multipathd service
[[email protected] ~]# systemctl restart multipathd
[[email protected] ~]# multipath -ll LUN0 (360000000000000000e00000000010001) dm-2 IET ,VIRTUAL-DISK size=50G features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 3:0:0:1 sdb 8:16 active ready running `- 4:0:0:1 sdc 8:32 active ready running
check the list of drives
Disk /dev/mapper/LUN0: 53.7 GB, 53686042624 bytes, 104855552 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes