Thursday, May 9, 2013

RHEL 6 iSCSI setup

Here is a mini howto for setting up RHEL 6 to share iSCSI storage.


A note of advice:
Whatever device you setup to be shared out as an iSCSI device, must not be mounted on the server. If it is mounted, you will not see it when you run the command tgt-admin –show!

Server steps used:
  1. yum install scsi-target-utils perl-Config-General
  1. service tgtd start
  2. chkconfig tgtd on
  3. add the following lines to /etc/tgt/targets.conf

<target iqn.2012-05.com.example.server1:data>
backing-store /dev/sdb1   #LUN1
write-cache off
</target>

  1. service tgtd restart
  2. tgt-admin –show
you should see output similar to the following
 
Target 1: iqn.2011-07.com.example.server1:trial
  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: 20000 MB
      Online: Yes
      Removable media: No
      Backing store type: rdwr
      Backing store path: /dev/sdb1

To mount the newly create iSCSI luns on the client follow these steps on the client:
  1. yum install iscsi-initiator-utils
  2. service iscsid start
  1. chkconfig iscsid on
  1. run the following commands to discover and connect to the lun on the server
    1. iscsiadm –mode discovery –type sendtargets –portal 192.168.1.10
      1. you will see output similar to the following:
      1. 192.168.1.10:3260,1 iqn.2012-05.com.example.server1:data
    1. iscsiadm –m node –T iqn.2012-05.com.example.server1:data –p 192.168.1.10 –l
      1. Logging in to [iface: default, target: iqn.2012-05.com.example.server1:data, portal: 192.168.1.10,3260]
  1. You should now see a new device listed in fdisk. Something along the lines of /dev/sdb1 if you only have 1 hdd in the server
  1. You are now ready to mount /dev/sdb1
  1. To mount the filesystem run the following commands:
    1. mkdir /data
    1. mount /dev/sdb1 /data
  1. If you want to make the mount point persistant, add the following line to /etc/fstab:
    1. /dev/sdb1           /data     ext4       defaults               0 0

No comments:

Post a Comment