Jul 312014
 

This article will show you how to configure Open-iSCSI initiator (client) to connect to an existing iSCSI target (server).  I will not actually review how to  setup the  iSCSI Target in this article.   If you don’t already have an iSCSI Target available in your environent, you might take a look at OpenFiler.

In this guide, I am using a CentOS 6.5 system as the iSCSI initiator (client) and will connect to an existing iSCSI target.

Install the Open-iSCSI software

On my CentOS 6.5 system, the Open-iSCSI package is not installed by default.  You can check to see if your system has the package installed by running the following command:

[root@linux ~]# rpm -qa | grep iscsi-initiator-utils

If the iscsi-initiator-utils package is not already installed, use the “yum” command to install it:

[root@linux ~]# yum install iscsi-initiator-utils

Start the iSCSI service

After installing the iscsi-initiator-utils packs, start the iscsid service and configure both the iscsid and iscsi services to automatically start each time the system boots:

[root@linux ~]# /etc/init.d/iscsid start
[root@linux ~]# chkconfig iscsid on
[root@linux ~]# chkconfig iscsi on

Discover iSCSI Targets

Use the iscsiadm command to discover all of the iSCSI targets on your iSCSI Target server (i.e. your iSCSI SAN.  In this case my server running OpenFiler):

[root@linux ~]# iscsiadm -m discovery -t sendtargets -p 192.168.197.201
192.168.197.201:3260,1 iqn.2006-01.com.openfiler:tsn.target1

Note: In my example, the hostname of my iSCSI Target (SAN) is “openfiler.mydomain.com” and has an IP address of 192.168.197.201

Login to the iSCSI Target and configure automatic login at boot time

