<?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; Networking</title>
	<atom:link href="http://spalinux.com/category/networking/feed" rel="self" type="application/rss+xml" />
	<link>http://spalinux.com</link>
	<description>Resources for Relaxing Linux System Administrators</description>
	<lastBuildDate>Mon, 26 Jul 2010 09:51:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>การใช้งาน DRBD เบื้องต้น</title>
		<link>http://spalinux.com/2010/02/basic_using_drbd</link>
		<comments>http://spalinux.com/2010/02/basic_using_drbd#comments</comments>
		<pubDate>Sat, 06 Feb 2010 11:09:40 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Disk]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[Kernel]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[drbd]]></category>
		<category><![CDATA[linux ha]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1072</guid>
		<description><![CDATA[จากบทความ ติดตั้งและคอนฟิก DRBD  เราได้คอนฟิกเป็นแบบ Single-primary mode คือ ณ เวลาใดเวลาหนึ่ง มีเครื่องเดียวเท่านั้นที่สามารถ อ่าน เขียน ข้อมูลได้ ดังนั้นขณะที่เครื่องที่ 1 (centos54-a) ทำหน้าที่เป็น primary ของดิสก์ drbd0 อยู่  เครื่องที่ 2 (centos54-b) จะไม่สามารถ mount ดิสก์ drbd0 นี้ขึ้นมาใช้งานได้ ในบทความนี้จะแสดงการทดสอบใช้คำสั่งเพื่อเปลี่ยนโหมด Primary, Secondary ระหว่างเครื่องทั้งสอง ตรวจสอบสถานะบนเครื่อง centos54-a [root@centos54-a ~]# service drbd status drbd driver loaded OK; device status: version: 8.3.2 (api:88/proto:86-90) GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 [...]]]></description>
			<content:encoded><![CDATA[<p>จากบทความ <a href="http://spalinux.com/2010/02/install_and_configure_drbd">ติดตั้งและคอนฟิก DRBD </a> เราได้คอนฟิกเป็นแบบ Single-primary mode คือ ณ เวลาใดเวลาหนึ่ง มีเครื่องเดียวเท่านั้นที่สามารถ อ่าน เขียน ข้อมูลได้</p>
<p>ดังนั้นขณะที่เครื่องที่ 1 (centos54-a) ทำหน้าที่เป็น primary ของดิสก์ drbd0 อยู่  เครื่องที่ 2 (centos54-b) จะไม่สามารถ mount ดิสก์ drbd0 นี้ขึ้นมาใช้งานได้</p>
<p>ในบทความนี้จะแสดงการทดสอบใช้คำสั่งเพื่อเปลี่ยนโหมด Primary, Secondary ระหว่างเครื่องทั้งสอง</p>
<p>ตรวจสอบสถานะบนเครื่อง centos54-a</p>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                 ds                 p  mounted  fstype
0:r0   Connected  Primary/Secondary  UpToDate/UpToDate  C  /export  ext3</pre>
<pre>[root@centos54-a ~]# df -h /export
Filesystem            Size  Used Avail Use% Mounted on
/dev/drbd0            950M   18M  885M   2% /export</pre>
<p>ทดสอบ mount ดิสก์บนเครื่อง centos54-b</p>
<pre>[root@centos54-b ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                 ds                 p  mounted  fstype
0:r0   Connected  Secondary/Primary  UpToDate/UpToDate  C</pre>
<pre>[root@centos54-b ~]# mount /dev/drbd0 /export
mount: block device /dev/drbd0 is write-protected, mounting read-only
mount: Wrong medium type</pre>
<p>ในกรณีที่ต้องการเปลี่ยนให้เครื่องที่ 2 (centos54-b) ทำหน้าที่เป็น primary  เช่นในกรณีที่ต้องการซ่อมบำรุงเครื่องที่ 1 สามารถทำได้ดังนี้</p>
<p>บนเครื่องที่ 1 ปิดเซอร์วิส DRBD</p>
<pre>[root@centos54-a ~]# <strong>service drbd stop
</strong>Stopping all DRBD resources:
.
[root@centos54-a ~]# <strong>service drbd status
</strong>drbd not loaded</pre>
<p>ตรวจสอบสถานะบนเครื่องที่ 2 หลังจากปิดเซอร์วิสบนเครื่องที่ 1</p>
<pre>[root@centos54-b ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs            ro                 ds                 p  mounted  fstype
0:r0   WFConnection  <strong><span style="color: #0000ff;">Secondary</span></strong>/Unknown  UpToDate/DUnknown  C</pre>
<p>แม้เครื่อง Primary ปิดไปแล้ว บนเครื่องที่ 2 ที่ยังอยู่ในโหมด Secondary ก็ยัง mount ดิสก์ ไม่ได้</p>
<pre>[root@centos54-b ~]# <strong>mount /dev/drbd0 /export
</strong>mount: block device /dev/drbd0 is write-protected, mounting read-only
mount: Wrong medium type</pre>
<p>ต้องเปลี่ยนสถานะบนเครื่องที่ 2 ให้เป็น primary ด้วยคำสั่ง drbdadm primary</p>
<pre>[root@centos54-b ~]# <strong>drbdadm primary all</strong></pre>
<p>ตรวจสอบสถานะบนเครื่องที่ 2</p>
<pre>[root@centos54-b ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs            ro               ds                 p  mounted  fstype
0:r0   WFConnection  <span style="color: #0000ff;"><strong>Primary</strong></span>/Unknown  UpToDate/DUnknown  C</pre>
<p>เมื่ออยู่ในโหมด primary แล้ว ก็สามารถ mount ดิสก์ขึ้นมาใช้งานได้</p>
<pre>[root@centos54-b ~]# <strong>mount /dev/drbd0 /export
</strong>[root@centos54-b ~]# <strong>df -h /export
</strong>Filesystem            Size  Used Avail Use% Mounted on
/dev/drbd0            950M   18M  885M   2% /export</pre>
<p>ทดลองสร้างไฟล์ในดิสก์ drbd0</p>
<pre>[root@centos54-b ~]# <strong>cd /export/
</strong>[root@centos54-b export]# <strong>ls
</strong>lost+found
[root@centos54-b export]# <strong>echo "hello world from node 2" &gt; test-file-on-node-2.txt
</strong>[root@centos54-b export]# <strong>ls -l
</strong>total 20
drwx------ 2 root root 16384 Feb  6 15:46 lost+found
-rw-r--r-- 1 root root    24 Feb  6 17:17 <span style="color: #0000ff;"><strong>test-file-on-node-2.txt</strong></span></pre>
<p>รันเซอร์วิส DRBD บนเครื่องที่ 1 ขึ้นมาอีกครั้ง ตอนนี้เครื่องที่ 1 จะทำหน้าที่เป็น Secondary และจะทำการ replicate ข้อมูลมาจากเครื่องที่ 2 (Primary) โดยอัตโนมัติ</p>
<pre>[root@centos54-a ~]# <strong>service drbd start
</strong>Starting DRBD resources: [ d(r0) s(r0) n(r0) ].</pre>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                 ds                 p  mounted  fstype
0:r0   Connected  <strong><span style="color: #0000ff;">Secondary</span></strong>/Primary  UpToDate/UpToDate  C</pre>
<p>บนเครื่องที่ 2 เปลี่ยนให้เป็นโหมด Secondary</p>
<pre>[root@centos54-b ~]# <strong>drbdadm secondary all
</strong><span style="color: #ff0000;">0: State change failed: (-12) Device is held open by someone</span>
Command 'drbdsetup 0 secondary' terminated with exit code 11</pre>
<p>หากมีการเรียกใช้ดิสก์ drbd อยู่ จะไม่สามารถเปลี่ยนโหมดจาก Primary ไปเป็น Secondary ได้ ต้อง umount ดิสก์ออกไปก่อนถึงจะเปลี่ยนโหมดได้</p>
<pre>[root@centos54-b ~]# <strong>umount /export
</strong>[root@centos54-b ~]# <strong>drbdadm secondary all</strong></pre>
<p>ตรวจสอบสถานะบนเครื่องที่ 2</p>
<pre>[root@centos54-b ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                   ds                 p  mounted  fstype
0:r0   Connected  <span style="color: #0000ff;"><strong>Secondary</strong></span>/Secondary  UpToDate/UpToDate  C</pre>
<p>เปลี่ยนโหมดบนเครื่องที่ 1 ให้เป็น Primary เพื่อเรียกใช้ดิสก์ได้</p>
<pre>[root@centos54-a ~]# <strong>drbdadm primary all
</strong>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                 ds                 p  mounted  fstype
0:r0   Connected  <strong><span style="color: #0000ff;">Primary</span></strong>/Secondary  UpToDate/UpToDate  C</pre>
<p>mount ดิสก์ และตรวจสอบไฟล์ที่อยู่ใน drbd0 จะเห็นไฟล์ที่สร้างจากเครื่องที่ 2</p>
<pre>[root@centos54-a ~]# <strong>mount /dev/drbd0 /export
</strong>[root@centos54-a ~]# <strong>cd /export/
</strong>[root@centos54-a export]# ls -l
total 20
drwx------ 2 root root 16384 Feb  6 15:46 lost+found
-rw-r--r-- 1 root root    24 Feb  6 17:17 <strong><span style="color: #0000ff;">test-file-on-node-2.txt
</span></strong>[root@centos54-a export]# <strong>cat test-file-on-node-2.txt
</strong>hello world from node 2</pre>
<h4>ตรวจสอบไฟล์ /var/log/messages</h4>
<p>เมื่อมีปัญหาเกี่ยวกับการใช้ DBRD นอกจากการใช้คำสั่ง service เพื่อตรวจสอบสถานะแล้ว ไฟล์ /var/log/messages จะแสดงการเปลี่ยนแปลงทั้งหมดของ DRBD ที่เกิดขึ้น ซึ่งสามารถนำมาใช้ช่วยในการแก้ปัญหาได้</p>
<p>ตัวอย่างข้อความในไฟล์ /var/log/messages ที่เกิดขึ้น เมื่อมีการเปลี่ยนโหมด</p>
<pre>[root@centos54-a ~]# <strong>tail /var/log/messages
</strong>...
Feb  6 17:19:38 centos54-a kernel: block drbd0: peer( Primary -&gt; Secondary )
Feb  6 17:21:04 centos54-a kernel: block drbd0: role( Secondary -&gt; Primary )
...</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2010/02/install_and_configure_drbd">ติดตั้งและคอนฟิก DRBD</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/02/basic_using_drbd/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้งและคอนฟิก DRBD</title>
		<link>http://spalinux.com/2010/02/install_and_configure_drbd</link>
		<comments>http://spalinux.com/2010/02/install_and_configure_drbd#comments</comments>
		<pubDate>Sat, 06 Feb 2010 09:40:46 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Disk]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[Kernel]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[drbd]]></category>
		<category><![CDATA[linux ha]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1068</guid>
		<description><![CDATA[DRBD (Distributed Replicated Block Device) เป็นโปรแกรมเพื่อใช้ในการ replicate ข้อมูลดิสก์ที่อยู่คนละเครื่องกัน ผ่านทางเน็ตเวิร์ก โดยจะทำในระดับ block ของดิสก์ เมื่อมีการเปลี่ยนแปลงข้อมูลที่อยูในดิสก์เครื่องหนึ่ง (primary) การเปลี่ยนแปลงนั้นจะถูก replicate ไปยังอีกเครื่อง (secondary) โดยอัตโนมัติ DRBD ประกอบด้วยสองส่วนคือ 1. Kernel module &#8211; DRBD ทำหน้าที่ใน kernel โดยจะสร้าง virtual block device คั่นกลางระหว่าง physical disk กับ filesystem ที่สร้างอยู่ ไม่ว่าจะเป็น ext3, ext4, xfs 2. User space administration tools &#8211; เป็นโปรแกรมที่ช่วยในการจัดการ DRBD ได้ง่ายขึ้น หลักๆ จะเป็น drbdadm ในบทความนี้จะแสดงการติดตั้งโปรแกรม [...]]]></description>
			<content:encoded><![CDATA[<p>DRBD (Distributed Replicated Block Device) เป็นโปรแกรมเพื่อใช้ในการ replicate ข้อมูลดิสก์ที่อยู่คนละเครื่องกัน ผ่านทางเน็ตเวิร์ก โดยจะทำในระดับ block ของดิสก์</p>
<p>เมื่อมีการเปลี่ยนแปลงข้อมูลที่อยูในดิสก์เครื่องหนึ่ง (primary) การเปลี่ยนแปลงนั้นจะถูก replicate ไปยังอีกเครื่อง (secondary) โดยอัตโนมัติ</p>
<p>DRBD ประกอบด้วยสองส่วนคือ</p>
<p>1. Kernel module &#8211; DRBD ทำหน้าที่ใน kernel โดยจะสร้าง virtual block device คั่นกลางระหว่าง physical disk กับ filesystem ที่สร้างอยู่ ไม่ว่าจะเป็น ext3, ext4, xfs<br />
2. User space administration tools &#8211; เป็นโปรแกรมที่ช่วยในการจัดการ DRBD ได้ง่ายขึ้น หลักๆ จะเป็น drbdadm</p>
<p>ในบทความนี้จะแสดงการติดตั้งโปรแกรม DRBD และคอนฟิกเป็นแบบ Single-primary mode คือ ณ เวลาใดเวลาหนึ่ง มีเครื่องเดียวเท่านั้นที่สามารถ อ่าน เขียน ข้อมูลได้</p>
<p><span style="color: #ff0000;"><strong>คำเตือน ติดตั้งและคอนฟิก DRBD บนเครื่องทดสอบให้เข้าใจก่อน เพราะบางคำสั่งอาจกระทบข้อมูลดิสก์หรือ partition ที่มีอยู่ในเครื่องได้ ทำให้ข้อมูลเสียหายได้</strong></span></p>
<p><span id="more-1068"></span></p>
<h4>ระบบสำหรับการทดสอบ</h4>
<p>ในที่นี้จะติดตั้ง CentOS 5.4 พร้อมคอนฟิกให้สองเครื่องติดต่อ ping กันได้ และปิดคุณสมบัติ firewall ทั้งหมด</p>
<p><strong>เครื่องที่ 1</strong></p>
<ul>
<li>Hostname:   centos54-a.spalinux.com</li>
<li>IP Address: 10.3.3.51</li>
</ul>
<p><strong>เครื่องที่ 2</strong></p>
<ul>
<li>Hostname:   centos54-b.spalinux.com</li>
<li>IP Address: 10.3.3.52</li>
</ul>
<p>แก้ไขไฟล์ /etc/hosts เพื่อให้ทั้งสองเครื่องอ้างอิงจากชื่อเครื่องได้</p>
<p>ตัวอย่างคอนฟิกของเครื่องที่ 1</p>
<pre>[root@centos54-a ~]# <strong>hostname</strong>
centos54-a.spalinux.com</pre>
<pre>[root@centos54-a ~]# <strong>cat /etc/hosts
</strong># Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6</pre>
<pre>10.3.3.51       centos54-a centos54-a.spalinux.com
10.3.3.52       centos54-b centos54-b.spalinux.com</pre>
<p>ตัวอย่างคอนฟิกของเครื่องที่ 2</p>
<pre>[root@centos54-b ~]# <strong>hostname</strong>
centos54-b.spalinux.com</pre>
<pre>[root@centos54-b ~]# <strong>cat /etc/hosts
</strong># Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6</pre>
<pre>10.3.3.51       centos54-a centos54-a.spalinux.com
10.3.3.52       centos54-b centos54-b.spalinux.com</pre>
<p>ทั้งสองเครื่อง ต้องสร้าง partition สำหรับใช้เป็นดิสก์ DRBD โดยไม่ต้องสร้าง filesystem ใดๆ ทั้งสิ้นบน partition นี้ สมมติว่าเป็น /dev/sda5 บนทั้งสองเครื่อง</p>
<p>หมายเหตุ</p>
<ul>
<li>แนะนำให้สร้าง partition ทั้งสองเครื่องให้เหมือนกัน ขนาดเท่ากัน จะได้ง่ายต่อการคอนฟิก</li>
<li>สำหรับการทดสอบเริ่มต้น แนะนำให้สร้างขนาด partition เล็กๆ ก่อน จะได้ใช้เวลาในการ sync ข้อมูลไม่นานมากนัก ในบทความนี้สร้างประมาณ 1 GBytes</li>
</ul>
<h4>ติดตั้งโปรแกรม DRBD</h4>
<p>ไฟล์ติดตั้ง DRBD ในรูปแบบ rpm ของ CentOS 5.4 นั้น ไม่อยู่ในแผ่นดีวีดีติดตั้ง แต่จะอยู่ในส่วนของ extras สำหรับในเมืองไทยสามารถดาวน์โหลดได้จาก <a href="http://www.mirror.in.th/osarchive/centos/5.4/extras/">http://www.mirror.in.th/osarchive/centos/5.4/extras/</a></p>
<p>ดาวน์โหล์ด และติดตั้งไฟล์ rpm สองไฟล์ บนเครื่องทั้งสอง</p>
<ul>
<li>drbd83-8.3.2-6.el5_3.x86_64.rpm  &#8211; &#8220;User space administration tools&#8221;</li>
<li>kmod-drbd83-8.3.2-6.el5_3.x86_64.rpm  &#8211; &#8220;Kernel Module&#8221;</li>
</ul>
<p>ใช้คำสั่ง rpm เพื่อติดตั้ง</p>
<pre>[root@centos54-a ~]# <strong>rpm -ivh drbd83-8.3.2-6.el5_3.x86_64.rpm
</strong>Preparing...                ########################################### [100%]
   1:drbd83                 ########################################### [100%]
[root@centos54-a ~]# <strong>rpm -ivh kmod-drbd83-8.3.2-6.el5_3.x86_64.rpm
</strong>Preparing...                ########################################### [100%]
   1:kmod-drbd83            ########################################### [100%]</pre>
<h4>คอนฟิก DRBD บนเครื่องที่ 1 (primary)</h4>
<p>ไฟล์คอนฟิกหลักของ DRBD คือไฟล์ /etc/drbd.conf ต้องมีการแก้ไขไฟล์นี้ก่อนถึงจะเริ่มใช้งานได้ โดยมีไฟล์ตัวอย่างคอนฟิกอยู่ใน /usr/share/doc/drbd83/drbd.conf</p>
<p>ไฟล์คอนฟิก /etc/drbd.conf จากการติดตั้ง</p>
<pre>[root@centos54-a ~]# <strong>cat /etc/drbd.conf
</strong>#
# please have a a look at the example configuration file in
# /usr/share/doc/drbd83/drbd.conf
#</pre>
<p>สร้างไฟล์คอนฟิก /etc/drbd.conf บนเครื่องที่ 1 &#8220;centos54-a.spalinux.com&#8221; ดังนี้</p>
<pre>[root@centos54-a ~]# <strong>cat /etc/drbd.conf
</strong>global {
    usage-count no;
}</pre>
<pre>common {
    syncer { rate 10M; }
}</pre>
<pre>resource <strong><span style="color: #0000ff;">r0</span> </strong>{
    protocol C;</pre>
<pre>    net {
        cram-hmac-alg "sha1";
        shared-secret "<span style="color: #0000ff;"><strong>test1234</strong></span>";
    }</pre>
<pre>    on <strong><span style="color: #0000ff;">centos54-a.spalinux.com</span></strong> {
        device /dev/drbd0;
        <strong><span style="color: #0000ff;">disk /dev/sda5</span></strong>;
        <strong><span style="color: #0000ff;">address 10.3.3.51:8888</span></strong>;
        meta-disk internal;
    }</pre>
<pre>    on <strong><span style="color: #0000ff;">centos54-b.spalinux.com</span></strong> {
        device /dev/drbd0;
        <strong><span style="color: #0000ff;">disk /dev/sda5</span></strong>;
        <strong><span style="color: #0000ff;">address 10.3.3.52:8888</span></strong>;
        meta-disk internal;
    }
}</pre>
<p>คำอธิบายเบื้องต้น</p>
<ul>
<li>shared-secret เป็นการกำหนดรหัสของเครื่องที่สามารถ replicate ข้อมูลกันได้ </li>
<li>r0 เป็นชื่อ resource ของ DRBD สามารถตั้งเป็นชื่อใดๆ ก็ได้ เพื่อสื่อความหมาย</li>
<li>on ตามด้วยชื่อ hostname ที่ต้องการ replicate ข้อมูลกัน ส่วนในวงเล็บ { เป็นการกำหนดคอนฟิกของแต่ละเครื่อง</li>
<li>disk คือชื่อ partition ที่สร้างไว้สำหรับการทำ DRBD ในที่นี้คือ /dev/sda5</li>
</ul>
<p>ใช้คำสั่ง drbadm create-md เพื่อสร้าง meta data บน partition ที่จะทำเป็น DRBD</p>
<pre>[root@centos54-a ~]# <strong>drbdadm create-md all
</strong>Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.</pre>
<p>หาก partition ที่คอนฟิกเป็น DRBD มี filesystem อยู่ก่อนแล้ว จะไม่สามารถสร้าง DRBD ได้</p>
<pre>[root@centos54-a ~]# <strong>drbdadm create-md all
</strong>md_offset 1011671040
al_offset 1011638272
bm_offset 1011605504</pre>
<pre><span style="color: #ff0000;">Found ext3 filesystem</span> which uses 987964 kB
current configuration leaves usable 987896 kB</pre>
<pre>Device size would be truncated, which
would corrupt data and result in
'access beyond end of device' errors.
You need to either
   * use external meta data (recommended)
   * shrink that filesystem first
   * zero out the device (destroy the filesystem)
<span style="color: #ff0000;">Operation refused.</span></pre>
<pre>Command 'drbdmeta 0 v08 /dev/sda5 internal create-md' terminated with exit code 40
<span style="color: #ff0000;">drbdadm create-md r0: exited with code 40</span></pre>
<p>วิธีการแก้ไขคือต้องลบข้อมูลของ filesystem บน partition /dev/sda5 นี้ออก วิธีการง่ายสุดคือใช้คำสั่ง dd</p>
<p><span style="color: #ff0000;"><strong>คำเตือน คำสั่ง dd จะลบข้อมูลทั้งหมดบน partition ที่ระบุ</strong></span></p>
<pre>[root@centos54-a ~]# <strong>dd if=/dev/zero of=/dev/sda5
</strong>dd: writing to `/dev/sda5': No space left on device
1975933+0 records in
1975932+0 records out
1011677184 bytes (1.0 GB) copied, 87.2749 seconds, 11.6 MB/s</pre>
<p>แล้วถึงสามารถสร้าง meta data ของ DRBD ได้</p>
<pre>[root@centos54-a ~]# <strong>drbdadm create-md all
</strong>Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.</pre>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิส DRBD</p>
<pre>[root@centos54-a ~]# <strong>service drbd start
</strong>Starting DRBD resources: [ d(r0) s(r0) n(r0) ]..........
***************************************************************
 DRBD's startup script waits for the peer node(s) to appear.
 - In case this node was already a degraded cluster before the
   reboot the timeout is 0 seconds. [degr-wfc-timeout]
 - If the peer was available before the reboot the timeout will
   expire after 0 seconds. [wfc-timeout]
   (These values are for resource 'r0'; 0 sec -&gt; wait forever)
 To abort waiting enter 'yes' [  20]:<span style="color: #3366ff;"><strong><span style="color: #0000ff;">yes</span></strong></span></pre>
<p>ในครั้งแรกที่รันเซอร์วิส บนเครื่อง primary โปรแกรมจะรอให้เครื่อง peer (secondary) เข้ามาเชื่อมต่อ หากไม่ต้องการให้รอ ให้พิมพ์คำว่า &#8220;yes&#8221; แล้ว [Enter]</p>
<p>ใช้คำสั่ง service status เพื่อตรวจสอบสถานะของ DRBD</p>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs            ro                 ds                     p  mounted  fstype
0:r0   WFConnection  <span style="color: #0000ff;"><strong>Secondary</strong></span>/Unknown  <span style="color: #0000ff;"><strong>Inconsistent</strong></span>/DUnknown  C</pre>
<p>หรืออ่านจากไฟล์ /proc/drbd โดยตรง</p>
<pre>[root@centos54-a ~]# <strong>cat /proc/drbd</strong>
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
 0: cs:WFConnection ro:Secondary/Unknown ds:Inconsistent/DUnknown C r----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:987896</pre>
<p>สร้างไดเรคทอรี /export สำหรับทดสอบ mount เพื่อใช้ดิสก์ drbd ที่สร้างขึ้น</p>
<pre>[root@centos54-a ~]# <strong>mount /dev/drbd0 /export
</strong>mount: block device /dev/drbd0 is write-protected, mounting read-only
mount: Wrong medium type</pre>
<p>ดิสก์นี้ยังไม่สามารถใช้ได้ ต้องใช้คำสั่ง drbdadm primary คอนฟิกให้ดิสก์ drbd บนเครื่องนี้ทำหน้าที่เป็น primary เพื่อให้สามารถ อ่าน เขียน ข้อมูลจากดิสก์ได้</p>
<pre>[root@centos54-a ~]# <strong>drbdadm primary all
</strong><span style="color: #ff0000;">0: State change failed: (-2) Refusing to be Primary without at least one UpToDate disk
</span>Command 'drbdsetup 0 primary' terminated with exit code 17</pre>
<p>หากเป็นการเรียกใช้ครั้งแรก ต้องระบุออปชั่นดังนี้</p>
<pre>[root@centos54-a ~]# <strong>drbdadm -- --overwrite-data-of-peer primary all
</strong>[root@centos54-a ~]#</pre>
<p>ตรวจสอบสถานะ drbd อีกครั้ง สังเกตว่า ฟิลด์ ro จะเปลี่ยนจาก Seconday เป็น Primary และฟิลด์ ds จะเปลี่ยนจาก Inconsistent เป็น UpToDate</p>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs            ro               ds                 p  mounted  fstype
0:r0   WFConnection  <span style="color: #0000ff;"><strong>Primary</strong></span>/Unknown  <strong><span style="color: #0000ff;">UpToDate</span></strong>/DUnknown  C</pre>
<p>ทดสอบการ mount ดิสก์อีกครั้ง</p>
<pre>[root@centos54-a ~]# <strong>mount /dev/drbd0 /export
</strong>mount: you must specify the filesystem type</pre>
<p>ก็ยังไม่สามารถ mount ได้ เพราะยังไม่มี filesystem บน /dev/drbd0</p>
<p>รันคำสั่ง mkfs.ext3 เพื่อสร้าง filesystem แบบ ext3</p>
<pre>[root@centos54-a ~]# <strong>mkfs.ext3 /dev/drbd0
</strong>mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
123648 inodes, 246974 blocks
12348 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=255852544
8 block groups
32768 blocks per group, 32768 fragments per group
15456 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376</pre>
<pre>Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done</pre>
<pre>This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.</pre>
<p>ทดสอบการ mount อีกครั้ง จะสามารถใช้งานได้แล้ว</p>
<pre>[root@centos54-a ~]# <strong>mount /dev/drbd0 /export</strong></pre>
<p>ตรวจสอบสถานะ DRBD</p>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs            ro               ds                 p  mounted  fstype
0:r0   WFConnection  Primary/Unknown  UpToDate/DUnknown  C  <span style="color: #0000ff;"><strong>/export  ext3</strong></span></pre>
<h4>คอนฟิก DRBD บนเครื่องที่ 2 (secondary)</h4>
<p>สร้างไฟล์คอนฟิก /etc/drbd.conf บนเครื่องที่ 2 เหมือนกับไฟล์ในเครื่องที่ 1</p>
<pre>[root@centos54-b ~]# <strong>cat /etc/drbd.conf
</strong>global {
    usage-count no;
}</pre>
<pre>common {
    syncer { rate 10M; }
}</pre>
<pre>resource r0 {
    protocol C;</pre>
<pre>    net {
        cram-hmac-alg "sha1";
        shared-secret "test1234";
    }</pre>
<pre>    on centos54-a.spalinux.com {
        device /dev/drbd0;
        disk /dev/sda5;
        address 10.3.3.51:8888;
        meta-disk internal;
    }</pre>
<pre>    on centos54-b.spalinux.com {
        device /dev/drbd0;
        disk /dev/sda5;
        address 10.3.3.52:8888;
        meta-disk internal;
    }
}</pre>
<p>ใช้คำสั่ง drbadm create-md เพื่อสร้าง meta data บน partition ที่จะทำเป็น DRBD</p>
<pre>[root@centos54-b ~]# <strong>drbdadm create-md all
</strong>Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.</pre>
<p>เช่นเดียวกัน หากมี filesystem อยู่บน partition ก่อนแล้ว ต้องใช้คำสั่ง dd เพื่อลบข้อมูลออก</p>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิส DRBD</p>
<pre>[root@centos54-b ~]# <strong>service drbd start
</strong>Starting DRBD resources: [ d(r0) s(r0) n(r0) ].</pre>
<p>เมื่อเริ่มต้นรันเซอร์วิส DRBD บนเครื่องที่ 2 จะเป็นการเริ่ม replicate ข้อมูลจากเครื่องที่ 1</p>
<p>ตรวจสอบสถานะ DRBD บนเครื่องที่ 2</p>
<pre>[root@centos54-b ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs          ro                 ds                     p  mounted  fstype
...    <strong><span style="color: #0000ff;">sync'ed:    42.2%</span> </strong>             (576248/987896)K
0:r0   <strong><span style="color: #0000ff;">SyncTarget</span></strong>  <strong><span style="color: #0000ff;">Secondary</span></strong>/Primary  <span style="color: #0000ff;"><strong>Inconsistent</strong></span>/UpToDate  C</pre>
<p>ตรวจสอบสถานะ DRBD บนเครื่องที่ 1</p>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs          ro                 ds                     p  mounted  fstype
...    <strong><span style="color: #0000ff;">sync'ed:    43.0%</span></strong>              (567032/987896)K
0:r0   <strong><span style="color: #0000ff;">SyncSource</span></strong>  Primary/<strong><span style="color: #0000ff;">Secondary</span>  </strong>UpToDate/<strong><span style="color: #0000ff;">Inconsistent</span></strong>  C  /export  ext3</pre>
<p>เมื่อ replicate ข้อมูลเรียบร้อย (synced) ข้อมูลแล้ว สถานะจะเป็นดังนี้</p>
<p>ตรวจสอบสถานะ DRBD บนเครื่องที่ 2 เมื่อ synced ข้อมูลเรียบร้อย</p>
<pre>[root@centos54-b ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                 ds                 p  mounted  fstype
0:r0   <strong><span style="color: #0000ff;">Connected</span>  <span style="color: #0000ff;">Secondary</span></strong>/Primary  <strong><span style="color: #0000ff;">UpToDate</span></strong>/UpToDate  C</pre>
<p>ตรวจสอบสถานะ DRBD บนเครื่องที่ 1 เมื่อ synced ข้อมูลเรียบร้อย</p>
<pre>[root@centos54-a ~]# <strong>service drbd status
</strong>drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by mockbuild@v20z-x86-64.home.local, 2009-08-29 14:07:55
m:res  cs         ro                 ds                 p  mounted  fstype
0:r0   <strong><span style="color: #0000ff;">Connected</span></strong>  Primary/<strong><span style="color: #0000ff;">Secondary</span></strong>  UpToDate/<strong><span style="color: #0000ff;">UpToDate</span></strong>  C  /export  ext3</pre>
<p>หลังจาก synced ข้อมูลระหว่างเครื่องเรียบร้อย เมื่อมีการเปลี่ยนแปลงข้อมูลในดิสก์บนเครื่องที่ 1 (primary) การเปลี่ยนแปลงนั้นจะถูก replicate ไปยังเครื่องที่ 2 (secondary) โดยอัตโนมัติ</p>
<p>ตัวอย่างการใช้คำสั่ง tcpdump  ตรวจสอบ packet ที่ส่งระหว่างเครื่องเพื่อการ replicate ข้อมูลของ DRBD</p>
<pre>[root@centos54-b ~]# <strong>tcpdump -i eth0 -l -nn | grep 8888
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
15:51:39.815802 IP 10.3.3.52.8888 &gt; 10.3.3.51.42180: P 2834377596:2834377604(8) ack 2893184807 win 46 &lt;nop,nop,timestamp 1772852 1818781&gt;
15:51:39.816356 IP 10.3.3.51.42180 &gt; 10.3.3.52.8888: P 1:9(8) ack 8 win 3216 &lt;nop,nop,timestamp 1828655 1772852&gt;
15:51:39.816394 IP 10.3.3.52.8888 &gt; 10.3.3.51.42180: . ack 9 win 46 &lt;nop,nop,timestamp 1772852 1828655&gt;
15:51:44.888876 IP 10.3.3.1.4117 &gt; 10.3.3.51.22: P 1560:1612(52) ack 1629 win 64271
15:51:49.815252 IP 10.3.3.51.42180 &gt; 10.3.3.52.8888: P 9:17(8) ack 8 win 3216 &lt;nop,nop,timestamp 1838655 1772852&gt;
15:51:49.815330 IP 10.3.3.52.8888 &gt; 10.3.3.51.42180: . ack 17 win 46 &lt;nop,nop,timestamp 1782853 1838655&gt;
15:51:49.815666 IP 10.3.3.52.8888 &gt; 10.3.3.51.42180: P 8:16(8) ack 17 win 46 &lt;nop,nop,timestamp 1782853 1838655&gt;
15:51:49.847300 IP 10.3.3.51.42180 &gt; 10.3.3.52.8888: . ack 16 win 3216 &lt;nop,nop,timestamp 1838696 1782853&gt;
15:51:50.937877 IP 10.3.3.51.8888 &gt; 10.3.3.52.40284: . 3903780263:3903781711(1448) ack 2834246899 win 501 &lt;nop,nop,timestamp 1839875 1683335&gt;
...
<strong><span style="color: #0000ff;">[Ctrl-C]</span></strong></pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://www.drbd.org/" target="_blank">DRBD</a></li>
<li><a href="http://www.mirror.in.th/osarchive/centos/5.4/extras/" target="_blank">CentOS 5.4 extras</a></li>
<li><a href="http://spalinux.com/2010/02/basic_using_drbd">การใช้งาน DRBD เบื้องต้น</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2010/02/install_and_configure_drbd/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>0</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>
		<item>
		<title>แก้ไข static route บนลีนุกซ์</title>
		<link>http://spalinux.com/2009/09/add_delete_static_route_on_linux</link>
		<comments>http://spalinux.com/2009/09/add_delete_static_route_on_linux#comments</comments>
		<pubDate>Sat, 26 Sep 2009 09:22:04 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Linux Installation]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[linux static route]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=932</guid>
		<description><![CDATA[บทความนี้อธิบายการแก้ไข static route บน ลีนุกซ์ โดยจะมีทั้งการแสดง routing tablle ที่มีอยู่ การเพิ่ม ลบ route รวมทั้งวิธีการคอนฟิกให้ตอนบู๊ตเครื่อง ให้คอนฟิก static route โดยอัตโนมัติ แสดง routing table ใช้คำสั่ง netstat -rn เพื่อแสดง routing table ของเครื่อง [root@fc11-64a ~]# netstat -rn Kernel IP routing table Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface 192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0 0.0.0.0         192.168.3.1     0.0.0.0         UG        [...]]]></description>
			<content:encoded><![CDATA[<p>บทความนี้อธิบายการแก้ไข static route บน ลีนุกซ์ โดยจะมีทั้งการแสดง routing tablle ที่มีอยู่ การเพิ่ม ลบ route รวมทั้งวิธีการคอนฟิกให้ตอนบู๊ตเครื่อง ให้คอนฟิก static route โดยอัตโนมัติ</p>
<p><span id="more-932"></span></p>
<h4>แสดง routing table</h4>
<p>ใช้คำสั่ง netstat -rn เพื่อแสดง routing table ของเครื่อง</p>
<pre>[root@fc11-64a ~]# <strong>netstat -rn
</strong>Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.3.1     0.0.0.0         UG        0 0          0 eth0</pre>
<p>อีกคำสั่งหนึ่งที่ให้ผลลัพธ์ใกล้เคียงกันคือคำสั่ง route -n</p>
<pre>[root@fc11-64a ~]# <strong>route -n
</strong>Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.3.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.3.1     0.0.0.0         UG    0      0        0 eth0</pre>
<h4>เพิ่ม static route</h4>
<p>การเพิ่ม static route ไปยัง subnet สามารถทำได้โดยใช้คำสั่ง route add ระบุออปชั่น &#8216;-net&#8217; ตามด้วย subnet และ netmask ที่ต้องการ สุดท้ายระบุว่าไปทาง router หรือ gateway ตามหลัง ออปชั่น &#8216;gw&#8217;</p>
<pre>[root@fc11-64a ~]# <strong>route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.3.2</strong></pre>
<pre>[root@fc11-64a ~]# <strong>netstat -rn
</strong>Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
<span style="color: #0000ff;"><strong>192.168.5.0     192.168.3.2     255.255.255.0   UG    0      0        0 eth0
</strong></span>192.168.3.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.3.1     0.0.0.0         UG    0      0        0 eth0</pre>
<p>การเพิ่ม static route ไปยัง host หรือเครื่อง ip address ที่ระบุ ทำได้โดยใช้คำสั่ง route add ระบุออปชั่น &#8216;-host&#8217; ตามด้วย ip address ปลายทาง สุดท้ายระบุว่าไปทาง router หรือ gateway ตามหลัง ออปชั่น &#8216;gw&#8217;</p>
<pre>[root@fc11-64a ~]# <strong>route add -host 192.168.5.10 gw 192.168.3.3</strong></pre>
<pre>[root@fc11-64a ~]# <strong>netstat -rn
</strong>Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
<strong><span style="color: #0000ff;">192.168.5.10    192.168.3.3     255.255.255.255 UGH       0 0          0 eth0
</span></strong>192.168.5.0     192.168.3.2     255.255.255.0   UG        0 0          0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.3.1     0.0.0.0         UG        0 0          0 eth0</pre>
<p>การเพิ่ม default gateway ทำได้โดย ใช้คำสั่ง route add ระบุออปชั่น &#8216;default gw&#8217; แล้วตามด้วย ip address ของ gateway หรือ router</p>
<pre>[root@fc11-64a ~]# <strong>route add default gw 192.168.3.4</strong></pre>
<pre>[root@fc11-64a ~]# <strong>netstat -rn
</strong>Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.5.10    192.168.3.3     255.255.255.255 UGH       0 0          0 eth0
192.168.5.0     192.168.3.2     255.255.255.0   UG        0 0          0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
<strong><span style="color: #0000ff;">0.0.0.0         192.168.3.4     0.0.0.0         UG        0 0          0 eth0
</span></strong>0.0.0.0         192.168.3.1     0.0.0.0         UG        0 0          0 eth0</pre>
<h4>ลบ static route</h4>
<p>การลบ static route ไปยัง subnet สามารถทำได้โดยใช้คำสั่ง route del ระบุออปชั่น &#8216;-net&#8217; ตามด้วย subnet และ netmask ที่ต้องการลบ และ &#8216;gw&#8217; ที่ชี้ไป</p>
<pre>[root@fc11-64a ~]# <strong>route del -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.3.2</strong></pre>
<p>การลบ static route ไปยัง host หรือเครื่อง ip address ที่ระบุ ทำได้โดยใช้คำสั่ง route del ระบุออปชั่น &#8216;-host&#8217; ตามด้วย ip address ปลายทาง สุดท้ายระบุว่าไปทาง router หรือ gateway ตามหลัง ออปชั่น &#8216;gw&#8217;</p>
<pre>[root@fc11-64a ~]# <strong>route del -host 192.168.5.10 gw 192.168.3.3</strong></pre>
<p>การลบ default gateway ทำได้โดย ใช้คำสั่ง route del ระบุออปชั่น &#8216;default gw&#8217; แล้วตามด้วย ip address ของ gateway หรือ router ที่ต้องการลบ</p>
<pre>[root@fc11-64a ~]# <strong>route del default gw 192.168.3.4</strong></pre>
<h4>ไฟล์ static-routes</h4>
<p>หากต้องการให้เครื่องลีนุกซ์คอนฟิกเพิ่ม static routes ที่ต้องการตอนบู๊ตเครื่องโดยอัตโนมัติ สามารถทำได้โดยการใส่ ข้อมูล route ไว้ในไฟล์ /etc/sysconfig/static-routes</p>
<p>ตัวอย่างไฟล์ สำหรับเพิ่ม static-routes ไปยัง subnet และ host ตามตัวอย่างด้านบน ให้คอนฟิกตอนบู๊ตเครื่อง</p>
<pre>[root@fc11-64a ~]# <strong>cat /etc/sysconfig/static-routes
</strong>any net 192.168.5.0 netmask 255.255.255.0 gw 192.168.3.2
any host 192.168.5.10 gw 192.168.3.3</pre>
<p>สำหรับ default gateway ต้องใส่เป็น ตัวแปรชื่อ &#8220;GATEWAY&#8221; ไว้ในไฟล์ /etc/sysconfig/network หรือไฟล์ /etc/sysconfig/network-scripts/ifcfg-eth0 ตัวอย่างเช่น</p>
<pre>[root@fc11-64a ~]# <strong>cat /etc/sysconfig/network
</strong>NETWORKING=yes
HOSTNAME=fc11-64a.spalinux.com
<strong><span style="color: #0000ff;">GATEWAY=192.168.3.4</span></strong></pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/02/configure_linux_to_be_router">คอนฟิกลีนุกซ์ทำหน้าที่เป็น Router</a></li>
<li><a href="http://spalinux.com/2008/10/configure_policy_based_routing_on_linux">คอนฟิก Policy Based Routing บนลีนุกซ์</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/09/add_delete_static_route_on_linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง Cacti บน Fedora 11 ตอนที่ 3</title>
		<link>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_3</link>
		<comments>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_3#comments</comments>
		<pubDate>Sat, 18 Jul 2009 09:52:26 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[install cacti]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=874</guid>
		<description><![CDATA[ขั้นตอนนี้จะเป็นการคอนฟิก Cacti ผ่านหน้าเว็บ ซึ่งเป็นค่าคอนฟิกต่างๆ ที่ใช้รัน   เลือกชนิดการติดตั้ง ถ้าเป็นการติดตั้งใหม่ เลือกเป็น &#8220;New Install&#8221;   หน้าเว็บจะแสดงโปรแกรมต่างๆ ที่ Cacti เรียกใช้ หากมีครบทุกอย่างก็สามารถกดปุ่ม [Finish] ได้      การล็อกอินครั้งแรก ใส่ User Name เป็น &#8220;admin&#8221; โดยไม่ต้องใส่ Password    เพื่อความปลอดภัย ในการล็อกอินครั้งแรก โปรแกรม Cacti จะบังคับให้เปลียน Password   หลังจากล็อกอินเรียบร้อยแล้ว ก็จะขึ้นหน้าเว็บของ Cacti   เปิดการ polling การติดตั้ง cacti โดยใช้ไฟล์ rpm จะติดตั้ง cron สำหรับการ poll data ทุกๆ 5 นาที ไว้ในไฟล์ /etc/cron.d/cacti เพียงแต่โดยดีฟอลต์จะปิดไว้ [...]]]></description>
			<content:encoded><![CDATA[<p>ขั้นตอนนี้จะเป็นการคอนฟิก Cacti ผ่านหน้าเว็บ ซึ่งเป็นค่าคอนฟิกต่างๆ ที่ใช้รัน</p>
<p><span id="more-874"></span></p>
<p><img title="Cacti Web Install - Step 1" src="http://spalinux.com/wp-content/uploads/2009/07/01_cacti_install_step-1.png" alt="Cacti Web Install - Step 1" width="816" height="571" /></p>
<p> </p>
<p>เลือกชนิดการติดตั้ง ถ้าเป็นการติดตั้งใหม่ เลือกเป็น &#8220;New Install&#8221;</p>
<p><img title="Cacti Web Install - Step 2" src="http://spalinux.com/wp-content/uploads/2009/07/02_cacti_install_step-2.png" alt="Cacti Web Install - Step 2" width="816" height="571" /></p>
<p> </p>
<p>หน้าเว็บจะแสดงโปรแกรมต่างๆ ที่ Cacti เรียกใช้ หากมีครบทุกอย่างก็สามารถกดปุ่ม [Finish] ได้ </p>
<p><img class="alignnone size-full wp-image-878" title="Cacti Web Install - Step 3" src="http://spalinux.com/wp-content/uploads/2009/07/03_cacti_install_step-3.png" alt="Cacti Web Install - Step 3" width="816" height="571" /></p>
<p> </p>
<p>  การล็อกอินครั้งแรก ใส่ User Name เป็น &#8220;admin&#8221; โดยไม่ต้องใส่ Password </p>
<p><img title="Cacti - User Login" src="http://spalinux.com/wp-content/uploads/2009/07/04_cacti_user_login.png" alt="Cacti - User Login" width="816" height="571" /></p>
<p> </p>
<p>เพื่อความปลอดภัย ในการล็อกอินครั้งแรก โปรแกรม Cacti จะบังคับให้เปลียน Password</p>
<p><img title="Cacti Forced Password Change" src="http://spalinux.com/wp-content/uploads/2009/07/05_cacti_forced_password_change.png" alt="Cacti Forced Password Change" width="816" height="571" /></p>
<p> </p>
<p>หลังจากล็อกอินเรียบร้อยแล้ว ก็จะขึ้นหน้าเว็บของ Cacti</p>
<p><img title="Cacti Web Console" src="http://spalinux.com/wp-content/uploads/2009/07/06_cacti_web_console.png" alt="Cacti Web Console" width="816" height="571" /></p>
<p> </p>
<h4>เปิดการ polling</h4>
<p>การติดตั้ง cacti โดยใช้ไฟล์ rpm จะติดตั้ง cron สำหรับการ poll data ทุกๆ 5 นาที ไว้ในไฟล์ /etc/cron.d/cacti เพียงแต่โดยดีฟอลต์จะปิดไว้ โดยใส่เครื่องหมาย &#8216;#&#8217; ไว้หน้าบรรทัด</p>
<pre>[root@fc11-64min ~]# <strong>cat /etc/cron.d/cacti
</strong><span style="color: #0000ff;">#</span>*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php &gt; /dev/null 2&gt;&amp;1</pre>
<p>ต้องแก้ไขไฟล์นี้โดยเอาเครื่องหมาย &#8216;#&#8217; ออก</p>
<pre>[root@fc11-64min ~]# <strong>cat /etc/cron.d/cacti
</strong>*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php &gt; /dev/null 2&gt;&amp;1 </pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_1">ติดตั้ง Cacti บน Fedora 11 ตอนที่ 1</a></li>
<li><a href="http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_2">ติดตั้ง Cacti บน Fedora 11 ตอนที่ 2</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง Cacti บน Fedora 11 ตอนที่ 2</title>
		<link>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_2</link>
		<comments>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_2#comments</comments>
		<pubDate>Sat, 18 Jul 2009 09:30:56 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[install cacti]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=863</guid>
		<description><![CDATA[หลังจากติดตั้งไฟล์โปรแกรม cacti เรียบร้อยแล้ว ต้องแก้ไขคอนฟิกไฟล์รวมทั้งสร้าง database เพื่อใช้ในการเก็บข้อมูลของ cacti เองด้วย คอนฟิกเว็บเซิร์ฟเวอร์ในส่วนของ cacti ส่วนแรกคือคอนฟิกของเว็บเซิร์ฟเวอร์ โดยดีฟอลต์จากการติดตั้ง cacti โดยใช้ไฟล์ rpm ของ Fedora 11 จะมีคอนฟิกเว็บในส่วนของ cacti สร้างเป็นไฟล์ชื่อ /etc/httpd/conf.d/cacti.conf [root@fc11-64min ~]# cat /etc/httpd/conf.d/cacti.conf # # Cacti: An rrd based graphing tool # Alias /cacti    /usr/share/cacti &#60;Directory /usr/share/cacti/&#62;         Order Deny,Allow         Deny from all         Allow from 127.0.0.1 &#60;/Directory&#62; ความหมายของคอนฟิกไฟล์ด้านบนคือ ผู้ใช้สามารถเรียกใช้เว็บโปรแกรม cati [...]]]></description>
			<content:encoded><![CDATA[<p>หลังจากติดตั้งไฟล์โปรแกรม cacti เรียบร้อยแล้ว ต้องแก้ไขคอนฟิกไฟล์รวมทั้งสร้าง database เพื่อใช้ในการเก็บข้อมูลของ cacti เองด้วย</p>
<p><span id="more-863"></span></p>
<h4>คอนฟิกเว็บเซิร์ฟเวอร์ในส่วนของ cacti</h4>
<p>ส่วนแรกคือคอนฟิกของเว็บเซิร์ฟเวอร์ โดยดีฟอลต์จากการติดตั้ง cacti โดยใช้ไฟล์ rpm ของ Fedora 11 จะมีคอนฟิกเว็บในส่วนของ cacti สร้างเป็นไฟล์ชื่อ /etc/httpd/conf.d/cacti.conf</p>
<pre>[root@fc11-64min ~]# <strong>cat /etc/httpd/conf.d/cacti.conf
</strong>#
# Cacti: An rrd based graphing tool
#
Alias /cacti    /usr/share/cacti</pre>
<pre>&lt;Directory /usr/share/cacti/&gt;
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
&lt;/Directory&gt;</pre>
<p>ความหมายของคอนฟิกไฟล์ด้านบนคือ ผู้ใช้สามารถเรียกใช้เว็บโปรแกรม cati โดยใส่ path เป็น /cacti เช่น http://&lt;ip-address&gt;/cacti/ แต่ดีฟอลต์จะอนุญาตให้เรียกมาจากเครื่อง ip 127.0.0.1 หรือตัวมันเองเท่านั้น</p>
<p>ถ้าต้องการแก้ไขให้เรียกเว็บ cacti จากเครื่องอื่นได้ ต้องแก้ไขคอนฟิกไฟล์นี้เป็น</p>
<pre>[root@fc11-64min ~]# <strong>cat /etc/httpd/conf.d/cacti.conf
</strong>#
# Cacti: An rrd based graphing tool
#
Alias /cacti    /usr/share/cacti</pre>
<pre>&lt;Directory /usr/share/cacti/&gt;
<span style="color: #0000ff;">        Order Allow,Deny
        Allow from all
</span>&lt;/Directory&gt;</pre>
<p>หลังแก้ไขไฟล์คอนฟิกของเว็บเซิร์ฟเวอร์ ต้องใช้คำสั่ง service เพื่อรีสตาร์ตให้คอนฟิกใหม่มีผล</p>
<pre>[root@fc11-64min Packages]# <strong>service httpd restart
</strong>Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]</pre>
<p>ทดลองเรียกเว็บ cacti ผ่าน web browser</p>
<p><img title="01 - Cannot connect database" src="http://spalinux.com/wp-content/uploads/2009/07/01-cacti-error-cannot-conne.png" alt="01 - Cannot connect database" width="816" height="255" /></p>
<h4>สร้างฐานข้อมูลของ cacti</h4>
<p>จากตัวอย่างด้านบน มี error เกิดขึ้น ยังไม่สามารถใช้งานได้</p>
<pre><span style="color: #ff0000;">FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'</span></pre>
<p>คือต้องสร้าง user, database และ table สำหรับเก็บข้อมูลของ cacti ใน MySQL ก่อน</p>
<p>คอนฟิกของ cacti ในส่วน database จะถูกเก็บอยู่ในไฟล์ /etc/cacti/db.php</p>
<pre>[root@fc11-64min ~]# <strong>cat /etc/cacti/db.php
</strong>&lt;?php
...
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";</pre>
<pre>/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";</pre>
<pre>?&gt;</pre>
<p><strong>หมายเหตุ </strong>ในที่นี้จะสร้าง database และ user ตามค่าดีฟอลต์เลย ซึ่งเหมาะสำหรับการทดสอบเพื่อเรียนรู้โปรแกรม cacti แต่ถ้านำไปใช้จริง production แนะนำให้เปลี่ยนค่าตัวแปรเหล่านี้เพื่อความปลอดภัย</p>
<p>ขั้นแรกต้องสร้าง database ให้ cacti ก่อน โดยสร้างชื่อตามตัวแปร $database_default</p>
<p>ในที่นี้จะใช้คำสั่ง mysql สร้างเลย คุณสามารถใช้โปรแกรมอื่นๆ ได้เช่น phpmyadmin</p>
<pre>[root@fc11-64min ~]# <strong>mysql -u root -p
</strong>Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 140
Server version: 5.1.32 Source distribution</pre>
<pre>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.</pre>
<pre>mysql&gt; <strong>CREATE DATABASE <span style="color: #0000ff;">cacti</span>;
</strong>Query OK, 1 row affected (0.00 sec)</pre>
<pre>mysql&gt;</pre>
<p>ขั้นต่อไปต้องสร้าง user และ password สำหรับการเชื่อมเข้า database ตามค่าตัวแปร $database_username, $database_password</p>
<pre>mysql&gt; <strong>GRANT ALL ON cacti.* TO <span style="color: #0000ff;">cactiuser </span>IDENTIFIED BY '<span style="color: #0000ff;">cactiuser</span>';
</strong>Query OK, 0 rows affected (0.09 sec)</pre>
<pre>mysql&gt; <strong>quit
</strong>Bye</pre>
<h4>สร้าง table ใน cacti database</h4>
<p>สุดท้ายต้องสร้าง table ต่างๆ เพื่อเก็บค่าของ cacti โดยสามารถใช้ไฟล์โครงสร้าง table ที่ติดตั้งมาให้อยู่แล้วใน /usr/share/doc/cacti-0.8.7d/cacti.sql</p>
<pre>[root@fc11-64min ~]# <strong>cat /usr/share/doc/cacti-0.8.7d/cacti.sql | mysql -u cactiuser -p cacti
</strong>Enter password:
[root@fc11-64min ~]#</pre>
<p>ทดลองใช้ user ที่สร้างขึ้นเข้า database</p>
<pre>[root@fc11-64min ~]# <strong>mysql -u cactiuser -p
</strong>Enter password:</pre>
<pre>Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 142
Server version: 5.1.32 Source distribution</pre>
<pre>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.</pre>
<pre>mysql&gt; <strong>SHOW DATABASES;
</strong>+--------------------+
| Database           |
+--------------------+
| information_schema |
| <strong><span style="color: #0000ff;">cacti</span></strong>              |
+--------------------+
2 rows in set (0.08 sec)</pre>
<pre>mysql&gt; <strong>CONNECT cacti;
</strong>Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A</pre>
<pre>Connection id:    149
Current database: cacti</pre>
<pre>mysql&gt; <strong>SHOW TABLES;
</strong>+---------------------------+
| Tables_in_cacti           |
+---------------------------+
| cdef                      |
| cdef_items                |
| colors                    |
| data_input                |
| data_input_data           |
| data_input_fields         |
| data_local                |
| data_template             |
| data_template_data        |
| data_template_data_rra    |
| data_template_rrd         |
| graph_local               |
| graph_template_input      |
| graph_template_input_defs |
| graph_templates           |
| graph_templates_gprint    |
| graph_templates_graph     |
| graph_templates_item      |
| graph_tree                |
| graph_tree_items          |
| host                      |
| host_graph                |
| host_snmp_cache           |
| host_snmp_query           |
| host_template             |
| host_template_graph       |
| host_template_snmp_query  |
| poller                    |
| poller_command            |
| poller_item               |
| poller_output             |
| poller_reindex            |
| poller_time               |
| rra                       |
| rra_cf                    |
| settings                  |
| settings_graphs           |
| settings_tree             |
| snmp_query                |
| snmp_query_graph          |
| snmp_query_graph_rrd      |
| snmp_query_graph_rrd_sv   |
| snmp_query_graph_sv       |
| user_auth                 |
| user_auth_perms           |
| user_auth_realm           |
| user_log                  |
| version                   |
+---------------------------+
48 rows in set (0.00 sec)</pre>
<pre>mysql&gt; <strong>quit</strong>
Bye
[root@fc11-64min ~]#</pre>
<p>เปิด web browser อีกครั้ง เรียกไปที่ http://&lt;ip-address&gt;/cacti/ หน้าจอจะ redirect ไปยังหน้าสำหรับการติดตั้งต่อไป</p>
<p><img title="Cacti Installation Guide" src="http://spalinux.com/wp-content/uploads/2009/07/02-cacti-installation-guide.png" alt="Cacti Installation Guide" width="816" height="571" /></p>
<p> </p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_1">ติดตั้ง Cacti บน Fedora 11 ตอนที่ 1</a></li>
<li><a href="http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_3">ติดตั้ง Cacti บน Fedora 11 ตอนที่ 3</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง Cacti บน Fedora 11 ตอนที่ 1</title>
		<link>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_1</link>
		<comments>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_1#comments</comments>
		<pubDate>Sat, 18 Jul 2009 08:45:34 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[install cacti]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=859</guid>
		<description><![CDATA[Cacti จัดเป็นโปรแกรมทางด้าน Network Management อย่างหนึ่ง คุณสมบัติหลักๆ คือสามารถไปดึงค่าต่างๆ จากอุปกรณ์ network ไม่ว่าจะเป็น Server, Router, Switch ผ่านทาง Poller  นำข้อมูลมาเก็บไว้ใน Data Storage  แล้วสามารถนำค่ามา plot เป็นกราฟ โดยใช้ RRDTool (ซึ่งเป็นโปรแกรมสร้างกราฟเดียวกันกับ MRTG) ในตอนที่ 1 จะอธิบายวิธีการติดตั้งไฟล์ที่จำเป็นและ Cacti บน Fedora 11 (x86_64) โดยทดสอบบนเครื่องที่ ติดตั้ง Fedora 11 แบบประหยัดพื้นที่สุด ก่อนการติดตั้ง Cacti ได้นั้น ในเครื่องต้องมี Apache, PHP, MySQL, net-snmp ติดตั้งอยู่ก่อนแล้ว ถ้าขาดโปรแกรมใดไป คำสั่ง rpm จะไม่ยอมให้ติดตั้ง ตัวอย่าง error เมื่อขาดโปรแกรมที่จำเป็นต่อ cacti [...]]]></description>
			<content:encoded><![CDATA[<p>Cacti จัดเป็นโปรแกรมทางด้าน Network Management อย่างหนึ่ง คุณสมบัติหลักๆ คือสามารถไปดึงค่าต่างๆ จากอุปกรณ์ network ไม่ว่าจะเป็น Server, Router, Switch ผ่านทาง Poller  นำข้อมูลมาเก็บไว้ใน Data Storage  แล้วสามารถนำค่ามา plot เป็นกราฟ โดยใช้ RRDTool (ซึ่งเป็นโปรแกรมสร้างกราฟเดียวกันกับ MRTG)</p>
<p>ในตอนที่ 1 จะอธิบายวิธีการติดตั้งไฟล์ที่จำเป็นและ Cacti บน Fedora 11 (x86_64) โดยทดสอบบนเครื่องที่ <a href="http://spalinux.com/2009/06/install_minimal_fedora_11">ติดตั้ง Fedora 11 แบบประหยัดพื้นที่สุด</a></p>
<p><span id="more-859"></span></p>
<p>ก่อนการติดตั้ง Cacti ได้นั้น ในเครื่องต้องมี Apache, PHP, MySQL, net-snmp ติดตั้งอยู่ก่อนแล้ว ถ้าขาดโปรแกรมใดไป คำสั่ง rpm จะไม่ยอมให้ติดตั้ง</p>
<p>ตัวอย่าง error เมื่อขาดโปรแกรมที่จำเป็นต่อ cacti</p>
<pre>[root@fc11-64min ~]# <strong>rpm -i cacti-0.8.7d-3.fc11.noarch.rpm
</strong>error: Failed dependencies:
        /usr/bin/php is needed by cacti-0.8.7d-3.fc11.noarch
        httpd is needed by cacti-0.8.7d-3.fc11.noarch
        mysql is needed by cacti-0.8.7d-3.fc11.noarch
        net-snmp is needed by cacti-0.8.7d-3.fc11.noarch
        php is needed by cacti-0.8.7d-3.fc11.noarch
        php-mysql is needed by cacti-0.8.7d-3.fc11.noarch
        php-snmp is needed by cacti-0.8.7d-3.fc11.noarch</pre>
<p>บทความต่อไปนี้ แสดงขั้นตอนและวิธีติดตั้งไฟล์ต่างๆ ที่จำเป็นต่อการรัน cacti</p>
<ul>
<li><a href="http://spalinux.com/2009/06/install_mysql_on_fedora_11">ติดตั้ง MySQL บน Fedora 11</a></li>
<li><a href="http://spalinux.com/2009/06/install_apache_php_on_fedora_11">ติดตั้ง Apache, PHP บน Fedora 11</a></li>
<li><a href="http://spalinux.com/2009/07/install_php_module_on_fedora_11">ติดตั้ง PHP Module เพิ่มบน Fedora 11</a></li>
<li><a href="http://spalinux.com/2009/07/install_php_module_snmp">ติดตั้ง PHP Module: snmp</a></li>
<li><a href="http://spalinux.com/2009/06/install_rrdtool_on_fedora_11">ติดตั้ง rrdtool บน Fedora 11</a></li>
</ul>
<p> </p>
<h4>ติดตั้ง cacti</h4>
<p>ดาวน์โหลดไฟล์ rpm ของ cacti ได้จาก Fedora 11 everything แล้วใช้คำสั่ง rpm ติดตั้ง</p>
<pre>[root@fc11-64min ~]# <strong>rpm -i cacti-0.8.7d-3.fc11.noarch.rpm</strong></pre>
<p>ถึงตอนนี้ยังไม่สามารถเรียกใช้ cacti ได้ ต้องแก้ไขคอนฟิกเพื่อเชื่อมโยงเข้าฐานข้อมูลก่อน ในบทความต่อไป</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_2">ติดตั้ง Cacti บน Fedora 11 ตอนที่ 2</a></li>
<li><a href="http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_3">ติดตั้ง Cacti บน Fedora 11 ตอนที่ 3</a></li>
<li><a href="http://www.cacti.net/" target="_blank">Cacti: The Complete RRDTool-based Graphing Solution</a></li>
<li><a href="http://mirrors.kernel.org/fedora/releases/11/Everything/x86_64/os/Packages/" target="_blank">Fedora 11 Everything</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/07/install_cacti_on_fedora_11_part_1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง PHP Module: snmp</title>
		<link>http://spalinux.com/2009/07/install_php_module_snmp</link>
		<comments>http://spalinux.com/2009/07/install_php_module_snmp#comments</comments>
		<pubDate>Sat, 18 Jul 2009 08:28:09 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[install_php-snmp]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=855</guid>
		<description><![CDATA[SNMP เป็นโปรโตคอลมาตรฐานสำหรับการบริหารจัดการอุปกรณ์ทางด้านเครือข่าย คือสามารถที่จะดึงค่าที่ต้องการ หรือคอนฟิกค่าของอุปกรณ์ได้ การที่จะสามารถเขียน PHP ให้เรียกใช้ฟังก์ชั่นเกี่ยวกับ snmp ได้ ต้องติดตั้งโมดูล php-snmp ใส่แผ่นดีวีดี Fedora 11 แล้วติดตั้งไฟล์ rpm ต่อไปนี้ตามตัวอย่าง [root@fc11-64min ~]# mount /dev/scd0 /media/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@fc11-64min ~]# cd /media/Packages/ ติดตั้ง net-snmp ต้องลงโปรแกรม net-snmp ก่อนที่จะติดตั้ง โมดูล php-snmp [root@fc11-64min Packages]# rpm -i lm_sensors-3.1.0-1.fc11.x86_64.rpm [root@fc11-64min Packages]# rpm -i net-snmp-libs-5.4.2.1-10.fc11.x86_64.rpm [root@fc11-64min Packages]# rpm -i [...]]]></description>
			<content:encoded><![CDATA[<p>SNMP เป็นโปรโตคอลมาตรฐานสำหรับการบริหารจัดการอุปกรณ์ทางด้านเครือข่าย คือสามารถที่จะดึงค่าที่ต้องการ หรือคอนฟิกค่าของอุปกรณ์ได้</p>
<p>การที่จะสามารถเขียน PHP ให้เรียกใช้ฟังก์ชั่นเกี่ยวกับ snmp ได้ ต้องติดตั้งโมดูล php-snmp</p>
<p><span id="more-855"></span>ใส่แผ่นดีวีดี Fedora 11 แล้วติดตั้งไฟล์ rpm ต่อไปนี้ตามตัวอย่าง</p>
<pre>[root@fc11-64min ~]# <strong>mount /dev/scd0 /media/
</strong>mount: block device /dev/sr0 is write-protected, mounting read-only
[root@fc11-64min ~]# <strong>cd /media/Packages/</strong></pre>
<h4>ติดตั้ง net-snmp</h4>
<p>ต้องลงโปรแกรม net-snmp ก่อนที่จะติดตั้ง โมดูล php-snmp</p>
<pre>[root@fc11-64min Packages]# <strong>rpm -i lm_sensors-3.1.0-1.fc11.x86_64.rpm
</strong>[root@fc11-64min Packages]# <strong>rpm -i net-snmp-libs-5.4.2.1-10.fc11.x86_64.rpm
</strong>[root@fc11-64min Packages]# <strong>rpm -i net-snmp-5.4.2.1-10.fc11.x86_64.rpm</strong></pre>
<p>ติดตั้งไฟล์ net-snmp-utils และโมดูล php-snmp เพิ่มเติมโดยสองไฟล์นี้ต้องดาวน์โหลดมาจาก Fedora 11 Everything</p>
<pre>[root@fc11-64min ~]# <strong>rpm -i net-snmp-utils-5.4.2.1-10.fc11.x86_64.rpm
</strong>[root@fc11-64min ~]# <strong>rpm -i php-snmp-5.2.9-2.fc11.x86_64.rpm</strong></pre>
<p>ใช้คำสั่ง service เพื่อรีสตาร์ตเว็บเซิร์ฟเวอร์</p>
<pre>[root@fc11-64min Packages]# <strong>service httpd restart
</strong>Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]</pre>
<h4>ทดสอบ php-snmp</h4>
<p>ทดลองเรียกใช้ฟังก์ชั่น snmpwalk เพื่อดึงค่า MIB ที่เกี่ยวกับ system จาก IP 192.168.1.254</p>
<pre>[root@fc11-64min html]# <strong>cat test-snmp.php
</strong>&lt;?php
$_ret = snmpwalk('192.168.1.254', 'public', 'system');
print_r($_ret);
?&gt;</pre>
<pre>[root@fc11-64min html]# <strong>php test-snmp.php</strong></pre>
<pre>Array
(
    [0] =&gt; STRING: Linux ...
    [1] =&gt; OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
...</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/06/install_apache_php_on_fedora_11">ติดตั้ง Apache, PHP บน Fedora 11</a></li>
<li><a href="http://spalinux.com/2009/07/install_php_module_on_fedora_11">ติดตั้ง PHP Module เพิ่มบน Fedora 11</a></li>
<li><a href="http://mirrors.kernel.org/fedora/releases/11/Everything/x86_64/os/Packages/" target="_blank">Fedora 11 Everything</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/07/install_php_module_snmp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง rrdtool บน Fedora 11</title>
		<link>http://spalinux.com/2009/06/install_rrdtool_on_fedora_11</link>
		<comments>http://spalinux.com/2009/06/install_rrdtool_on_fedora_11#comments</comments>
		<pubDate>Sat, 27 Jun 2009 08:15:43 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[rrdtool]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=799</guid>
		<description><![CDATA[จากแผ่นดีวีดี Fedora 11 ติดตั้งไฟล์ RPM ดังนี้ [root@fc11-64a ~]# mount /dev/scd0 /media [root@fc11-64a ~]# cd /media/Packages/ [root@fc11-64a Packages]# rpm -i fontpackages-filesystem-1.20-2.fc11.noarch.rpm [root@fc11-64a Packages]# rpm -i dejavu-fonts-common-2.29-2.fc11.noarch.rpm [root@fc11-64a Packages]# cd ~ [root@fc11-64a ~]# umount /media/ ดาวน์โหลดไฟล์เพิ่มเติมจาก Fedora 11 (Everything) แล้วใช้คำสั่ง rpm เพื่อติดตั้ง [root@fc11-64a ~]# rpm -i dejavu-lgc-sans-fonts-2.29-2.fc11.noarch.rpm [root@fc11-64a ~]# rpm -i dejavu-lgc-sans-mono-fonts-2.29-2.fc11.noarch.rpm [root@fc11-64a ~]# rpm -i dejavu-lgc-serif-fonts-2.29-2.fc11.noarch.rpm [...]]]></description>
			<content:encoded><![CDATA[<p>จากแผ่นดีวีดี Fedora 11 ติดตั้งไฟล์ RPM ดังนี้</p>
<pre>[root@fc11-64a ~]# <strong>mount /dev/scd0 /media
</strong>[root@fc11-64a ~]# <strong>cd /media/Packages/
</strong>[root@fc11-64a Packages]# <strong>rpm -i fontpackages-filesystem-1.20-2.fc11.noarch.rpm
</strong>[root@fc11-64a Packages]# <strong>rpm -i dejavu-fonts-common-2.29-2.fc11.noarch.rpm
</strong>[root@fc11-64a Packages]# <strong>cd ~
</strong>[root@fc11-64a ~]# <strong>umount /media/</strong></pre>
<p>ดาวน์โหลดไฟล์เพิ่มเติมจาก Fedora 11 (Everything) แล้วใช้คำสั่ง rpm เพื่อติดตั้ง</p>
<pre>[root@fc11-64a ~]# <strong>rpm -i dejavu-lgc-sans-fonts-2.29-2.fc11.noarch.rpm
</strong>[root@fc11-64a ~]# <strong>rpm -i dejavu-lgc-sans-mono-fonts-2.29-2.fc11.noarch.rpm
</strong>[root@fc11-64a ~]# <strong>rpm -i dejavu-lgc-serif-fonts-2.29-2.fc11.noarch.rpm
</strong>[root@fc11-64a ~]# <strong>rpm -i dejavu-fonts-lgc-compat-2.29-2.fc11.noarch.rpm
</strong>[root@fc11-64a ~]# <strong>rpm -i rrdtool-1.3.7-1.fc11.x86_64.rpm</strong></pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://mirrors.kernel.org/fedora/releases/11/Everything/x86_64/os/Packages/" target="_blank">Fedora 11 (Everything)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/06/install_rrdtool_on_fedora_11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
