ISCSI Target ( Server )

In: Aashish

16 Feb 2010

Article by Aashish


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.

Debian / Ubuntu Linux Install tgt

Type the following command to install Linux target framework user-space tools:

$ sudo apt-get install tgt

CentOS / RHEL / Red Hat Linux Install tgt

RHEL 5.2 and older version do not have tgt tools. However, RHEL 5.3 (preview version) comes with tgt tools.

tgtadm – Linux SCSI Target Administration Utility

tgtadm is used to monitor and modify everything about Linux SCSI target software: targets, volumes, etc. This tool allows a system to serve block-level SCSI storage to other systems that have a SCSI initiator. This capability is being initially deployed as a Linux iSCSI target, serving storage over a network to any iSCSI initiator.

Start tgtd

To start the tgtd, enter:

# /usr/sbin/tgtd

Under RHEL 5.3 to start the tgtd service, enter:

# /etc/init.d/tgtd start

Define an iscsi target name

The following example creates a target with id 1 (the iqn is 19 iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz) and adds a 20 logical unit (backed by /dev/hdc1)with lun 1.

# tgtadm –lld iscsi –op new –mode target –tid 1 -T iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
To view the current configuration, enter:

# tgtadm –lld iscsi –op show –mode target

Sample output:

Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz

System information:

Driver: iscsi

Status: running

I_T nexus information:

LUN information:

LUN: 0

Type: controller

SCSI ID: deadbeaf1:0

SCSI SN: beaf10

Size: 0

Online: No

Poweron/Reset: Yes

Removable media: No

Backing store: No backing store

Account information:

ACL information:

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

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

Note:- about home computer / test system

Most production boxes will only use iSCSI root with real iSCSI devices, but for testing purposes it can be quite useful to set up an iSCSI target on your image server. This is useful for testing and learning iSCSI target and iSCSI initiator at home, simply use filesystem for testing purpose. Use dd command to create diskbased filesystem:

# dd if=/dev/zero of=/fs.iscsi.disk bs=1M count=512

Add /fs.iscsi.disk as a logical unit to the target:

# tgtadm –lld iscsi –op new –mode logicalunit –tid 1 –lun 1 -b /fs.iscsi.disk

Now, you should able to view details:

# tgtadm –lld iscsi –op show –mode target

Sample output:

Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz

System information:

Driver: iscsi

Status: running

I_T nexus information:

LUN information:

LUN: 0

Type: controller

SCSI ID: deadbeaf1:0

SCSI SN: beaf10

Size: 0

Online: No

Poweron/Reset: Yes

Removable media: No

Backing store: No backing store

LUN: 1

Type: disk

SCSI ID: deadbeaf1:1

SCSI SN: beaf11

Size: 512M

Online: Yes

Poweron/Reset: Yes

Removable media: No

Backing store: /fs.iscsi.disk

Account information:

ACL information:

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:

tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 27328/tgtd
tcp6 0 0 :::3260 :::* LISTEN 27328/tgtd

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.

For Client
Install Required Package

iscsi-initiator-utils RPM package – The iscsi package provides the server daemon for the iSCSI protocol, as well as the utility programs used to manage it. iSCSI is a protocol for distributed disk access using SCSI commands sent over Internet Protocol networks. This package is available under Redhat Enterprise Linux / CentOS / Fedora Linux and can be installed using yum command:

# yum install iscsi-initiator-utils

A note about Debian / Ubuntu Linux

If you are using Debian / Ubuntu Linux install open-iscsi package, enter:

$ sudo apt-get install open-iscsi

iSCSI Configuration

There are three steps needed to set up a system to use iSCSI storage:

1. iSCSI startup using the init script or manual startup. You need to edit and configure iSCSI

via /etc/iscsi/iscsid.conf file

2. Discover targets.

3. Automate target logins for future system reboots.

4. You also need to obtain iSCSI username, password and storage server IP address (target host)

Step # 1: Configure iSCSI

Open /etc/iscsi/iscsid.conf with vi text editor:

# vi /etc/iscsi/iscsid.conf

Setup username and password:

node.session.auth.username = My_ISCSI_USR_NAME

node.session.auth.password = MyPassword

discovery.sendtargets.auth.username = My_ISCSI_USR_NAME

discovery.sendtargets.auth.password = MyPassword

Where,

* node.session.* is used to set a CHAP username and password for initiator authentication by the target(s).
* discovery.sendtargets.* is used to set a discovery session CHAP username and password for the initiator authentication by the target(s)

You may also need to tweak and set other options. Refer to man page for more information. Now start the iscsi service:

