Configure iSCSI in CentOS 4/5 REHL 4/5

Open-iSCSI project is a high performance, transport independent, multi-platform implementation of RFC3720 ( Internet Small Computer System Interface ). It enables the user to configure & maintain a reliable, low-cost SAN environment using existing Ethernet setup.

I have tested & implemented Open-iSCSI in my test machine (which is a CentOS machine) with the help of Netapp filer which is acting as target. The same procedure will (?) work with Fedora & Ubuntu. But i haven’t tested it yet.

Prerequisites :
1. CentOS/RHEL 4/5
2. Open-iSCSI initiator
3. Netapp (or similar file server which can act as iSCSI target)
4. Network between initiator (is the one who initiates an iSCSI session) and target (is the one which provides LUN to a initiator)

These iSCSI initiator use CRC for data integrity. Please make sure that you have installed all the modules required for installing & running an iSCSI initiator.
1. Install & configure CentOS/REHL 4/5  as your requirement. Please try to install all the modules/packages in the install media.
3. If you are using an existing machine, make sure you have enabled “YUM” installer.
4. Install Open-iSCSI initiator in your CentOS/REHL 4/5 test machine by typing,

yum install iscsi-initiator-utils

5. Once installation completes, you can check the service by running,

service iscsid status

If the package is correctly installed, you will see the output as below,

iscsid (pid 23236 23235) is running…

Go to “/etc/iscsi/” dir. You can see two files namely,

-rw-r–r– 1 root root   49 Feb 11 17:20 initiatorname.iscsi
-rw——- 1 root root 9071 Feb 11 17:39 iscsid.conf

“initiatorname.iscsi” is the file containing the iSCSI node name which is required to target machine to identify and to authenticate the initiator.

[root@tester3 iscsi]# cat initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:d791b1dcf29

Use this “iqn” numbere while creating “igroups” in Netapp & map that “igroup” to the lun/s.
To generate new “iqn” number for an initiator (your test machine), use “iscsi-iname” cmd

[root@tester3 iscsi]# iscsi-iname
iqn.1994-05.com.redhat:65345e3d79e0

Note this “iqn”, edit “initiatorname.iscsi” file, remove the old “iqn” number & replace the newly generated “iqn” number. Once done, restart the “iscsid” daemon.

Open “iscsid.conf” file editing using your favourite editor. Uncomment below line in the file,

#node.session.auth.authmethod = CHAP
`
#node.session.auth.username = “USERNAME”
#node.session.auth.password = “PASSWD”
`
#node.session.auth.username_in = “USERNAME_IN”
#node.session.auth.password_in = “PASSWD_IN”

Please make a note, use different username & password for “node.session.auth.username & node.session.auth.username_in”. It’s just  credentials that “iscsid” uses to authenticate initiator and target with each other.

OPTIONAL:

If you want enable CHAP for authenticating (I prefer to do with CHAP enabled for more security), uncomment below lines. I have tested this with Netapp filer & found working fine. You can ignore this if you don’t want to use CHAP. Am not sure whether this works with any other filers/storage.
`
#discovery.sendtargets.auth.authmethod = CHAP
`
#discovery.sendtargets.auth.username = “USERNAME”
#discovery.sendtargets.auth.password = “PASSWD”
`
#discovery.sendtargets.auth.username_in = “USERNAME_IN”
#discovery.sendtargets.auth.password_in = “PASSWD_IN

Please note, use the same username and password what you have used in “node.session.auth.username & node.session.auth.password” in “discovery.sendtargets.auth.username & discovery.sendtargets.auth.password” “USERNAME” and “PASSWD” field. This applies for the second set of options also.

Once necessary username and passwords are given in the conf file, restart “iscsid” service.

Now, It’s the time to discover the iSCSI targets to find any LUN/s mapped to the “iqn” of your machine. Use “iscsiadm” cmd to identify the target & to start a new iSCSI session from your machine.

[root@tester3 iscsi]# iscsiadm -m discovery -t sendtargets -p “ip_of_your_stoarage_box”

If initiator & targets have succussfully authenticated itself, you can see output like this (which is in red)

[root@tester3 ~]# iscsiadm -m discovery -t sendtargets -p  192.168.178.122
192.168.178.122:3260,1000 iqn.1992-08.com.netapp:sn.101196108

If authentication (CHAP enabled only) fails, it display msg like below

[root@tester3 ~]# iscsiadm -m discovery -t sendtargets -p  192.168.178.122
iscsiadm: Login failed to authenticate with target
iscsiadm: discovery login to 192.168.178.122 rejected: initiator error (02/01), non-retryable, giving up

If you haven’t seen any eeors, restart “iscsid” deamon.

[root@tester3 ~]# /etc/init.d/iscsid restart
Stopping iSCSI daemon:
Turning off network shutdown. Starting iSCSI daemon:
OK ]
OK ]

Even you can check the log file for any iSCSI related errors.

[root@tester3 ~]# tail /var/log/messages
May 26 19:41:08 tester3 kernel: Loading iSCSI transport class v2.0-869.
May 26 19:41:08 tester3 kernel: iscsi: registered transport (tcp)
May 26 19:41:08 tester3 kernel: iscsi: registered transport (iser)
May 26 19:41:08 tester3 iscsid: iSCSI logger with pid=1650 started!
May 26 19:41:09tester3 iscsid: transport class version 2.0-869. iscsid version 2.0-871
May 26 19:41:09 tester3 iscsid: iSCSI daemon with pid=1651 started!

Use “fdisk -l” cmd to find any newly attached hard drive & format the partition as usual you will do for physical hard drive. Mount the drive to any dir & you can start writing the data.

+++++————————————————————————————————————————————–++++++

4 Responses to Configure iSCSI in CentOS 4/5 REHL 4/5

  1. Pingback: 2010 in review « Linux Bites

  2. Pingback: Configure iSCSI in CentOS 4/5 REHL 4/5 | devtrends.com

  3. Thank you for sharing this tip on configuring an iSCSI initiator.

    For a few months, I had nominated myself for a project at work to create an inexpensive iSCSI SAN. It started out as strictly opensource products, such as the iSCSI Enterprise Target daemon (IET) and Ubuntu, but quickly migrated to using OpenSolaris and its native iSCSI target software.

    I have some articles about opensource/Linux iSCSI targets on my blog if you are interested.

    -Aaron

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s