This article will walk through attaching an iSCSI LUN to RHEL/CentOS 7.
These instructions are only compatible with CentOS 7
Install the iSCSI libraries on the server:
yum -y install iscsi-initiator-utils device-mapper-multipath lldpad
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 ;
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
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
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
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
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
cat /proc/partitions
Fdisk the LUNs as you would a standard disk
Edit the /etc/fstab file and add an entry similar to the following:
/dev/sdb1 /var/lib/docker/ ext4 defaults,_netdev 0 0