Multipathing is used to detect multiple paths to devices for fail-over or performance reasons and coalesces them.
Prerequisites:
We are configuring multipath through iscsi, before we move ahead you have to setup iscsi first, if you don’t know how to set up it please refer How to setup iSCSI in linux. After you setup iscsi targets we will move ahead and install multipath package. You must set up multiple ip’s to the server and client, you can use different ip subnet. in our scenario we used same ip subnet.
On the initiator you need to install below packages :
# yum install device-mapper-multipath
# yum install iscsi-initiator-utils
Once you install above packages start iscsi service:
# service iscsi start # service iscsid start
Configure it at startup :
# chkconfig iscsid on # chkconfig iscsi on
Discover the exported luns from the server 10.192.8.170 and 10.192.8.171 via iscsiadmin :
# iscsiadm -m discovery -t sendtargets -p 10.192.8.170 # iscsiadm -m discovery -t sendtargets -p 10.192.8.171
Now you have to login to same lun using different IP:
# iscsiadm -m node -T iqn.2016-02.testlab.example:node1.target1 -p 10.192.8.170 -l
# iscsiadm -m node -T iqn.2016-02.testlab.example:node1.target1 -p 10.192.8.171 -l
Now run fdisk -l command which will show you newly added iscsi devices as your local drives ie. /dev/sdc and /dev/sdd.
Edit the /etc/iscsi/iscsid.conf file and configure iscsi for automatic mounting after reboot.
# vi /etc/iscsi/iscsid.conf
Add or un-comment below line
node.startup = automatic
By default there is no file multipath.conf file you have to copy it from the example documents. Copy file from below location and place it to /etc/
cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/
If you don’t have /etc/multipath.conf file. Just Edit /etc/multipath.conf file add below lines to it.
# vi /etc/multipath.conf
defaults { udev_dir /dev polling_interval 10 path_selector "round-robin 0" path_grouping_policy multibus getuid_callout "/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/%n" prio const path_checker directio rr_min_io 100 flush_on_last_del no max_fds 8192 rr_weight priorities failback immediate no_path_retry fail queue_without_daemon no user_friendly_names no mode 644 uid 0 gid disk } blacklist { wwid 26353900f02796769 devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" devnode "^hd[a-z][[0-9]*]" devnode "^dcssblk[0-9]*" }
Now start the multipathd service
# service multipathd start
Start up the service after next reboot.
# chkconfig multipathd on
Now check whether you are able to see VIRTUAL-DISKS or not.
multipath -ll
1IET_00010001 dm-3 IET,VIRTUAL-DISK size=100M features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 8:0:0:1 sdb 8:16 active ready running `- 9:0:0:1 sdc 8:32 active ready running
You will be able to see the new virtual disk as 1IET_00010001 (in your case it might display different name) in /dev directory :
ls /dev/mapper/1IET_00010001
Now create new partition on virtual disk using below command:(if you don’t know how to create partition please refer How to create partition )
fdisk /dev/mapper/1IET_00010001
Now you will be able to see new partition as /dev/mapper/1IET_00010001p1 in the partition table of /dev/mapper/1IET_00010001. Now run partprobe command : partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.
# partprobe /dev/mapper/1IET_00010001p1
Now create file system on the new partition in this case we are creating ext4:
# mkfs.ext4 /dev/mapper/1IET_00010001p1
fdisk -l will show you the new disk as
Disk /dev/mapper/1IET_00010001: 104 MB, 104857600 bytes 4 heads, 29 sectors/track, 1765 cylinders Units = cylinders of 116 * 512 = 59392 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x13099dd6 Device Boot Start End Blocks Id System /dev/mapper/1IET_00010001p1 1 100 5785+ 83 Linux
Disk /dev/mapper/1IET_00010001p1: 100 MB, 5924352 bytes 255 heads, 63 sectors/track, 0 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Create new directory to mount the new virtual partition :
# mkdir /share
Mount the file system using below command :
mount -t ext4 /dev/mapper/1IET_00010001p1 /share
If you want to add it to fstab: edit /etc/fstab file and add below line to end of the fstab file.
/dev/mapper/1IET_00010001p1 /share ext4 defaults,_netdev 0 0
MOST COMMENTED
Uncategorized
Ubuntu 16.04 No desktop only shows background wallpaper
Administration / DNS / Linux
Dig command examples
Virtualization
OpenVz(Kernel Base Open source Virtulization)
Uncategorized
Install Ansible on Linux
Puppet
Configuring puppet4 server agent and puppetdb on ubuntu16.04
Database
Installing postgresql on ubuntu 16.04
Puppet
opensource puppet4 installation on ubuntu16.04