<?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; Uncategorized</title>
	<atom:link href="http://spalinux.com/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://spalinux.com</link>
	<description>เพื่อชีวิตที่ผ่อนคลายของคนใช้ลีนุกซ์</description>
	<lastBuildDate>Sat, 12 May 2012 10:38:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>ดักจับ Traffic ใน Network ด้วย tcpdump</title>
		<link>http://spalinux.com/2011/06/using_tcpdump_to_capture_traffic_on_network</link>
		<comments>http://spalinux.com/2011/06/using_tcpdump_to_capture_traffic_on_network#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:44:19 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Console]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Sniffer]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tcpdump]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1351</guid>
		<description><![CDATA[tcpdump เป็นโปรแกรมประเภทเดียวกับ Sniffer, Wireshark คือใช้ในการดักจับ (capture) Traffic หรือ Packet ที่ รับ/ส่ง เข้า/ออก ระหว่างพอร์ตแลน (LAN) ของเซิรฟ์เวอร์เครื่องที่รันคำสั่ง และอุปกรณ์เครือข่าย (Router, Switch, HUB) มีประโยชน์อย่างมาก เพื่อใช้ในการวิเคราะห์ ตรวจสอบ หรือแก้ปัญหาเกี่ยวกับ Network ได้ tcpdump ต้องรันด้วย root หรือเทียบเท่า และรันแบบ command line ติดตั้งมาเป็นดีฟอลต์บนลีนุกซ์เกือบทุกตระกูล เวอร์ชั่น จึงใช้งานได้สะดวก ไม่ต้องติดตั้งเพิ่มเติมเหมือนโปรแกรมอื่นๆ ในที่นี้ขอแนะนำวิธีการใช้งานเบื้องต้นของ tcpdump รันคำสั่ง tcpdump ล็อกอินเป็น root แล้วพิมพ์คำสั่ง tcpdump หมายเหตุ พอร์ตที่ใช้ในดักจับ packet ไม่จำเป็นต้องใส่ IP Address หรือเป็น IP ในกลุ่มเดียวกับ IP อื่นๆ [...]]]></description>
			<content:encoded><![CDATA[<p>tcpdump เป็นโปรแกรมประเภทเดียวกับ Sniffer, Wireshark คือใช้ในการดักจับ (capture) Traffic หรือ Packet ที่ รับ/ส่ง เข้า/ออก ระหว่างพอร์ตแลน (LAN) ของเซิรฟ์เวอร์เครื่องที่รันคำสั่ง และอุปกรณ์เครือข่าย (Router, Switch, HUB)</p>
<p>มีประโยชน์อย่างมาก เพื่อใช้ในการวิเคราะห์ ตรวจสอบ หรือแก้ปัญหาเกี่ยวกับ Network ได้</p>
<p>tcpdump ต้องรันด้วย root หรือเทียบเท่า และรันแบบ command line ติดตั้งมาเป็นดีฟอลต์บนลีนุกซ์เกือบทุกตระกูล เวอร์ชั่น จึงใช้งานได้สะดวก ไม่ต้องติดตั้งเพิ่มเติมเหมือนโปรแกรมอื่นๆ</p>
<p>ในที่นี้ขอแนะนำวิธีการใช้งานเบื้องต้นของ tcpdump</p>
<h4><span id="more-1351"></span><br />
รันคำสั่ง tcpdump</h4>
<p>ล็อกอินเป็น root แล้วพิมพ์คำสั่ง tcpdump</p>
<p><strong>หมายเหตุ</strong> พอร์ตที่ใช้ในดักจับ packet ไม่จำเป็นต้องใส่ IP Address หรือเป็น IP ในกลุ่มเดียวกับ IP อื่นๆ ใน Network ที่ต้องการดักจับ ขอให้สถานะ Up พอ</p>
<p>หากไม่ระบุออปชั่นใดๆ เลย tcpdump จะเลือกดักจับ packet ที่เข้าออก พอร์ตแลนแรก โดยทั่วไปคือ eth0</p>
<p>ตัวอย่างการรันคำสั่งแบบไม่ระบุออปชั่น</p>
<pre>[root@server ~]# <strong>tcpdump
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:15:53.948422 IP 192.168.1.102.jwalkserver &gt; server.example.com.ssh: Flags [.], ack 1108, win 64623, length 0
09:15:53.955117 IP server.example.com.ssh &gt; 192.168.1.102.jwalkserver: Flags [P.], seq 1108:1384, ack 1, win 8576, length 276
09:15:53.963948 IP server.example.com.ssh &gt; 192.168.1.102.jwalkserver: Flags [P.], seq 1384:1548, ack 1, win 8576, length 164
09:15:53.964191 IP 192.168.1.102.jwalkserver &gt; server.example.com.ssh: Flags [.], ack 1548, win 64183, length 0
09:15:53.972707 IP server.example.com.ssh &gt; 192.168.1.102.jwalkserver: Flags [P.], seq 1548:1824, ack 1, win 8576, length 276
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<pre>102 packets captured
102 packets received by filter
0 packets dropped by kernel</pre>
<p>กด [Ctrl-C] เพื่อออกจากคำสั่ง tcpdump ด้านล่างจะมีรายงานสรุปว่า ดักจับได้กี่ packet</p>
<p>ผลลัพธ์ที่แสดงจากคำสั่ง tcpdump จะแตกต่างกันไปขึ้นกับ Network Protocol ที่รับ/ส่ง เช่นถ้าเป็น IP Protocol (TCP, UDP) รูปแบบจะเป็น</p>
<ul>
<li>เวลา</li>
<li>IP</li>
<li>[Source IP Address].[Source Port]</li>
<li>[Destination Address].[Destination Port]</li>
<li>IP, TCP, UDP Headers</li>
</ul>
<p> </p>
<h4>เลือกพอร์ตที่ดักจับ</h4>
<p>ระบุออปชั่น &#8220;-i&#8221; แล้วตามด้วยชื่อพอร์ต เช่น ต้องการจับ packet ที่เข้าออก eth1</p>
<pre>[root@server ~]# <strong>tcpdump -i eth1
</strong>tcpdump: WARNING: eth1: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<p>ในที่นี้ พอร์ต eth1 ไม่มีการใส่ IP Address จึงขึ้นฟ้อง &#8220;WARNING: eth1: no IPv4 address assigned&#8221; แต่ก็ยังสามารถดักจับ Traffic ได้</p>
<h4>ไม่ต้องแปลง IP เป็นชื่อ hostname</h4>
<p>ผลลัพธ์ที่แสดงออกมา โปรแกรม tcpdump จะพยายามแปลง IP Address ทั้งต้นทาง ปลายทาง ของ packet ที่ดักจับได้ ให้เป็นชื่อ hostname โดยใช้ไฟล์ /etc/hosts หรือ บริการ DNS</p>
<p>ถ้าหาก traffic มีปริมาณมาก แนะนำให้ปิดคุณสมบัติการพยายามแปลง IP เป็น ชื่อ hostname ออกซะ ด้วยการระบุออปชั่น &#8220;-n&#8221; เพื่อลดโหลด DNS</p>
<pre>[root@server ~]# <strong>tcpdump -i eth0 -l -n
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:31:10.322145 IP 192.168.1.1.ssh &gt; 192.168.1.102.jwalkserver: Flags [P.], seq 1901277915:1901278111, ack 2244887520, win 8576, length 196
09:31:10.322752 IP 192.168.1.102.jwalkserver &gt; 192.168.1.1.ssh: Flags [.], ack 196, win 65535, length 0
09:31:10.330843 IP 192.168.1.1.ssh &gt; 192.168.1.102.jwalkserver: Flags [P.], seq 196:472, ack 1, win 8576, length 276
09:31:10.332785 IP 192.168.1.1.ssh &gt; 192.168.1.102.jwalkserver: Flags [P.], seq 472:636, ack 1, win 8576, length 164
09:31:10.333209 IP 192.168.1.102.jwalkserver &gt; 192.168.1.1.ssh: Flags [.], ack 636, win 65095, length 0
<span style="color: #ff0000;">^C</span></pre>
<p> </p>
<h4>ไม่ต้องแปลง Port Number เป็นชื่อ Port Name</h4>
<p>หากต้องการแสดงชื่อพอร์ต (TCP, UDP ports) เป็นตัวเลข (ไฟล์ /etc/services)  ให้ระบุออปชั่น &#8220;-n&#8221; เพิ่มอีกหนึ่ง หรือระบุเป็น &#8220;-nn&#8221; เลย</p>
<pre>[root@server ~]# <strong>tcpdump -i eth0 -l -nn
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:39:38.800430 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: Flags [.], ack 196, win 65535, length 0
09:39:38.802793 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: Flags [P.], seq 196:456, ack 1, win 8576, length 260
09:39:38.805709 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: Flags [P.], seq 456:604, ack 1, win 8576, length 148
09:39:38.805963 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: Flags [.], ack 604, win 65127, length 0
09:39:38.808655 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: Flags [P.], seq 604:848, ack 1, win 8576, length 244
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<h4>ผลลัพธ์แบบสั้นๆ </h4>
<p>หากไม่สนใจ ข้อมูลใน IP, TCP, UDP Headers ต้องการรู้แค่ว่า IP อะไรคุยกัน ใช้พอร์ตอะไร แค่นั้นพอ ให้ระบุออปชั่น &#8220;-q&#8221;</p>
<pre>[root@server ~]# <strong>tcpdump -i eth0 -l -nn -q
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:40:48.472427 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 196
09:40:48.473006 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 0
09:40:48.479252 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 164
09:40:48.487003 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 100
09:40:48.487311 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 0
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<p> </p>
<h4>แสดงข้อมูล Layer 2 (MAC Address)</h4>
<p>ระบุออปชั่น &#8220;-e&#8221;  หากต้องการแสดงข้อมูล Layer 2 หรือแสดง Source, Destination MAC Address ด้วย</p>
<pre>[root@server ~]# <strong>tcpdump -i eth0 -l -nn -e -q
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:44:05.644395 00:11:22:33:44:55 &gt; 00:55:66:77:88:99, IPv4, length 250: 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 196
09:44:05.644959 00:55:66:77:88:99 &gt; 00:11:22:33:44:55, IPv4, length 60: 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 0
09:44:05.652121 00:11:22:33:44:55 &gt; 00:55:66:77:88:99, IPv4, length 314: 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 260
09:44:05.660897 00:11:22:33:44:55 &gt; 00:55:66:77:88:99, IPv4, length 218: 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 164
09:44:05.661173 00:55:66:77:88:99 &gt; 00:11:22:33:44:55, IPv4, length 60: 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 0
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<h4> <br />
save ผลลัพธ์เก็บในไฟล์</h4>
<p>หากต้องการบันทึก (save) ผลลัพธ์ที่ดักจับได้ ให้เหมือนกับหน้าจอที่แสดงขึ้นมา ก็ใช้การ redirection</p>
<p>ตัวอย่าง การเก็บผลลัพธ์ลงไฟล์ ให้เหมือนกับที่แสดงขึ้นมา</p>
<pre>[root@server ~]# <strong>tcpdump -i eth0 -l -nn -q &gt; catpure-display.log
</strong>tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
<span style="color: #ff0000;"><strong>^C</strong></span>
7 packets captured
7 packets received by filter
0 packets dropped by kernel</pre>
<pre>หากต้องการหยุด ก็กดปุ่ม [Ctrl-C] เหมือนกัน</pre>
<p>ใช้คำสั่ง cat เพื่อดูเนื้อหาไฟล์ที่บันทึก</p>
<pre>[root@server ~]# <strong>cat capture-display.log
</strong>09:57:08.118314 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 196
09:57:08.118515 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 0
09:57:09.138258 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 36
09:57:09.355761 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: tcp 36
09:57:09.356025 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: tcp 0
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<p> แต่ถ้าต้องการบันทึกแบบเต็มรูปแบบ ให้ใช้ออปชั่น &#8220;-w&#8221; แล้วตามด้วยชื่อไฟล์ โดยทั่วไปนิยมบันทึกเป็นไฟล์นามสกุล &#8220;.cap&#8221;</p>
<pre>[root@server ~]# <strong>tcpdump -i eth0 -w capture-raw.cap
</strong>tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
<strong><span style="color: #ff0000;">^C</span></strong>
24 packets captured
24 packets received by filter
0 packets dropped by kernel</pre>
<p>ไฟล์ที่บันทึกด้วยออปชั่น &#8220;-w&#8221; สามารถนำมาเปิดย้อนหลังด้วยคำสั่ง tcpdump ตามด้วยออปชั่น &#8220;-r&#8221;  นอกจากนี้ ยังสามารถนำไปเปิดกับโปรแกรม Wireshark ได้อีกด้วย</p>
<pre>[root@server ~]# <strong>tcpdump -r capture-raw.cap -l -nn
</strong>reading from file capture-raw.cap, link-type EN10MB (Ethernet)
10:00:14.959339 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: Flags [P.], seq 105:157, ack 236, win 65431, length 52
10:00:14.972070 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: Flags [P.], seq 236:288, ack 157, win 8576, length 52
10:00:15.137079 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: Flags [.], ack 288, win 65379, length 0
10:00:15.221339 IP 192.168.1.102.1289 &gt; 192.168.1.1.22: Flags [P.], seq 157:209, ack 288, win 65379, length 52
10:00:15.227905 IP 192.168.1.1.22 &gt; 192.168.1.102.1289: Flags [P.], seq 288:340, ack 209, win 8576, length 52
<span style="color: #ff0000;"><strong>^C</strong></span></pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/09/verify_lan_network_interface_status_on_linux">ตรวจสอบสถานะของการ์ดเน็ตเวิร์กบนลีนุกซ์</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/06/using_tcpdump_to_capture_traffic_on_network/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>จำกัดจำนวน login พร้อมกันของผู้ใช้เดียวกัน</title>
		<link>http://spalinux.com/2011/05/limit_maximum_number_of_logins_for_user</link>
		<comments>http://spalinux.com/2011/05/limit_maximum_number_of_logins_for_user#comments</comments>
		<pubDate>Sun, 08 May 2011 07:13:52 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Linux Shell]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1325</guid>
		<description><![CDATA[การจำกัด (limit) จำนวนการ login พร้อมกันโดยใช้ชื่อผู้ใช้เดียวกัน สามารถคอนฟิกด้วยออปชั่น &#8220;maxlogins&#8221; ในไฟล์ /etc/security/limits.conf คำอธิบายออปชั่น &#8220;maxlogins&#8221; คือ max number of logins for this user คอนฟิกได้สองแบบคือ จำกัดเป็นรายคน เช่น ชื่อผู้ใช้ user1 สามารถ login ได้สูงสุดพร้อมกันได้แค่ 2 sessions แต่ถ้าต้องการจำกัดผู้ใช้ที่อยู่ในกลุ่ม (group) ให้เติมเครื่องหมาย @ ข้างหน้าชื่อกลุ่ม ตัวอย่างคอนฟิก จำกัดผู้ใช้ user1 ให้ login พร้อมกันได้แค่ 2 sessions เท่านั้น [root@server ~]# cat /etc/security/limits.conf user1           -       maxlogins       2 หลังแก้ไขไฟล์แล้ว คอนฟิกใหม่มีผลต่อการ login ครั้งต่อไปเลย [...]]]></description>
			<content:encoded><![CDATA[<p>การจำกัด (limit) จำนวนการ login พร้อมกันโดยใช้ชื่อผู้ใช้เดียวกัน สามารถคอนฟิกด้วยออปชั่น &#8220;maxlogins&#8221; ในไฟล์ /etc/security/limits.conf</p>
<p>คำอธิบายออปชั่น &#8220;maxlogins&#8221; คือ max number of logins for this user</p>
<p><span id="more-1325"></span></p>
<p>คอนฟิกได้สองแบบคือ จำกัดเป็นรายคน เช่น ชื่อผู้ใช้ user1 สามารถ login ได้สูงสุดพร้อมกันได้แค่ 2 sessions แต่ถ้าต้องการจำกัดผู้ใช้ที่อยู่ในกลุ่ม (group) ให้เติมเครื่องหมาย @ ข้างหน้าชื่อกลุ่ม</p>
<p>ตัวอย่างคอนฟิก จำกัดผู้ใช้ user1 ให้ login พร้อมกันได้แค่ 2 sessions เท่านั้น</p>
<pre>[root@server ~]# <strong>cat /etc/security/limits.conf
</strong>user1           -       maxlogins       2</pre>
<p>หลังแก้ไขไฟล์แล้ว คอนฟิกใหม่มีผลต่อการ login ครั้งต่อไปเลย ไม่จำเป็นต้องรีสตาร์ตโปรแกรม หรือเซอร์วิสใด</p>
<p>ตัวอย่างข้อความในไฟล์ /var/log/secure ที่เกิดขึ้น ระหว่างการทดสอบ login</p>
<p>login ด้วย user1 ครั้งแรก ได้</p>
<pre>Jul  8 13:21:19 server sshd[2375]: Accepted password for user1 from 192.168.1.12 port 4310 ssh2
Jul  8 13:21:19 server sshd[2375]: pam_unix(sshd:session): session opened for user user1 by (uid=0)</pre>
<p>login ด้วย user1 ครั้งที่ 2 ก็ได้</p>
<pre>Jul  8 13:21:39 server sshd[2400]: Accepted password for user1 from 192.168.1.12 port 4311 ssh2
Jul  8 13:21:39 server sshd[2400]: pam_unix(sshd:session): session opened for user user1 by (uid=0)</pre>
<p>ใช้คำสั่ง w เพื่อดูผู้ใช้ที่ login อยู่</p>
<pre>[user1@server ~]$ <strong>w</strong>
 13:21:49 up 14 min,  3 users,  load average: 0.07, 0.19, 0.25
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
admin    pts/0    192.168.1.12         13:19   35.00s  0.72s  0.18s sshd: admin [priv]
user1    pts/1    192.168.1.12         13:21   30.00s  0.20s  0.20s -bash
user1    pts/2    192.168.1.12         13:21    0.00s  0.25s  0.04s w</pre>
<p>login ด้วย user1 ครั้งที่ 3 จะไม่ได้แล้ว</p>
<pre>Jul  8 13:22:00 server sshd[2426]: Accepted password for user1 from 192.168.1.12 port 4312 ssh2
Jul  8 13:22:00 server sshd[2426]: <span style="color: #ff0000;"><strong>pam_limits(sshd:session): Too many logins (max 2) for user1
</strong></span>Jul  8 13:22:00 server sshd[2426]: pam_unix(sshd:session): session opened for user user1 by (uid=0)
Jul  8 13:22:00 server sshd[2426]: error: PAM: pam_open_session(): Permission denied</pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/05/limit_maximum_number_of_logins_for_user/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ติดตั้ง MySQL บน Fedora 11</title>
		<link>http://spalinux.com/2009/06/install_mysql_on_fedora_11</link>
		<comments>http://spalinux.com/2009/06/install_mysql_on_fedora_11#comments</comments>
		<pubDate>Sat, 27 Jun 2009 10:48:02 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[install mysql]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=818</guid>
		<description><![CDATA[ในบทความนี้จะอธิบายวิธีการติดตั้งและคอนฟิก MySQL บน Fedora 11 (x86_64) โดยทดสอบบนเครื่องที่ ติดตั้ง Fedora 11 แบบประหยัดพื้นที่สุด หมายเหตุ Fedora 11 ปรับปรุงเวอร์ชั่นมาใช้ MySQL เวอร์ชั่น 5.1 แล้ว ใส่แผ่นดีวีดี 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/ [root@fc11-64min Packages]# rpm -i perl-DBI-1.607-2.fc11.x86_64.rpm [root@fc11-64min Packages]# rpm -i perl-DBD-MySQL-4.010-1.fc11.x86_64.rpm [root@fc11-64min Packages]# rpm [...]]]></description>
			<content:encoded><![CDATA[<p>ในบทความนี้จะอธิบายวิธีการติดตั้งและคอนฟิก MySQL บน Fedora 11 (x86_64) โดยทดสอบบนเครื่องที่ <a href="http://spalinux.com/2009/06/install_minimal_fedora_11">ติดตั้ง Fedora 11 แบบประหยัดพื้นที่สุด</a></p>
<p>หมายเหตุ Fedora 11 ปรับปรุงเวอร์ชั่นมาใช้ MySQL เวอร์ชั่น 5.1 แล้ว</p>
<p><span id="more-818"></span></p>
<p>ใส่แผ่นดีวีดี 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>
<pre>[root@fc11-64min Packages]# <strong>rpm -i perl-DBI-1.607-2.fc11.x86_64.rpm
</strong>[root@fc11-64min Packages]# <strong>rpm -i perl-DBD-MySQL-4.010-1.fc11.x86_64.rpm
</strong>[root@fc11-64min Packages]# <strong>rpm -i mysql-5.1.32-1.fc11.x86_64.rpm
</strong>[root@fc11-64min Packages]# <strong>rpm -i mysql-server-5.1.32-1.fc11.x86_64.rpm
</strong>[root@fc11-64min Packages]# <strong>cd</strong></pre>
<p>ตรวจสอบไฟล์ MySQL ที่ติดตั้งทั้งหมด</p>
<pre>[root@fc11-64min ~]# <strong>rpm -qa | grep -i mysql
</strong>mysql-server-5.1.32-1.fc11.x86_64
mysql-libs-5.1.32-1.fc11.x86_64
mysql-5.1.32-1.fc11.x86_64
perl-DBD-MySQL-4.010-1.fc11.x86_64</pre>
<p>ใช้คำสั่ง service เพื่อรันเซอร์วิส MySQL</p>
<pre>[root@fc11-64min ~]# <strong>service mysqld start
</strong>Initializing MySQL database:  Installing MySQL system tables...
090628  0:09:11 [Warning] Forcing shutdown of 2 plugins
OK
Filling help tables...
090628  0:09:11 [Warning] Forcing shutdown of 2 plugins
OK</pre>
<pre>To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system</pre>
<pre>PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:</pre>
<pre>/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h fc11-64min.spalinux.com password 'new-password'</pre>
<pre>Alternatively you can run:
/usr/bin/mysql_secure_installation</pre>
<pre>which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.</pre>
<pre>See the manual for more instructions.</pre>
<pre>You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &amp;</pre>
<pre>You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl</pre>
<pre>Please report any problems with the /usr/bin/mysqlbug script!</pre>
<pre>The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/</pre>
<pre>                                                           [  OK  ]
Starting MySQL:                                            [  OK  ]</pre>
<p>หากเป็นการรันเซอร์วิส MySQL ครั้งแรกจะมีข้อความต่างๆ ขึ้นมากมาย เหมือนข้างบน เพื่อแนะนำการรันเซอร์วิส พร้อมทั้งเตือนให้มีการเปลี่ยน password ในการใช้ฐานข้อมูล</p>
<p>วิธีการง่ายสุดในการเปลี่ยน password และแก้ไขคอนฟิกของ MySQL เพื่อความปลอดภัย คือการรันคำสั่ง mysql_secure_installation</p>
<p>ผลจากการใช้คำสั่ง mysql_secure_installation</p>
<ul>
<li>Set root password &#8211; เปลี่ยน password ของ root ในการ connect database</li>
<li>Remove anonymous users &#8211; ลบ anonymous user ออก คือบังคับทุก user ที่ connect database ต้องใส่ password</li>
<li>Disallow root login remotely &#8211; ปิดการเชื่อมต่อเป็น root จากเครื่องอื่น ใช้ได้จากเครื่องทีรัน mysql อยู่เท่านั้น</li>
<li>Remove test database and access to it &#8211; ลบ database ชื่อ &#8216;test&#8217;</li>
<li>Reload privilege tables now &#8211; reload ให้สิทธิต่างๆ ที่เพิ่งคอนฟิกไป มีผลทันที</li>
</ul>
<pre>[root@fc11-64min ~]# <strong>mysql_secure_installation</strong></pre>
<pre>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!</pre>
<pre>In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.</pre>
<pre>Enter current password for root (enter for none):
OK, successfully used password, moving on...</pre>
<pre>Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.</pre>
<pre><span style="color: #0000ff;">Set root password? [Y/n] <strong>y</strong>
</span>New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!</pre>
<pre>By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.</pre>
<pre><span style="color: #0000ff;">Remove anonymous users? [Y/n] <strong>y</strong>
</span> ... Success!</pre>
<pre>Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.</pre>
<pre><span style="color: #0000ff;">Disallow root login remotely? [Y/n] <strong>y</strong>
</span> ... Success!</pre>
<pre>By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.</pre>
<pre><span style="color: #0000ff;">Remove test database and access to it? [Y/n] <strong>y</strong>
</span> - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!</pre>
<pre>Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.</pre>
<pre><span style="color: #0000ff;">Reload privilege tables now? [Y/n] <strong>y</strong>
</span> ... Success!</pre>
<pre>Cleaning up...</pre>
<pre> </pre>
<pre>All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.</pre>
<pre>Thanks for using MySQL!</pre>
<p>ทดลองใช้คำสั่ง mysql เพื่อ connect database หน้าจอจะฟ้องว่า ไม่สามารถเข้าได้ &#8220;access denied&#8221;</p>
<pre>[root@fc11-64min ~]# <strong>mysql
</strong>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)</pre>
<p>ต้องระบุออปชั่น &#8216;-p&#8217; เพื่อใส่ password ด้วย</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 12
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 |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)</pre>
<pre>mysql&gt; <strong>exit</strong>
Bye
[root@fc11-64min ~]#</pre>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2009/07/mysql_secure_installation_error_read-only_file_system">รัน mysql_secure_installation ขึ้น Read-only file system</a></li>
</ul>
<pre> </pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2009/06/install_mysql_on_fedora_11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

