Wednesday, 9 April 2014

iSCSI(Internet Small Computer System Interface)

iSCSI(Internet Small Computer System Interface)

iSCSI is Internet SCSI (Small Computer System Interface), an Internet Protocol (IP)-based storage networking standard for linking data storage facilities, developed by the Internet Engineering Task Force (IETF). By carrying SCSI commands over IP networks, iSCSI is used to facilitate data transfers over intranets and to manage storage over long distances. The iSCSI protocol is among the key technologies expected to help bring about rapid development of the storage area network (SAN) market, by increasing the capabilities and performance of storage data transmission. Because of the ubiquity of IP networks, iSCSI can be used to transmit data over local area networks (LANs), wide area networks (WANs), or the Internet and can enable location-independent data storage and retrieval.

How iSCSI works:

When an end user or application sends a request, the operating system generates the appropriate SCSI commands and data request, which then go through encapsulation and, if necessary, encryption procedures. A packet header is added before the resulting IP packets are transmitted over an Ethernet connection. When a packet is received, it is decrypted (if it was encrypted before transmission), and disassembled, separating the SCSI commands and request. The SCSI commands are sent on to the SCSI controller, and from there to the SCSI storage device. Because iSCSI is bi-directional, the protocol can also be used to return data in response to the original request.
iSCSI is one of two main approaches to storage data transmission over IP networks; the other method, Fibre Channel over IP (FCIP), translates Fibre Channel control codes and data into IP packets for transmission between geographically distant Fibre Channel SANs. FCIP (also known as Fibre Channel tunnelingor storage tunneling) can only be used in conjunction with Fibre Channel technology; in comparison, iSCSI can run over existing Ethernet networks. A number of vendors, including Cisco, IBM, and Nishan have introduced iSCSI-based products (such as switches and routers).

Initiator:

The initiator is the name of the iscsi client. The iscsi client has a block level access to the iscsi devices, which can be a disk,one client can use multiple iscsi devices.

Target:

The target is the name of the iSCSI server. The iSCSI server offers its devices (disks, tape... etc.) to the clients. One device can by accessed by one client.

Discovery:

Discovery is the process which shows the targets for the initiator.

Discovery Method:

Internet Storage Name Service (iSNS) - Potential targets are discovered by interacting with one or more iSNS servers.
SendTargets – Potential targets are discovered by using a discovery-address.
SLP - Discover targets via Service Location protocol (RFC 4018)
Static – Static target address is specified.

ISCSI Naming:

The iSCSI name consists of two parts: type string and unique name string.
The type string can be the following:
iqn. : iscsi qualifiled name
eui. : eui-64 bit identifier
Most of the implementations use the iqn format. Let'S see our initiator name:
iqn.1993-08.com.redhat:01.35ef13adb6d
1. iqn: we use iSCSI qualified name address.
2. 1993-08: the year of the month on which the naming authority acquired the domain name which is used in the iSCSI name.
3. com.redhat: reversed dns name which defines the organizational naming authority.
4. 01.35ef13adb6d : this string is defined by the naming authority each disk will have unique string.




Before starting the iSCSI target configuration we need to have a partition which we need to use through the network. For this we need to create a partition using fdisk, parted or lvm.

(root)# fdisk -cu /dev/sdb

n - Create a new partition
1 - Select the number of the partition to be created depending on the layout
p/e - Select partition type
w - Write the changes to disk and exit.

(root)# partx -a /dev/sdb

iSCSI TARGET(server) CONFIG

To configure a iSCSI server you need to install the below package.
# yum install scsi-target-utils* -y

Edit the iSCSI target(server) config file to create a target
# vim /etc/tgt/targets.conf
####Copy line 31,32,33 and paste at end
<target iqn.2012-02.com.example:desktop26.target1>
backing-store /dev/sdb1
initiator-address 192.168.0.26
</target>
wq!

Explanation of the target conf file:
Line 1 : iqn.<year.month(in which we get our domain name or else we can use the current)>.com.hindux:<hostname>.<target_number>

Line 2 : backing-store  /dev/sdb1   --> The partition which we have created for utilizing as iSCSI
Line 3 : initiator-address 192.168.0.26   --> IP of the server on which we are configuring the ISCSI server.
Line 4 : </target>   --> Ending tag.


# service tgtd restart     --->     Restart the tgtd(iscsi target) service
# chkconfig tgtd on       --->     Turn on at startup
# tgt-admin --show | less     ---> Verify whether it is configured or not.

iSCSI INITIATOR(client)CONFIG:

To configure an iSCSI initiator(client) we need to install the below mentioned package.
# yum install iscsi-initiator-utils* -y

Restart the iscsi initiator service
# service iscsi start
If it doesn't work try this
# service iscsid force-start
# chkconfig iscsi on

To get the iqn name of the target we need to discover the target by using the following command.
# iscsiadm -m discovery -t st -p 192.168.0.25
192.168.0.25:3260,1 iqn.2012-02.com.example:desktop26.target1

After getting the iqn we need to configure the Initiator by editing the below config file.
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2012-02.com.example:desktop26.target1
:wq!

 After configuring the initiator we need to login to the target by using the following command.
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -l

 Now we need to know what is the name of the partition we get from the target. By using the below command we can get the name of the partition. After the name we can see the details of the partition and can mount the partition on to a directory and also we need to add an entry to the /etc/fstab file for permanent mounting. But we should remember to mention _netdev as it is a network storage.
# tail /var/log/messages | grep --color 'sd[a-z]'
# fdisk -l |less
# fdisk /dev/sdb
# cat /proc/partitions
# mkfs.ext4 /dev/sdb1
# blkid /dev/sdb1
# vim /etc/fstab
UUID="4e9de845-514e-430d-8d1b-51fb7bb0803e" /mnt/iscsi ext4 _netdev 0 0
:wq!

Note: Before rebooting always logout from Target(server) by using this command
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -u


Note: To Disconnect from iSCSI Target permanently remove entry from fstab then log out from Target and then clean/delete iSCSI information.
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -u
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -o delete

No comments :

Post a Comment