Client side iscsi initiator setup:
root@manager-desktop:~# apt-get install open-iscsi
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libdevel-symdump-perl libipc-run-perl debootstrap libauthen-sasl-perl diffstat libio-stringy-perl patchutils libaio1 seabios
python-cheetah libio-pty-perl openvpn-blacklist libterm-size-perl kpartx libpkcs11-helper1 vgabios devscripts libtest-pod-perl
dctrl-tools dput libpod-coverage-perl libapt-pkg-perl lintian libparse-debcontrol-perl wdiff qemu-common
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
open-iscsi-utils
The following NEW packages will be installed:
open-iscsi open-iscsi-utils
0 upgraded, 2 newly installed, 0 to remove and 542 not upgraded.
Need to get 684kB of archives.
After this operation, 1,696kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://in.archive.ubuntu.com/ubuntu/ lucid/main open-iscsi-utils 2.0.871-0ubuntu4 [108kB]
Get:2 http://in.archive.ubuntu.com/ubuntu/ lucid/main open-iscsi 2.0.871-0ubuntu4 [575kB]
Fetched 684kB in 6s (101kB/s)
Selecting previously deselected package open-iscsi-utils.
(Reading database ... 181243 files and directories currently installed.)
Unpacking open-iscsi-utils (from .../open-iscsi-utils_2.0.871-0ubuntu4_amd64.deb) ...
Selecting previously deselected package open-iscsi.
Unpacking open-iscsi (from .../open-iscsi_2.0.871-0ubuntu4_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up open-iscsi-utils (2.0.871-0ubuntu4) ...
Setting up open-iscsi (2.0.87
.........................................................
Next we open /etc/iscsi/iscsid.conf...
vim /etc/iscsi/iscsid.conf
... and set node.startup to automatic:
[...]
node.startup = automatic
[...]
**********************************************************************
Following is a quick way to access iSCSI target, under RHEL 5. Let us say your server iSCSI Target IP is 192.168.1.2. Type the following command to discover targets at a given IP address such as 192.168.1.2 (use 127.0.0.1 if you are testing it from same computer):
root@manager-desktop:~# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.27
192.168.1.27:3260,1 iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
Login to the iscsi target session:
*********************************
root@manager-desktop:~# iscsiadm --mode node --targetname
iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz --portal 192.168.1.27:3260 --login
iscsiadm: no records found!
(actually "iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz" is changed "iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz")
once again discoverd the iqn value:
root@manager-desktop:~# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.27
192.168.1.27:3260,1 iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
then changed the iqn's disk1 to disk2
******************
root@manager-desktop:~# iscsiadm --mode node --targetname
iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz --portal 192.168.1.27:3260 --login
Logging in to [iface: default, target: iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz, portal: 192.168.1.27,3260]
Login to [iface: default, target: iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz, portal: 192.168.1.27,3260]: successful
Verify that login was successful:
root@manager-desktop:~# tailf /var/log/messages
Mar 21 02:20:06 manager-desktop kernel: [ 8311.885562] scsi6 : iSCSI Initiator over TCP/IP
Mar 21 02:20:06 manager-desktop kernel: [ 8312.166485] scsi 6:0:0:0: RAID IET Controller 0001 PQ: 0 ANSI: 5
Mar 21 02:20:06 manager-desktop kernel: [ 8312.166919] scsi 6:0:0:0: Attached scsi generic sg1 type 12
Mar 21 02:20:06 manager-desktop kernel: [ 8312.168818] scsi 6:0:0:1: Direct-Access IET VIRTUAL-DISK 0001 PQ: 0 ANSI: 5
Mar 21 02:20:06 manager-desktop kernel: [ 8312.170014] sd 6:0:0:1: Attached scsi generic sg2 type 0
Mar 21 02:20:06 manager-desktop kernel: [ 8312.178782] sd 6:0:0:1: [sdb] 382922113 512-byte logical blocks: (196 GB/182 GiB)
Mar 21 02:20:06 manager-desktop kernel: [ 8312.181503] sd 6:0:0:1: [sdb] Write Protect is off
Mar 21 02:20:06 manager-desktop kernel: [ 8312.182107] sd 6:0:0:1: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Mar 21 02:20:06 manager-desktop kernel: [ 8312.183907] sdb: unknown partition table
Mar 21 02:20:06 manager-desktop kernel: [ 8312.197096] sd 6:0:0:1: [sdb] Attached SCSI disk
root@manager-desktop:~# fdisk -cul
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009122a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 477868031 238932992 83 Linux
/dev/sda2 477870078 488396799 5263361 5 Extended
/dev/sda5 477870080 488396799 5263360 82 Linux swap / Solaris
Disk /dev/sdb: 196.1 GB, 196056121856 bytes
255 heads, 63 sectors/track, 23835 cylinders, total 382922113 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xcb0a0ab2
Disk /dev/sdb doesn't contain a valid partition table
root@manager-desktop:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x8e2b2146.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-23835, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-23835, default 23835): 2000
Command (m for help): p
Disk /dev/sdb: 196.1 GB, 196056121856 bytes
255 heads, 63 sectors/track, 23835 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8e2b2146
Device Boot Start End Blocks Id System
/dev/sdb1 1 2000 16064968+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@manager-desktop:~# partprobe
root@manager-desktop:~# clear
root@manager-desktop:~# fdisk -cul
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009122a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 477868031 238932992 83 Linux
/dev/sda2 477870078 488396799 5263361 5 Extended
/dev/sda5 477870080 488396799 5263360 82 Linux swap / Solaris
Disk /dev/sdb: 196.1 GB, 196056121856 bytes
255 heads, 63 sectors/track, 23835 cylinders, total 382922113 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8e2b2146
Device Boot Start End Blocks Id System
/dev/sdb1 63 32129999 16064968+ 83 Linux
Linux tgtadm: Setup iSCSI Target ( SAN )
Linux target framework (tgt) aims to simplify various SCSI target driver (iSCSI, Fibre Channel, SRP, etc) creation and maintenance. The key goals are the clean integration into the scsi-mid layer and implementing a great portion of tgt in user space.
The developer of IET is also helping to develop Linux SCSI target framework (stgt) which looks like it might lead to an iSCSI target implementation with an upstream kernel component. iSCSI Target can be useful:
a] To setup stateless server / client (used in diskless setups).
b] Share disks and tape drives with remote client over LAN, Wan or the Internet.
c] Setup SAN - Storage array.
d] To setup loadbalanced webcluser using cluster aware Linux file system etc.
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.tgtadm - Linux SCSI Target Administration Utility
tgtadm:
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.
**********************************************************************************
CONFIGURING tgtadm:
root@client27-System-Product-Name:~# apt-get install tgt
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libconfig-general-perl libibverbs1 librdmacm1 sg3-utils
The following NEW packages will be installed:
libconfig-general-perl libibverbs1 librdmacm1 sg3-utils tgt
0 upgraded, 5 newly installed, 0 to remove and 298 not upgraded.
Need to get 936 kB of archives.
After this operation, 2,986 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://in.archive.ubuntu.com/ubuntu/ natty/main libconfig-general-perl all 2.48-1 [70.7 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu/ natty/main sg3-utils amd64 1.30-1 [577 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ natty/main libibverbs1 amd64 1.1.3-2ubuntu1 [34.1 kB]
...........................
root@client27-System-Product-Name:~# /usr/sbin/tgtd
(null): fcoe_init(214) (null)
(null): fcoe_create_interface(171) no interface specified.
librdmacm: couldn't read ABI version.
librdmacm: assuming: 4
CMA: unable to get RDMA device list
(null): iser_ib_init(3250) Failed to initialize RDMA; load kernel modules?
(don't consider this just run the following command)
REf:
http://iscsitargetandinitiator.blogspot.in/
http://osdir.com/ml/debian-bugs-dist/2010-09/msg08226.html
root@manager-desktop:~# ps -ef | grep -i tgt
root 18618 1 0 00:40 ? 00:00:00 /usr/sbin/tgtd
root 18619 18618 0 00:40 ? 00:00:00 /usr/sbin/tgtd
root 25769 8586 0 01:18 pts/0 00:00:00 grep --color=auto -i tgt
*************************************************************
Now 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.
root@client27-System-Product-Name:~# 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:
root@client27-System-Product-Name:~# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
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, Block size: 1
Online: Yes
Removable media: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
ACL information:
NOW CREATED A PARTITION /dev/sda3 :
Add a logical unit to the target (/dev/sda3)
root@client27-System-Product-Name:~# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sda3
Now, you should able to view details:
root@client27-System-Product-Name:~# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
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, Block size: 1
Online: Yes
Removable media: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 196056 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sda3
Backing store flags:
Account information:
ACL information:
Accept iSCSI Target:
To enable the target to accept any initiators, enter:
root@client27-System-Product-Name:~# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
This should open network port # 3260:
root@client27-System-Product-Name:~# netstat -plunt | grep 3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 4371/tgtd
tcp6 0 0 :::3260 :::* LISTEN 4371/tgtd
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.
******************************************************************************************************************
No comments:
Post a Comment