iSCSI server configuration in RHEL6

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


Client side configuration:
1 ) Install  iscsi-initiator-utils package on the client using yum
# yum install iscsi-initiator-utils
2 )Discover the target LUN’s exported by server using following command. It will provide iqn name with of LUN associated with given ip address


# iscsiadm -m discovery -t sendtargets -p 10.30.32.206
Starting iscsid:                                         [  OK  ]
10.30.32.206:3260,1 iqn.2008-09.com.example:server.target1t
Note :
-p : it is indicates the address of target server.


3)  To connect iSCSI target we can use following command , we need to mention server ip and iqn name.
# iscsiadm -m node -T iqn.2008-09.com.example:server.target1 –p 10.30.32.206 –login
Note :
-p : it is indicates the address of target server.
-T : This option specifies iqn of target server
Now iSCSI target is connected from ip 10.30.32.206.To find out the device associated with the iSCSI LUN. We have to check /var/log/message


# tail /var/log/messages
Dec 26 14:22:50 localhost kernel: scsi 3:0:0:0: Attached scsi generic sg4 type 12
Dec 26 14:22:50 localhost kernel: scsi 3:0:0:1: Direct-Access     IET      VIRTUAL-DISK     0001 PQ: 0 ANSI: 5
Dec 26 14:22:50 localhost kernel: sd 3:0:0:1: Attached scsi generic sg5 type 0
Dec 26 14:22:50 localhost kernel: sd 3:0:0:1: [sdd] 6281352 512-byte logical blocks: (3.21 GB/2.99 GiB)
Dec 26 14:22:50 localhost kernel: sd 3:0:0:1: [sdd] Write Protect is off
Dec 26 14:22:50 localhost kernel: sd 3:0:0:1: [sdd] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Dec 26 14:22:50 localhost kernel: sdd: sdd1
Dec 26 14:22:50 localhost kernel: sd 3:0:0:1: [sdd] Attached SCSI disk
Dec 26 14:22:50 localhost libvirtd: 14:22:50.833: error : udevGetSCSIType:747 : Failed to find SCSI device type 12
Dec 26 14:22:50 localhost iscsid: Connection1:0 to [target: iqn.2008-09.com.example:server.target1, portal: 10.30.32.206,3260] through [iface: default] is operational now


In this demo, iSCSI LUN is linked as /ded/sdd1


Creating file system:
 we can create file system on /ded/sdd1 and use locally.
# mkfs.ext3 /dev/sdd1
# mkdir iSCSI
# mount /dev/sdd1 /iSCSI/


Adding entry in /etc/fstab:
Find out UUID of device using following command
# blkid /dev/sdd1
/dev/sdd1: UUID=”9674832d-c995-4ac8-b6da-0d25efa088d0″ TYPE=”ext3″


Add the following entry in /etc/fstab using vi editor.
“UUID=9674832d-c995-4ac8-b6da-0d25efa088d0 /iSCSI ext3   _netdev        0 0”


[root@dhcpserver /]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Jun  2 00:41:38 2011
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=9c732237-b39f-4024-a631-3c264e637179 /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=9674832d-c995-4ac8-b6da-0d25efa088d0 /iSCSI ext3   _netdev        0 0


The added entry is highlighted in the above output.


Note:
We must use _netdev parameter while adding entry in /etc/fstab,Which is used to prevent the system from attempting to mount the file systems until the network has been enabled on the system.

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

페이스북/트위트/구글 계정으로 댓글 가능합니다.