Jump to Navigation

240 - iSCSI on Linux Server

Internet SCSI (iSCSI) is a network protocol s that allows you to use of the SCSI protocol over TCP/IP networks.
It is an alternative to Fibre Channel-based SANs, easily manage, mount and format iSCSI Volume under Linux.
It allows getting access to a SAN storage over the Ethernet network.

* iSCSI target (server)

Storage resource located on an iSCSI server known as a "target". An iSCSI target usually represents nothing but hard disk storage.
As with initiators, software to provide an iSCSI target is available for most mainstream operating systems.

* iSCSI initiator (client)

An initiator functions as an iSCSI client. An initiator typically serves the same purpose to a computer as a SCSI bus adapter would,
except that instead of physically cabling SCSI devices (like hard drives and tape changers), an iSCSI initiator sends SCSI commands
over an IP network.

1. Install packeges

* iSCSI target

# yum install scsi-target-utils (if you can not, you need to download from rpm)

scsi-target-utils-1.0.14-2.el5.x86_64.rpm
perl-Config-General-2.44-1.el5.rf.noarch.rpm

* Start tgtd

# /etc/init.d/tgtd start
# chkconfig tgtd on

* iSCSI initiator

# yum install iscsi-initiator-utils

* Start iscsi

# /etc/init.d/iscsi start
# chkconfig iscsi on

 

+++++++++++++++++++++++++  iSCSI target (server) +++++++++++++++++++++++++

2. Define an iscsi target name on the target server

# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-06.com.myserver01.oracle:sdb1

# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-07.com.myserver01.oracle:bidvdata

* To view the current configuration

# tgtadm --lld iscsi --op show --mode target

3. Add a logical unit to the target (/dev/sdb1, /dev/vg_myserver01/bidvdata)

# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1
# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/vg_oradev3/bidvdata

* To view the current configuration

# tgtadm --lld iscsi --op show --mode target

4. Accept iscsi target

* To enable the target to accept any initiators

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

*** tstg --> tcp:3260.  You should open this port# in iptables.
# netstat -tulpn | grep 3260

================================================================================================================

+++++++++++++++++++++++++  iSCSI initiator (client) +++++++++++++++++++++++++

5. Discover targets

# iscsiadm -m discovery -t sendtargets -p 192.168.17.22 192.168.17.22:3260,1 iqn.2012-06.com.myserver01.oracle:sdb1

# iscsiadm -m discovery -t sendtargets -p 192.168.17.34 192.168.17.34:3260,1 iqn.2012-07.com.myserver01.oracle:bidvdata

OR

# iscsiadm -m discovery -t sendtargets -p 192.168.17.22
# iscsiadm -m discovery -t sendtargets -p 192.168.17.34

# /etc/init.d/iscsi restart

6. Login to the iscsi target session

# iscsiadm -m node --targetname iqn.2012-06.com.myserver01.oracle:sdb1 --portal 192.168.17.22:3260 -l
# iscsiadm -m node --targetname iqn.2012-07.com.myserver01.oracle:bidvdata --portal 192.168.17.34:3260 -l

# iscsiadm -m node --targetname iqn.2012-06.com.myserver01.oracle:sdb1 --portal 192.168.17.22:3260 -u

7. Add a node

# iscsadm -m node -p ipaddress:port -T targetname -o new

8. Logout

# scsiadm --mode node --target iqn.2012-06.com.myserver01.oracle:sdb1 -p 192.168.17.22 --logout

or

# iscsiadm --mode node --logoutall=all

9. Deleting a node

# iscsiadm -m node -p ipaddress:port -T targetname -o delete

10. Format the iSCSI Volume

# fdisk -l

# fdisk /dev/sdd     ( Create a partition )

# mkfs.ext3 /dev/sdb1
(# mke2fs -j /dev/sdb1)  ( Format it as ext3 )

11. Mount the volume

# mkdir /iscsi

# mount -t ext3 /dev/sdb1 /iscsi

12. Modify fstab for the automount when reboot server

# vi /etc/fstab
/dev/sdb1  /iscsi ext3 _netdev 0 0

Solution: Change the ‘defaults’ for the iSCSI mounts to use the ‘_netdev’ identifier (‘_netdev’ = file system resides on a device that requires network access
[used to prevent the system from attempting to mount these file systems until the network has been enabled on the system] ).
RHEL will not attempt to mount these drive paths until both the network connections have been done and that the iSCSI daemon is running.

 



Main menu 2

Story | by Dr. Radut