<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SpaLinux.com &#187; iSCSI</title>
	<atom:link href="http://spalinux.com/tag/iscsi/feed" rel="self" type="application/rss+xml" />
	<link>http://spalinux.com</link>
	<description>Resources for Relaxing Linux System Administrators</description>
	<lastBuildDate>Sat, 21 Jan 2012 16:07:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>คอนฟิก iSCSI target บน Linux</title>
		<link>http://spalinux.com/2009/11/configure_iscsi_target_on_linux</link>
		<comments>http://spalinux.com/2009/11/configure_iscsi_target_on_linux#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:49:56 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Disk]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[iSCSI]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=968</guid>
		<description><![CDATA[บทความนี้กล่าวถึงการติดตั้งโปรแกรม iSCSI target และการคอนฟิกเพื่อให้เครืองอื่นๆ ที่ทำหน้าที่ initiator สามารถมาเรียกใช้ storage ได้ ติดตั้งไฟล์ rpm ไฟล์ rpm ที่ต้องใช้ เพื่อคอนฟิกเครื่องให้ทำหน้าที่เป็น iSCSI target ได้ คือ &#8220;scsi-target-utils&#8221; ตัวอย่างการติดตั้งไฟล์ rpm สำหรับ Fedora 11 [root@fc11-server ~]# rpm -i scsi-target-utils-0.9.5-1.fc11.x86_64.rpm error: Failed dependencies:         perl(Config::General) is needed by scsi-target-utils-0.9.5-1.fc11.x86_64 หากเจอ error แบบนี้ ต้องลงไฟล์ rpm ชื่อ perl-Config-General ก่อน [root@fc11-server ~]# rpm -i perl-Config-General-2.42-2.fc11.noarch.rpm [root@fc11-server ~]# rpm [...]]]></description>
			<content:encoded><![CDATA[<p>บทความนี้กล่าวถึงการติดตั้งโปรแกรม iSCSI target และการคอนฟิกเพื่อให้เครืองอื่นๆ ที่ทำหน้าที่ initiator สามารถมาเรียกใช้ storage ได้</p>
<p><span id="more-968"></span></p>
<h4>ติดตั้งไฟล์ rpm</h4>
<p>ไฟล์ rpm ที่ต้องใช้ เพื่อคอนฟิกเครื่องให้ทำหน้าที่เป็น iSCSI target ได้ คือ &#8220;scsi-target-utils&#8221;</p>
<p>ตัวอย่างการติดตั้งไฟล์ rpm สำหรับ Fedora 11</p>
<pre>[root@fc11-server ~]# <strong>rpm -i scsi-target-utils-0.9.5-1.fc11.x86_64.rpm
</strong><span style="color: #ff0000;">error: Failed dependencies:
        perl(Config::General) is needed by scsi-target-utils-0.9.5-1.fc11.x86_64</span></pre>
<p>หากเจอ error แบบนี้ ต้องลงไฟล์ rpm ชื่อ perl-Config-General ก่อน</p>
<pre>[root@fc11-server ~]# <strong>rpm -i perl-Config-General-2.42-2.fc11.noarch.rpm
</strong>[root@fc11-server ~]# <strong>rpm -i scsi-target-utils-0.9.5-1.fc11.x86_64.rpm</strong></pre>
<h4>รันเซอร์วิส tgtd</h4>
<p>รันเซอร์วิส tgtd (The Generic storage Target Daemon) ก่อน โดยใช้คำสั่ง service</p>
<pre>[root@fc11-server ~]# <strong>/etc/init.d/tgtd start
</strong>Starting SCSI target daemon:                               [  OK  ]</pre>
<h4>สร้าง target ใหม่</h4>
<p>ใช้คำสั่ง tgtadm เพื่อสร้าง target ใหม่ โดยพารามิเตอร์ที่ต้องระบุคือ target id (&#8211;tid) และชื่อ target (-T)</p>
<p>เราสามารถสร้างได้หลาย target ในเซิร์ฟเวอร์เครื่องหนึ่ง แต่ต้องมี id และชื่อแตกต่างกัน สำหรับ  id เราสามารถรันตัวเลขเริ่มจาก 1 ได้ ส่วนชื่อ target ที่นิยมกันจะตั้งชื่อในรูปแบบ iqn (iSCSI Qualified Name)</p>
<p>รูปแบบชื่อแบบ iqn</p>
<pre>iqn.yyyy-mm.{reversed domain name}:resource_name</pre>
<p>ในบทความนี้ตั้งชื่อเป็น iqn.2001-04.com.example:storage.test.disk-01</p>
<p>ตัวอย่างการสร้าง target ใหม่</p>
<pre>[root@fc11-server ~]# <strong>tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2001-04.com.example:storage.test.disk-01</strong></pre>
<p>หลังจากที่สร้างแล้ว สามารถใช้คำสั่ง tgtadm &#8211;op show เพื่อตรวจสอบคอนฟิก target ที่ทำงานอยู่ได้</p>
<pre>[root@fc11-server ~]# <strong>tgtadm --lld iscsi --op show --mode target
</strong><span style="color: #0000ff;">Target 1: iqn.2001-04.com.example:storage.test.disk-01
</span>    System information:
        Driver: <span style="color: #0000ff;">iscsi</span>
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store: No backing store
    Account information:
    ACL information:</pre>
<h4>เพิ่ม logical unit เข้า target</h4>
<p>เมื่อสร้าง target แล้ว จะยังไม่สามารถใช้งานได้ทันที ต้องเพิ่ม logical unit ที่จะทำหน้าที่เป็น storage ของ target นี้ก่อน</p>
<p>เราสามารถใช้ disk partition หรือ LVM logical volume เพื่อทำหน้าที่เป็น logical unit ได้ ในที่นี้จะใช้ disk partition /dev/sdb1</p>
<p><span style="color: #ff0000;">คำเตือน!!! ข้อมูลใน disk ที่จะใช้เป็น logical unit จะถูกทำลายทั้งหมด จาก initiator</span></p>
<p>ตัวอย่างการเพิ่ม logical unit เข้า target</p>
<pre>[root@fc11-server ~]# <strong>tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1</strong></pre>
<p>ตรวจสอบหลังจากการเพิ่ม logical unit</p>
<pre>[root@fc11-server ~]# <strong>tgtadm --lld iscsi --op show --mode target
</strong>Target 1: iqn.2001-04.com.example:storage.test.disk-01
    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
            Online: Yes
            Removable media: No
            Backing store: No backing store
<span style="color: #0000ff;">        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 40049 MB
            Online: Yes
            Removable media: No
            Backing store: /dev/sdb1
</span>    Account information:
    ACL information:</pre>
<h4>คอนฟิก bind target</h4>
<p>สุดท้ายต้องระบุการ bind เพื่อเป็นการอนุญาตให้เครื่อง client หรือ initiator สามารถเข้ามาใช้ (access) target ได้</p>
<p>เบื้องต้น เราจะอนุญาตทั้งหมดให้เข้ามาใช้ได้ ด้วยการระบบออปชั่น &#8220;-I ALL&#8221;</p>
<pre>[root@fc11-server ~]# <strong>tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL</strong></pre>
<p>ตรวจสอบหลังจากคอนฟิก</p>
<pre>[root@fc11-server ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2001-04.com.example:storage.test.disk-01
    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
            Online: Yes
            Removable media: No
            Backing store: No backing store
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 40049 MB
            Online: Yes
            Removable media: No
            Backing store: /dev/sdb1
    Account information:
    ACL information:
        <span style="color: #0000ff;"><strong>ALL</strong></span></pre>
<h4>ทดสอบจาก iSCSI initiator</h4>
<p>ทดสอบรันคำสั่ง iscsiadm -m discovery จากเครื่องอื่น เพื่อทดสอบการค้นหา target ที่เพิ่งสร้างขึ้น  สมมติว่าเคื่อง server ที่ทำหน้าที่ target มี ip address เป็น 192.168.1.1</p>
<pre>[root@fc11-client ~]# <strong>iscsiadm -m discovery -t sendtargets -p 192.168.1.1
</strong>192.168.1.1:3260,1 iqn.2001-04.com.example:storage.test.disk-01</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/11/configure_iscsi_initiator_on_linux">คอนฟิก iSCSI initiator บน Linux</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/11/configure_iscsi_target_on_linux/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>คอนฟิก iSCSI initiator บน Linux</title>
		<link>http://spalinux.com/2009/11/configure_iscsi_initiator_on_linux</link>
		<comments>http://spalinux.com/2009/11/configure_iscsi_initiator_on_linux#comments</comments>
		<pubDate>Sat, 14 Nov 2009 10:19:25 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Disk]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[iSCSI]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=962</guid>
		<description><![CDATA[iSCSI (Internet Small Computer System Interface) เป็นวิธีการเชื่อมต่อ storage โดยผ่าน Internet Protocol (IP) ทำให้สามารถเชื่อมต่อ เครื่องกับ storage ผ่านทาง network ต่างๆ ระยะทางไกลได้ (เป็นข้อดีที่เหนือกว่าการใช้ Fiber Channel ที่ถูกจำกัดระยะทางด้วยสาย Fiber) iSCSI ทำงานในรูปแบบ Server-Client โดย ฝั่ง Client หรือเรียกว่า Initiator ทำหน้าที่ส่ง SCSI command ไปยัง storage ของ Server ปลายทาง ที่เรียกว่า Target บทความนี้กล่าวถึงวิธีการติดตั้งโปรแกรมและคอนฟิก iSCSI ฝั่ง Client เพื่อให้สามารถเรียกใช้ดิสก์ (target) จาก server ได้ โดยฝั่ง server อาจเป็น Storage [...]]]></description>
			<content:encoded><![CDATA[<p>iSCSI (Internet Small Computer System Interface) เป็นวิธีการเชื่อมต่อ storage โดยผ่าน Internet Protocol (IP) ทำให้สามารถเชื่อมต่อ เครื่องกับ storage ผ่านทาง network ต่างๆ ระยะทางไกลได้ (เป็นข้อดีที่เหนือกว่าการใช้ Fiber Channel ที่ถูกจำกัดระยะทางด้วยสาย Fiber)</p>
<p>iSCSI ทำงานในรูปแบบ Server-Client โดย ฝั่ง Client หรือเรียกว่า Initiator ทำหน้าที่ส่ง SCSI command ไปยัง storage ของ Server ปลายทาง ที่เรียกว่า Target</p>
<p>บทความนี้กล่าวถึงวิธีการติดตั้งโปรแกรมและคอนฟิก iSCSI ฝั่ง Client เพื่อให้สามารถเรียกใช้ดิสก์ (target) จาก server ได้ โดยฝั่ง server อาจเป็น Storage Array หรือ Server ที่ถูกคอนฟิกเพื่อทำหน้าที่เป็น target ได้</p>
<p><span id="more-962"></span></p>
<p>ตัวอย่างในบทความนี้ ถือว่าฝั่ง server คอนฟิกสร้าง volume ชื่อ &#8220;vol-01&#8243; และอนุญาตให้เครื่องที่เราจะคอนฟิกสามารถใช้งานได้ (access)</p>
<h4>ติดตั้งไฟล์ rpm</h4>
<p>ตัวอย่างการติดตั้งไฟล์ rpm สำหรับ Fedora 11</p>
<pre>[root@fc11-64a ~]# <strong>rpm -i iscsi-initiator-utils-6.2.0.870-8.fc11.x86_64.rpm</strong></pre>
<h4>ค้นหา target</h4>
<p>เริ่มต้น ต้องค้นหาชื่อ target ปลายทางจาก IP ที่ระบุ โดยใช้คำสั่ง iscsiadm โหมด discovery</p>
<pre>[root@fc11-64a ~]# <strong>iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260
</strong>Starting iscsid:                                           [  OK  ]
192.168.1.1:3260,1 iqn.2000-10.com.example:0-999999-b8f877804-bfd0000000c13f3e-vss-control
192.168.1.1:3260,1 iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01</pre>
<p>หากเป็นการเรียกใช้คำสั่ง iscsiadm ครั้งแรก เซอร์วิส iscsid จะถูกรันขึ้นมาโดยอัตโนมัติ</p>
<p>ตัวอย่างข้อความที่เกิดขึ้นในไฟล์ /var/log/messages ซึ่งไฟล์นี้จะมีประโยชน์มากในการตรวจสอบ และแก้ไขปัญหาที่อาจเกิดขึ้น</p>
<pre>[root@fc11-64a ~]# <strong>tail -f /var/log/messages
</strong>...
Nov 14 16:24:31 fc11-64a kernel: Loading iSCSI transport class v2.0-870.
Nov 14 16:24:31 fc11-64a kernel: iscsi: registered transport (tcp)
Nov 14 16:24:31 fc11-64a kernel: iscsi: registered transport (iser)
Nov 14 16:24:31 fc11-64a iscsid: iSCSI logger with pid=6014 started!
Nov 14 16:24:32 fc11-64a iscsid: transport class version 2.0-870. iscsid version 2.0-870
Nov 14 16:24:32 fc11-64a iscsid: iSCSI daemon with pid=6016 started!</pre>
<h4>login เข้า target ที่ต้องการ</h4>
<p>เมื่อเราทราบชื่อ target ที่ต้องการใช้แล้ว สามารถใช้คำสั่ง iscsiadm โหมด node ระบุออปชั่น &#8216;-l&#8217; เพื่อ login เข้าสู่ target ได้</p>
<pre>[root@fc11-64a ~]# <strong>iscsiadm -m node -p 192.168.1.1 -T iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01 -l
</strong>Logging in to [iface: default, target: iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01, portal: 192.168.1.1,3260]
Login to [iface: default, target: iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01, portal: 192.168.1.1,3260]: successful</pre>
<p>ตัวอย่างข้อความที่เกิดขึ้นในไฟล์ /var/log/messages</p>
<pre>[root@fc11-64a ~]# <strong>tail -f /var/log/messages
</strong>...
Nov 14 16:28:20 fc11-64a kernel: scsi6 : iSCSI Initiator over TCP/IP
Nov 14 16:28:30 fc11-64a kernel: scsi 6:0:0:0: Direct-Access     EXAMPLE  100E-00         x.x  PQ: 0 ANSI: 5
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] 209725440 512-byte hardware sectors: (107 GB/100 GiB)
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] Write Protect is off
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] 209725440 512-byte hardware sectors: (107 GB/100 GiB)
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] Write Protect is off
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Nov 14 16:28:30 fc11-64a kernel: sdb: unknown partition table
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: [sdb] Attached SCSI disk
Nov 14 16:28:30 fc11-64a kernel: sd 6:0:0:0: Attached scsi generic sg2 type 0
Nov 14 16:28:30 fc11-64a iscsid: connection1:0 is operational now</pre>
<p>จากไฟล์ /var/log/messages เมื่อ login เข้า target สำเร็จ volume จะถูก map เป็นดิสก์ (sdb) ให้เราสามารถเรียกใช้ได้</p>
<p>ใช้คำสั่ง fdisk ตรวจสอบ</p>
<pre>[root@fc11-64a ~]# <strong>fdisk -l /dev/sdb</strong></pre>
<pre>Disk /dev/sdb: 107.3 GB, 107379425280 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000</pre>
<pre>Disk /dev/sdb doesn't contain a valid partition table</pre>
<p>เราสามารถสร้าง partition แล้วสร้าง filesystem ตามที่ต้องการได้เหมือนดิสก์ทั่วๆ ไป</p>
<p>ใช้คำสั่ง fdisk เพื่อสร้าง partition</p>
<pre>[root@fc11-64a ~]# <strong>fdisk /dev/sdb
</strong>Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x52c1bb70.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.</pre>
<pre>The number of cylinders for this disk is set to 13054.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)</pre>
<pre>Command (m for help): <strong>n</strong>
Command action
   e   extended
   p   primary partition (1-4)
<strong>p
</strong>Partition number (1-4): <strong>1
</strong>First cylinder (1-13054, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054</pre>
<pre>Command (m for help): <strong>p</strong></pre>
<pre>Disk /dev/sdb: 107.3 GB, 107379425280 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x52c1bb70</pre>
<pre>   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       13054   104856223+  83  Linux</pre>
<pre>Command (m for help): <strong>w
</strong>The partition table has been altered!</pre>
<pre>Calling ioctl() to re-read partition table.
Syncing disks.</pre>
<p>ใช้คำสั่ง mkfs.xfs เพื่อสร้าง filesystem แบบ xfs บน partition ที่ถูกสร้างขึ้น</p>
<pre>[root@fc11-64a ~]# <strong>mkfs.xfs /dev/sdb1
</strong>meta-data=/dev/sdb1              isize=256    agcount=4, agsize=6553514 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=26214055, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=12799, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=0
realtime =none                   extsz=4096   blocks=0, rtextents=0</pre>
<p>ใช้คำสั่ง mount เพื่อ mount filesystem</p>
<pre>[root@fc11-64a ~]# <strong>mount /dev/sdb1 /mnt/vol-01/
</strong>[root@fc11-64a ~]# <strong>cd /mnt/vol-01/
</strong>[root@fc11-64a vol-01]# <strong>df -h .
</strong>Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             100G  4.2M  100G   1% /mnt/vol-01</pre>
<h4>เลิกใช้งาน disk</h4>
<p>เมื่อจะเลิกใช้งาน ต้อง umount ก่อน</p>
<pre>[root@fc11-64a ~]# <strong>umount /mnt/vol-01
</strong>[root@fc11-64a ~]#</pre>
<p>ใช้คำสั่ง iscsiadm โหมด node ระบุออปชั่น &#8216;-u&#8217; เพื่อจะ logout ออกจาก target</p>
<pre>[root@fc11-64a ~]# <strong>iscsiadm -m node -p 192.168.1.1 -T iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01 -u
</strong>Logging out of session [sid: 1, target: iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01, portal: 192.168.1.1,3260]
Logout of [sid: 1, target: iqn.2000-10.com.example:0-999999-141376505-58c000000654afe7-vol-01, portal: 192.168.1.1,3260]: successful</pre>
<p>หลังจาก logout แล้ว ตรวจสอบด้วยคำสั่ง fdisk จะไม่เห็นดิสก์ที่ map ไว้</p>
<pre>[root@fc11-64a ~]# <strong>fdisk -l /dev/sdb
</strong>[root@fc11-64a ~]#</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/11/configure_iscsi_target_on_linux">คอนฟิก iSCSI target บน Linux</a></li>
<li><a href="http://en.wikipedia.org/wiki/ISCSI" target="_blank">iSCSI &#8211; Wikipedia</a></li>
<li>man iscsiadm (8)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/11/configure_iscsi_initiator_on_linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

