Monday, December 2, 2013

iSCSI server configuration in RHEL6


Configuring  iSCSI target on RHEL 6


Introduction

iSCSI is Internet SCSI (Small Computer System Interface), 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 makes block devices available via the network. We can mount block devices (disks) across an IP network to local system and then use them like any other block device. iSCSI is a client-server protocol. The server-side is referred to as the 'target,' while the client-side is referred to as the 'initiator.' Both the target and initiator are uniquely identified by a string called the iSCSI Qualified Name (iQN). Initiators come in two varieties: software and hardware. A software initiator is just a driver that handles all requests and pairs the network interfaces driver and the SCSI drivers together to make it work. Using a software initiator any system with an Ethernet card can act as an iSCSI initiator. A hardware initiator is an iSCSI HBA, which is basically just an ethernet card with a SCSI ASIC onboard. Here we are configuring software initiator in RHEL 6.

OS installation

Install RHEL 6 on the server with basic server installation and configure yum server on the machine.

Network setup

Configure network with ipaddress and make sure that clients are reachable to the server. By default iSCSI will listen to the port 3260, we have to add necessary rules in iptables to allow iSCSI. Ignore this step if firewall is disabled.

# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT 
# service iptables save                                                  
# service iptables restart                                               

Install and enable the iSCSI target service

Install and enable the iSCSI target service with the following commands

# yum install scsi-target-utils  
# chkconfig tgtd on                
# service tgtd start                

Allocate storage for the LUNs

The iSCSI target service is not dependent on a particular type of exported LUN. The LUNs can be plain files, LVM volumes, or block devices. There is however a performance overhead if using the LVM and/or file system layers as compared to block devices. This example demonstrates the creation of a local partition /dec/sdc1 as iSCSI storage LUN

# fdisk -l /dev/sdc

Disk /dev/sdc: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc9a1606e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         391     3140676   83  Linux

Create the targets

Targets can be created by adding an XML entry to the /etc/tgt/targets.conf file, using text editor.  Following entries to be added.

#vi /etc/tgt/targets.conf 

default-driver iscsi
<target iqn.2008-09.com.example:server.target1>
    backing-store /dev/sdc1
    write-cache off
</target>
Note:
The target attribute requires an iSCSI Qualified Name (IQN),following is the general format:
iqn.yyyy-mm.reversed.domain.name:OptionalIdentifierText

yyyy-mm represents the 4-digit year and 2-digit month the device was started (for example: 2011-07)
reversed.domain.name is the hosts domain name in reverse. For example, server1.example.com, in an IQN, becomes com.example.server1;
OptionalIdentifierText is any text string, without spaces, that helps the administrator identifies which device.

Restart  tgtd service

Need to restart tgtd service after configuring iscsi target

# service tgtd restart

Stopping SCSI target daemon:                               [  OK  ]
Starting SCSI target daemon:                               [  OK  ]

Checking configuration

To confirm the successful operation , query the iSCSI target setup using following command

# tgt-admin --show 

Target 1: iqn.2008-09.com.example:server.target1
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store type: rdwr
            Backing store path: None
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 3216 MB
            Online: Yes
            Removable media: No           
            Backing store type: rdwr                 
            Backing store path: /dev/sdc1          
    Account information:                                
    ACL information:                                     
        ALL                                                    

+JetStor iSCSI RAID +JetStor iSCSI RAID  +Red Hat 

No comments:

Post a Comment