Thursday, 28 November 2013

ISCSi target Configuration in RHEL6/Centos


                                                      ISCSI TARGET CONFIGURATION

1.      Install RHEL machine.
2.      Edit the repo file(create new repo).
3.      Mount rhel dvd
#mount /dev/cdrom /media
#cd /etc/yum.repos.d/
#vi dvd.repo

Save & quit!
#yum clean all
Now intall scsi-target-utils package from dvd.

#yum install scsi-target-utils*

Create a new partition in rhel machine
Configure the target name & define the LUN “as: (/dev/sda4 -130GB)”
Save it
Formate the volume /dev/sda4
#mkfs.ext4  /dev/sda4
Define an iscsi target name
The following example creates a target with id 1 (the iqn is iqn.2001-04.com.taashee:iscsistorage)

# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-07.com.example:iscsistorage

 To view the current configuration, enter:
# tgtadm --lld iscsi --op show --mode target

Add a logical unit to the target (/dev/sdb4):

# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb4

To view the current configuration

# tgtadm --lld iscsi --op show --mode target
Accept iSCSI Target
To enable the target to accept any initiators, enter:

# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL

This should open network port # 3260:

# netstat -tulpn | grep 3260

Sample output:
   
And you are done. Your system is configured as iSCSI Target. Remote client computer can access this computers hard disk over network. Your can use cluster aware filesystem to setup real shared storage for small business. Open TCP port 3260 in your firewall, if required.
# tgtadm --lld iscsi --op show --mode target
For making the setup persistent over reboot type this command:

# tgt-admin  --dump >> /etc/tgt/targets.conf

# vim /etc/tgt/target.conf

Create a directory and mount the /dev/sda4

#mkdir /iscsi
#mount /dev/sda4 /iscsi
Or
#vim /etc/fstab(make entry)

#service tgtd restart

# chkconfig tgtd onDescription: https://mail.google.com/mail/u/0/images/cleardot.gif

#chkconfig iscsi on