[root@linux ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.target1 -p 192.168.197.201 --login
[root@linux ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.target1 -p 192.168.197.201 --op update -n node.startup -v automatic

Verify iSCSI session is active

[root@linux ~]# iscsiadm -m session
tcp: [1] 192.168.197.201:3260,1 iqn.2006-01.com.openfiler:tsn.target1

Identify which device the iSCSI target maps to

[root@linux ~]# (cd /dev/disk/by-path; ls -l *iscsi* | awk '{FS=" "; print $9 " " $10 " " $11}')
ip-192.168.197.201:3260-iscsi-iqn.2006-01.com.openfiler:tsn.target1-lun-0 -> ../../sdc

This tells us that the iSCSI target has been mapped to /dev/sdc on the system.  From here, use standard partitioning/formatting commands (fdisk, mkfs, etc) to setup the disk as desired!

 Posted by at 4:57 pm
Nov 082012
 

A software iSCSI target can be a great way to set up shared storage when you don’t have enough dough to afford pricey SAN hardware. The iSCSI target acts just like a real hardware iSCSI array, except it’s just a piece of software running on a traditional server (or even a VM!). Setting up an iSCSI target is an easy and low cost way to get the shared storage you need, whether you’re using a clustering product like Microsoft Windows Server Failover Clustering (WSFC), a cluster filesystem such as GFS or OCFS, or even if you’re wanting to get the most out of your virtualization platform (be it VMware, XenServer, or Hyper-V) by enabling storage pooling and live migration.

About Lio-Target

Recently, the Linux kernel has adopted LIO-Target as the standard iSCSI target for Linux. LIO-Target is available in Linux kernels 3.1 and higher. LIO-Target supports SCSI-3 Persistent Reservations, which are required by Windows Server Failover Clustering, VMware vSphere, and other clustering products. The LUNs (disks) presented by the iSCSI target can be entire disks, partitions, or even just plain old files on the filesystem. LIO-Target supports all of these options.

Below, we’ll walk through the steps to configure LIO-Target on an Ubuntu 12.04 server (other recent distros will probably work also, but the steps may vary slightly).

Configuration Steps

First, install the Lio-target packages:

# apt-get install –no-install-recommends targetcli python-urwid

Lio-target is controlled using the targetcli command line utility.

The first step is to create the backing store for the LUN. In this example, we’ll use a file-backed LUN, which is just a normal file on the filesystem of the iSCSI target server.

# targetcli

/> cd backstores/
/backstores> ls
o- backstores …………………………………………………… […]
o- fileio …………………………………………. [0 Storage Object]
o- iblock …………………………………………. [0 Storage Object]
o- pscsi ………………………………………….. [0 Storage Object]
o- rd_dr ………………………………………….. [0 Storage Object]
o- rd_mcp …………………………………………. [0 Storage Object]

/backstores> cd fileio

/backstores/fileio> help create  (for help)

/backstores/fileio> create lun0 /root/iscsi-lun0 2g  (create 2GB file-backed LUN)

Now the LUN is created. Next we’ll set up the target so client systems can access the storage.

/backstores/fileio/lun0> cd /iscsi

/iscsi> create   (create iqn and target port group)

Created target iqn.2003-01.org.linux-iscsi.murray.x8664:sn.31fc1a672ba1.
Selected TPG Tag 1.
Successfully created TPG 1.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.murray.x8664:sn.31fc1a672ba1/tpgt1

/iscsi/iqn.20…a672ba1/tpgt1> set attribute authentication=0   (turn off chap auth)

/iscsi/iqn.20…a672ba1/tpgt1> cd luns

/iscsi/iqn.20…a1/tpgt1/luns> create /backstores/fileio/lun0   (create the target LUN)
Selected LUN 0.
Successfully created LUN 0.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.murray.x8664:sn.31fc1a672ba1/tpgt1/luns/lun0

/iscsi/iqn.20…gt1/luns/lun0> cd ../../portals

iSCSI traffic can consume a lot of bandwidth, so you’ll probably want the iSCSI traffic to be on a dedicated (or SAN) network, rather than your public network.

/iscsi/iqn.20…tpgt1/portals> create 10.10.102.164  (create portal to listen for connections)
Using default IP port 3260
Successfully created network portal 10.10.102.164:3260.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.murray.x8664:sn.31fc1a672ba1/tpgt1/portals/10.10.102.164:3260

/iscsi/iqn.20….102.164:3260> cd ..

/iscsi/iqn.20…tpgt1/portals> create 10.11.102.164
Using default IP port 3260
Successfully created network portal 10.11.102.164:3260.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.murray.x8664:sn.31fc1a672ba1/tpgt1/portals/10.11.102.164:3260

/iscsi/iqn.20…102.164:3260> cd ../../acls

Now, you’ll just need to register the iSCSI initiators (client systems). To do this, you’ll need to find the initiator names of the systems. For Linux, this will usually be in /etc/iscsi/initiatorname.iscsi. For Windows, the initiator name is found in the iSCSI Initiator Properties Panel in the Configuration Tab.

/iscsi/iqn.20…a1/tpgt1/acls> create iqn.1994-05.com.redhat:f5b312caf756   (register initiator — this IQN is the IQN of the initiator — do this for each initiator that will access the target)
Successfully created Node ACL for iqn.1994-05.com.redhat:f5b312caf756
Created mapped LUN 0.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.murray.x8664:sn.31fc1a672ba1/tpgt1/acls/iqn.1994-05.com.redhat:f5b312caf756

/iscsi/iqn.20….102.164:3260> cd /

Now, remember to save the configuration. Without this step, the configuration will not be persistent.
/> saveconfig  (SAVE the configuration!)

/> exit


You’ll now need to connect your initiators to the target. You’ll generally need to provide the IP address of the target to connect to it. After the connection is made, the client systems will see a new disk. The disk will need to be formatted before use.

And that’s it! You’re ready to use your new SAN. Have fun!

 Posted by at 1:57 pm
Jul 312012
 

Welcome to LinuxClustering.net. Visit us to find information, techniques, tips and best practices in the areas of high availability, data replication and disaster recovery for your critical linux applications.  If there are particular topics you would like to see discussed, please let us know. Enjoy!

 Posted by at 11:33 am