# /etc/init.d/iscsi start

Step # 2: Discover targets
Now use iscsiadm command, which is a command-line tool allowing discovery and login to iSCSI targets, as well as access and management of the open-iscsi database. If your storage server IP address is 192.168.1.5, enter:

# iscsiadm -m discovery -t sendtargets -p 192.168.1.5

# /etc/init.d/iscsi restart

Now there should be a block device under /dev directory. To obtain new device name, type:

# fdisk -l

or

# tail -f /var/log/messages

Output:
Oct 10 12:42:20 ora9is2 kernel: Vendor: EQLOGIC Model: 100E-00 Rev: 3.2
Oct 10 12:42:20 ora9is2 kernel: Type: Direct-Access ANSI SCSI revision: 05
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)
Oct 10 12:42:20 ora9is2 kernel: sdd: Write Protect is off
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: drive cache: write through
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)
Oct 10 12:42:20 ora9is2 kernel: sdd: Write Protect is off
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: drive cache: write through
Oct 10 12:42:20 ora9is2 kernel: sdd: unknown partition table
Oct 10 12:42:20 ora9is2 kernel: sd 3:0:0:0: Attached scsi disk sdd
Oct 10 12:42:20 ora9is2 kernel: sd 3:0:0:0: Attached scsi generic sg3 type 0
Oct 10 12:42:20 ora9is2 kernel: rtc: lost some interrupts at 2048Hz.
Oct 10 12:42:20 ora9is2 iscsid: connection0:0 is operational now
/dev/sdd is my new block device.

Step # 3: Format and Mount iSCSI Volume

You can now partition and create a filesystem on the target using usual fdisk and mkfs.ext3 commands:

# fdisk /dev/sdd

# mke2fs -j -m 0 -O dir_index /dev/sdd1

OR

# mkfs.ext3 /dev/sdd1

Tip: If your volume is large size like 1TB, run mkfs.ext3 in background using nohup:

# nohup mkfs.ext3 /dev/sdd1 &

Mount new partition:

# mkdir /mnt/iscsi

# mount /dev/sdd1 /mnt/iscsi

Step #4: Mount iSCSI drive automatically at boot time

First make sure iscsi service turned on at boot time:

# chkconfig iscsi on

Open /etc/fstab file and append config directive:

/dev/sdd1 /mnt/iscsi ext3 _netdev 0 0

Share and Enjoy:

  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Live
  • MySpace
  • Netvibes
  • Reddit
  • Slashdot
  • SphereIt
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Twitter
  • Yahoo! Bookmarks

Related Posts:

  • No Related Posts

11 Responses to ISCSI Target ( Server )

Avatar

Webmaster

June 10th, 2010 at 10:48 am

Hello! Please e-mail me your contacts. I have a question webmaster@spottovo.ru” rel=”nofollow”>……

Thank you!!!…

Avatar

CLARENCE

June 25th, 2010 at 5:42 pm

Pillspot.org. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Pillspot.org. Herbal-supplements@buy.online” rel=”nofollow”>.…

Categories: Mens Health.Mental HealthStop SmokingPain Relief.Anxiety/Sleep Aid.Stomach.Anti-allergic/Asthma.Antiviral.Skin Care.Eye Care.Blood Pressure/Heart.Womens Health.Antidiabetic.Vitamins/Herbal Supplements.Antibiotics.Weight Loss.Antidepres…

Avatar

r\x3dh

August 29th, 2010 at 2:13 am

r\x3dh http://01DODGEPARTS.US/tag/r\x3dh : au capsules Capsules/…

au capsules Capsules/…

Avatar

trader

August 29th, 2010 at 2:32 am

trader http://AUTOTECHGUIDE.INFO/tag/trader joe\x27s : trader…

wasabi Recipe/…

Avatar

au Card XD/

August 29th, 2010 at 2:33 am

au Card XD/ http://ABABYCLOTHES.INFO/tag/r\x3dh : au Card XD/…

au Card XD/…

Avatar

00p Reviews masterbilt epiphone/

August 29th, 2010 at 2:34 am

5 http://AUTOPARTSVILLE.INFO/tag/Dr. 5 : 00p Reviews masterbilt epiphone/…

00p Reviews masterbilt epiphone/…

Avatar

dell

August 29th, 2010 at 5:34 am

Avatar

potato

August 29th, 2010 at 4:23 pm

Avatar

grohe

August 29th, 2010 at 4:34 pm

Avatar

Washer

August 29th, 2010 at 4:47 pm

Avatar

Mall

August 29th, 2010 at 9:20 pm

Comment Form

Recent Posts