Intr

iSCSI is an Internet Protocol (IP)-based storage networking standard for linking data storage facilities. By carrying SCSI commands over IP networks, iSCSI is used to facilitate data transfers over intranets and to manage storage over long distances.

iSCSI is a client-server protocol. the server side is called 'target', while the client side is referred as the ' initiator'. Both target and initiator are uniquely identified by a string called the iSCSI Qualified Name(iQN).

Clients (called Initiators) sends SCSI commands (CDBs) to SCSI storage devices (Linux-IO Targets) on remote servers over internet. Unlike traditional Fibre Channel, which requires special-purpose cabling, iSCSI can be run over long distances using existing network infrastructure.

Regarless which kind of target. The initiator configuration is same, Here I'm going to show you how to config client side. In this example, I'm using SL6.4, same to RHEL6.4, CentOS6.4, also can be reference to other Linux distributions.

See iSCSI target setup on Linux for software iSCSI target setup, another one for Hardware iSCSI setup, config and tuning example

Package installation

# yum install iscsi-initiator-utils.x86_64

================================================================================
 Package                     Arch         Version                Repository
                                                                           Size
================================================================================
Installing:
 iscsi-initiator-utils       x86_64       6.2.0.873-10.el6       sl       685 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 685 k
Installed size: 2.3 M
Is this ok [y/N]: y

Installed:
  iscsi-initiator-utils.x86_64 0:6.2.0.873-10.el6

Config iQN for the initiator

Set the initiator name, same as iSCSI target, they use iSCSI IQN format, but not same to target IQN, actually, in the same iSCSI setup environment, never set two initiatorname to the same.

 # cat initiatorname.iscsi 
InitiatorName=iqn.1994-05.com.redhat:7018da8525

Discovery target

# iscsiadm -m discovery -t sendtargets -p pps11
                                                           [  OK  ]
206.12.1.147:3260,1 iqn.2015-01.com.fibrevillage.pps11:pps11.target1

Note:

Many iscsiadm node and discovery operations require iscsi daemon(iscsid) be running, thus, you may notice iscsiadm brings iscsid up when doing targets discovery.

This operation only needs to be done once, you only need to do it when iscsi target changed or iscsid session configuration change, tuning ect..

Start iscsi service

# service iscsi start
Starting iscsi:                                            [  OK  ]

Note: You may notice that iscsid daemon is also brought up, this is normal.

Checkcfg on iscsi service

chkcfg --level 345 on iscsi

List new iscsi target device

# lsscsi
...
[5:0:0:2]    disk    Fibrevil iscsi-soft       1.0   /dev/sdb

Now you can use the device as a regular scsi block device, create a filesystem, add it to lvm etc..

Stop iscsi service

# service iscsi stop
Stopping iscsi:                                            [  OK  ]

Session is not active

# iscsiadm -m session
iscsiadm: No active sessions.

However, iscsid is still running

# service iscsid status
iscsid (pid  11056) is running...

Stop iscsid if you are going to do maintenance at iscsi target side.

# service iscsid stop  
Stopping iscsid:
#                                            [  OK  ]

Check session status

# iscsiadm -m session
tcp: [15] 10.0.0.1:3260,1 iqn.2015-01.com.fibrevillage:pps11.target1

Detail session info

# iscsiadm -m session -P3
iSCSI Transport Class version 2.0-870
version 6.2.0-873.10.el6
Target: iqn.2015-01.com.fibrevillage:pps11.target1
    Current Portal: 10.0.0.1:3260,1
    Persistent Portal: 10.0.0.1:3260,1
        **********
        Interface:
        **********
        Iface Name: default
        Iface Transport: tcp
        Iface Initiatorname: iqn.1994-05.com.redhat:7018da8525
        Iface IPaddress: 10.0.0.2
        Iface HWaddress: <empty>
        Iface Netdev: <empty>
        SID: 15
        iSCSI Connection State: LOGGED IN
        iSCSI Session State: LOGGED_IN
        Internal iscsid Session State: NO CHANGE
        *********
        Timeouts:
        *********
        Recovery Timeout: 15
        Target Reset Timeout: 30
        LUN Reset Timeout: 30
        Abort Timeout: 15
        *****
        CHAP:
        *****
        username: <empty>
        password: ********
        username_in: <empty>
        password_in: ********
        ************************
        Negotiated iSCSI params:
        ************************
        HeaderDigest: None
        DataDigest: None
        MaxRecvDataSegmentLength: 1048576
        MaxXmitDataSegmentLength: 1048576
        FirstBurstLength: 65536
        MaxBurstLength: 262144
        ImmediateData: Yes
        InitialR2T: Yes
        MaxOutstandingR2T: 1
        ************************
        Attached SCSI devices:
        ************************
        Host Number: 19    State: running
        scsi19 Channel 00 Id 0 Lun: 0
        scsi19 Channel 00 Id 0 Lun: 2
            Attached scsi disk sdb        State: running

Things to remember when doing troubleshooting

 Once iscsi target get discovered by initiator on client, the target session info is stored in

/var/lib/iscsi/nodes/

So, keep remember that if you have any tuning/changes done at target or iscsid side, restart iscsid and redo iscsi discovery, of course iscsi session restart.