Connect iSCSI LUNs to RHEL/CENTOS




Description:


This article will walk through attaching an iSCSI LUN to RHEL/CentOS 7.


   COMPATABILITY NOTICE:
These instructions are only compatible with CentOS 7     and RHEL 7  


Pre-Requisites:


Install the iSCSI libraries on the server:

yum -y install iscsi-initiator-utils device-mapper-multipath lldpad


Start iSCSI Services:


Once all of the pre-requisite packages have been installed, all of the iscsi services need to be started and configured to start on boot.


systemctl start iscsi;
systemctl start iscsid ;
systemctl start multipathd ;
systemctl enable iscsi ;
systemctl enable iscsid ;
systemctl enable multipathd ;


Configure Interface:


   iSCSI VLAN:
Ensure that either the chassis or switch port that the server is connected to is set to the proper iSCSI VLAN or the interface will not be able to communicate with the iSCSI Target.


vim /etc/sysconfig/network-scipts/ifcfg-enoxxxx
Adapter
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=enp8s0
UUID=5e72182e-82ca-4072-a376-1645852871b4
DEVICE=enp8s0
ONBOOT=yes
MTU=9000
DCB=on
DCB_APP_FCOE=no
DCB_APP_FCOE_ENABLE=no
DCB_APP_ISCSI=yes
DCB_APP_ISCSI_CFG=40
DCB_APP_ISCSI_ENABLE=yes
DCB_APP_ISCSI_ADVERTISE=yes
DCB_APP_ISCSI_WILLING=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_PRIVACY=no
IPADDR=172.1.2.3
NETMASK=255.255.0.0


Get Initiator Name:


Once the interfaces have been configured, we need the initiator name, which will be used on the iSCSI target, to allow access to the iSCSI resource.


cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:ab92cf327a


Perform Discovery:


Assuming that the server initiator has been granted access to the LUN on the target, performing a discovery should show the LUNs that have been assigned to the initiator.


iscsiadm -m discovery -t sendtargets -p 172.2.3.254


Verify discovery:


Use the commands below to show information about the LUNs that have been assigned to the initiator.


iscsiadm -m session -o show
iscsiadm -m node -o show


Login to the Target:


Logging onto the target should map the LUNs to the server. Once logged in, the LUNs should be visable on the server.


iscsiadm -m node --login


Verify Connectivity:


cat /proc/partitions


Prepare the LUNs


Fdisk the LUNs as you would a standard disk


Mount the LUNs


Edit the /etc/fstab file and add an entry similar to the following: * In this example the LUN is being mounted to /var/lib/docker, before mounting ensure that the mount target directory exists.

/dev/sdb1  /var/lib/docker/ ext4    defaults,_netdev   0 0


Post Requisites:



References: