You are on page 1of 6

Set up an iSCSI Server in RHEL 6.

x
What is iSCSI? iSCSI is a network storage protocol above TCP/IP suite. iSCSI protocol encapsulates SCSI data into TCP packets. It allows a host to connect to a storage array via a simple Ethernet connection. This solution is quite cheaper than the Fibre Channel SAN as Fibre Channel HBAs and switches are pretty expensive. The user of the client system sees the storage arrays LUNs like a local disk. iSCSI devices should not be confused with NAS (Network Attached Storage) devices e.g. NFS (Network File System). Note: The most important difference is that NFS volumes can be accessed by multiple hosts, but one iSCSI volume should be accessed by one host. iSCSI Terminology Initiator: Its the name of the iSCSI client. The iSCSI client has a block level access to the iSCSI devices, which can be a disk, tape drive or CD/DVD writer. One client can use multiple iSCSI devices. Target: Its the iSCSI Server. It offers the devices like disks, tape drives, cd/dvd drives to the clients. One device can be accessed by one client. Discovery: Its the process which shows the targets for the initiator. Naming Rule [ iqn.year-month.domain:anyname ] iSCSI Target can be used to Setup stateless server/client (used in diskless setup) Share disks and tape drives with remote client over LAN, WAN or the Internet. Setup SAN Storage Array etc

Test Environment In my test setup, I am using two virtual hosts viz., server1 (192.168.150.140) and station1 (192.168.150.142) and both runs RHEL 6.3 64-bit. Here, server1 will be my iSCSI target and station1 will be the iSCSI initiator.

Prabir Meher <prabirmeher@gmail.com>

Page 1

Set up an iSCSI Server in RHEL 6.x


Creating the iSCSI Target First, we need to add an additional hard drive to create an iSCSI Target. In my case, its /dev/sdb and has only one partition /dev/sdb1 of size around 50 GB. Here I am creating a LVM based storage because of the flexibility it provides, you can proceed without LVM if you want.

Create a physical volume:

Create a volume group:

Create a logical volume:

Now, we need to install the package which will provide the iSCSI utils for our setup. # yum install scsi-target-utils Add the following at the end of the file: /etc/tgt/targets.conf <target iqn.2013-02.com.example:target1> backing-store /dev/target/target_01 initiator-address 192.168.150.142 </target>

Now start the server # service tgtd start OR # /etc/init.d/tgtd start

Prabir Meher <prabirmeher@gmail.com>

Page 2

Set up an iSCSI Server in RHEL 6.x


IPTables Configuration If your host is using iptables, open port 3260 for iSCSI access: # iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT # service iptables save # service iptables restart Verify the new iSCSI Targets View the new targets to ensure the setup was successful, by using the tgt-admin command: # tgt-admin --show

LUN 0 will appear as a device of type "controller".

Prabir Meher <prabirmeher@gmail.com>

Page 3

Set up an iSCSI Server in RHEL 6.x


Notice that the ACL information is set to station2 (192.168.150.142) that means this particular LUN1 is accessible to only station2.

Now we will configure iSCSI initiator


Install the following package: # yum install iscsi-initiator-utils

Testing the targets


Now we can test whether the new iSCSI device is discoverable from client1.example.com: Discover the targets as follows:

So far so good! Confirm status after discovery # iscsiadm -m node -o show Login to target

Confirm session

Prabir Meher <prabirmeher@gmail.com>

Page 4

Set up an iSCSI Server in RHEL 6.x


Confirm partitions:

You can see that a new block device /dev/sdc has been added to the system. Success! Now the target is enabled to be accessed upon reboots (persistent) and it's added to a node database in /var/lib/iscsi. The iscsid service will access this database upon system startup and re-attach your iSCSI Targets. To disconnect the iSCSI Target, you will need to log out: # iscsiadm -m node -T iqn.2013-02.com.example:target1 -p server1 u

You could also log out of all attached targets by using this command: # iscsiadm -m node -U all

Prabir Meher <prabirmeher@gmail.com>

Page 5

Set up an iSCSI Server in RHEL 6.x


To again list the target, you need to login to the target system as follows: # iscsiadm m node --login

Prabir Meher <prabirmeher@gmail.com>

Page 6

You might also like