iSCSI is a protocol that allows clients (called initiators) to send SCSI commands (CDBs) to SCSI storage devices (targets) on remote servers. It is a popular Storage Area Network(SAN) protocol, allowing organizations to consolidate storage into data center storage arrays while providing hosts (such as database and web servers) with the illusion of locally-attached disks. Unlike Fibre Channel, which requires special-purpose cabling, iSCSI can be run over long distances using existing network infrastructure.
To use RHEL/CentOS 6 system as an iSCSI initiator or client, you must have iscsi-initiator-utils package installed. You can verify that this is installed on your system using the rpm command, as shown in the following example:
$ rpm -qa | grep iscsi-initiator-utils
1. Install the package if its not already available on your system using yum.
# yum install iscsi-initiator-utils
2. Start the iscsi demaon and use chkconfig to enable it to start after reboot as well.
# service iscsi start # chkconfig iscsi on
1. Once you have installed the required package and started the service you can start discovering the available targets. To Obtain a listing of available targets from a given host (please note that ipaddress listed below must be replaced with the resolvable hostname or IP address of the system providing the port if different than default):
# iscsiadm -m discovery -t st -p 192.168.10.10 192.168.10.10:3260,1 iqn.2010-03.com.example:tgtd
iqn.2010-03.com.example:tgtd – is the target_iqn_name.
2. You can view more information on the target using the below command.
# iscsiadm -m node -T [target_iqn_name] -p [target_ipaddress]
3. The next step is to login to the discovered target.
# iscsiadm -m node -T iqn.2010-03.com.example:tgtd -p 192.168.10.10 -l Logging in to [iface: default, target: iqn.2010-03.com.example:tgtd, portal: 192.168.10.10,3260] Login to [iface: default, target: iqn.2010-03.com.example:tgtd, portal: 192.168.10.10,3260]: successful
You can also login into all the LUNs exported on the target by running:
# iscsiadm -m discovery -t st -l
The iscsi initiator has it’s own database to save the target/node information and configuration. This is located in “/var/lib/iscsi” directory.
4. You can view the newly attached iSCSI storage using fdisk command.
# fdisk -l
Disconnect iSCSI storage
1. To disconnect an existing iSCSI storage, you will have to first log out of the target.
# iscsiadm -m node -T [target_iqn_name] -p [ipaddress] -u
2. To remove the target from the iscsi database so that the iscsi does not reconnect upon reboot, delete the target after logging out of it:
# iscsiadm -m node -T target_iqn_name -p ip address --op delete
3. If you have multiple targets that you have logged into, you can log out of all targets by running:
# iscsiadm -m node -U all
1. To get target list, run:
# iscsiadm -m discovery
2. To get the node list, run:
# iscsiadm -m node
3. The iscsid daemon opens a TCP session with the target. To check the open session, run:
# iscsiadm -m session
# netstat -tpan | grep iscsid
You can also check for the file /sys/class/iscsi_session to find open sessions.
4. Find which session a disk belongs to:
# iscsiadm -m session
The output will include active sessions and attached scsi disks.