<?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>Just My Life &#187; Server</title>
	<atom:link href="http://imrgill.com/tag/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://imrgill.com</link>
	<description>I&#039;m mrGilL, I&#039;m Newbie Admin</description>
	<lastBuildDate>Mon, 19 Dec 2011 11:46:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Server Down รู้ได้ทันทีผ่าน SMS แถมฟรีด้วย</title>
		<link>http://imrgill.com/2009/12/11/monitor-server-with-sms-alert-shell-script.html</link>
		<comments>http://imrgill.com/2009/12/11/monitor-server-with-sms-alert-shell-script.html#comments</comments>
		<pubDate>Fri, 11 Dec 2009 01:19:20 +0000</pubDate>
		<dc:creator>mrgill</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[alert]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://imrgill.com/?p=438</guid>
		<description><![CDATA[ก่อนอื่นขอหาวยาวๆ ก่อนกล่าวสวัสดีท่านผู้อ่านทุกท่าน  เมื่อคืนบ้าพลังอะไรไม่รู้อยากเขียน script ส่ง sms เตือนเมื่อ server down ที่จริงชาวบ้านเค้าก็ทำขายกันเยอะแยะ แต่หลังจากที่ผมได้ใช้ Google Calendar แล้วให้มันส่ง sms เตือนแถมฟรีอีก ก็เลยคิดอยากใช้ประโยชน์จากมันเพิ่มเติมก็ค้นๆ  Google อีกเช่นเคยครับ ไปเจอบทความใน ThaiAdmin เรื่อง google calendar sms ที่ท่าน smartsoft เขียนไว้ก็เลยลองโหลด Libraries Google Calendar SMS มาเล่นดูบ้าง ซึ่งเมื่อลองดูแล้วก็ถือว่าใช้งานง่ายทีเดียวเลยเอามาโมต่อ โดยให้ Shell Script เป็นตัว Submit form แทน ความสามารถของ Script 1. ส่ง sms แจ้งเตือนเมื่อ ping ไม่เจอ server 2. เก็บ log ในตัว เพราะทุกครั้งที่มันส่ง [...]]]></description>
			<content:encoded><![CDATA[<p>ก่อนอื่นขอหาวยาวๆ ก่อนกล่าวสวัสดีท่านผู้อ่านทุกท่าน  เมื่อคืนบ้าพลังอะไรไม่รู้อยากเขียน script ส่ง sms เตือนเมื่อ server down ที่จริงชาวบ้านเค้าก็ทำขายกันเยอะแยะ แต่หลังจากที่ผมได้ใช้ Google Calendar แล้วให้มันส่ง sms เตือนแถมฟรีอีก ก็เลยคิดอยากใช้ประโยชน์จากมันเพิ่มเติมก็ค้นๆ  Google อีกเช่นเคยครับ ไปเจอบทความใน ThaiAdmin เรื่อง <a href="http://www.thaiadmin.org/board/index.php?topic=114285.0">google calendar sms</a> ที่ท่าน <a title="ดูรายละเอียดของ smartsoft" href="http://www.thaiadmin.org/board/index.php?action=profile;u=25720">smartsoft</a> เขียนไว้ก็เลยลองโหลด Libraries Google Calendar SMS มาเล่นดูบ้าง ซึ่งเมื่อลองดูแล้วก็ถือว่าใช้งานง่ายทีเดียวเลยเอามาโมต่อ โดยให้ Shell Script เป็นตัว Submit form แทน</p>
<p><strong>ความสามารถของ Script</strong></p>
<p>1. ส่ง sms แจ้งเตือนเมื่อ ping ไม่เจอ server<br />
2. เก็บ log ในตัว เพราะทุกครั้งที่มันส่ง sms มันจะไปเพิ่ม Event ใน Google Calendar ทำให้เราเข้าไปตรวจสอบย้อนหลังได้<br />
3. ไม่ต้องเสียเงินค่าส่ง SMS แม้แต่น้อย (พี่ Google เค้าใจดี)</p>
<p><strong>มาดูขั้นตอนการทำกัน</strong></p>
<p>ก่อนอื่นเราก็ต้องไป Verify เบอร์มือถือใน Google Calendar ก่อนครับ ขออนุญาตท่าน <a title="ดูรายละเอียดของ smartsoft" href="http://www.thaiadmin.org/board/index.php?action=profile;u=25720">smartsoft</a> ทำรูปใหม่นะครับ<br />
1. ขั้นแรก ล็อกอินเข้า Google Calendar <a href="http://www.google.com/calendar" target="_blank">http://www.google.com/calendar</a> ก็ใช้ User ของ Gmail นั้นแหละครับ<br />
ล็อกอินแล้วคลิกที่ Settings เพื่อไปปรับเมนูให้เป็นภาษาไทย (หากใครเป็นภาษาไทยอยู่แล้วข้ามไปขั้นตอนต่อไปได้เลย)</p>
<p><img class="aligncenter" src="http://farm3.static.flickr.com/2773/4175582724_515d2cfce5_o.png" alt="" width="519" height="148" /></p>
<p style="text-align: center;">คลิก Settings</p>
<p>2. เลือก Language ให้เป็น <strong>ภาษาไทย </strong>แล้วกด Save</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2774/4175582728_de23bb83d4_o.png" alt="" width="469" height="243" /></p>
<p style="text-align: center;">เลือก ภาษาไทย</p>
<p style="text-align: left;"><span id="more-438"></span>3. กลับมาหน้าปฏิทินคลิกที่ <strong>การตั้งค่า</strong></p>
<p style="text-align: left;"><img class="aligncenter" src="http://farm3.static.flickr.com/2785/4175582742_55962360a8_o.png" alt="" width="219" height="286" /></p>
<p style="text-align: left;">4. คลิกที่ <strong>ตั้งค่าอุปกรณ์เคลื่อนที่</strong></p>
<p style="text-align: left;"><img class="aligncenter" src="http://farm3.static.flickr.com/2516/4175582744_767056a6b0_o.png" alt="" width="317" height="177" /></p>
<p style="text-align: left;">
<p style="text-align: left;">5. กรอกเบอร์โทรศัพท์มือถือของคุณลงไป จากนั้นกดปุ่ม <strong>ส่งรหัสยืนยัน</strong></p>
<p style="text-align: left;"><img class="aligncenter" src="http://farm3.static.flickr.com/2745/4175582748_14b2eb8d46_o.png" alt="" width="527" height="223" /></p>
<p style="text-align: left;">6. รอสักครู่ Google จะส่ง SMS รหัสยืนยันมาให้ เมื่อได้รับรหัสยืนยันแล้วนำมากรอกในช่อง <strong>รหัสยืนยัน</strong> จากนั้นคลิก <strong>สิ้นสุดการตั้งค่า</strong></p>
<p style="text-align: center;"><strong><img class="aligncenter" src="http://farm3.static.flickr.com/2627/4175582752_3328f279a2_o.png" alt="" width="527" height="223" /></strong>กรอกรหัสยืนยันลงไป</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2699/4174864937_66e118528c_o.png" alt="" width="563" height="61" />สถานะจะเปลี่ยนเป็นสีเขียวหลังยืนยันหมายเลขโทรศัพท์สำเร็จแล้ว</p>
<p style="text-align: left;"><strong><br />
</strong></p>
<p style="text-align: left;">7. คลิกที่แท็บ <strong>ปฎิทิน</strong> แล้วคลิกที่ <strong>การแจ้ง</strong></p>
<p style="text-align: left;"><img class="aligncenter" src="http://farm3.static.flickr.com/2509/4175583670_089b0611af_o.png" alt="" width="490" height="241" /></p>
<p style="text-align: left;">8. เลือก <strong>การแจ้งเตือนกิจกรรม</strong> ให้เป็น SMS  แล้วกด <strong>บันทึก </strong>(** สำคัญมาก คุณต้องเลือกให้เป็น SMS เป็นอันดับแรก)<strong><br />
</strong></p>
<p style="text-align: center;"><a href="http://farm3.static.flickr.com/2802/4175583674_3a5c7533c3_o.png" rel="lightbox[438]"><img class="aligncenter" src="http://farm3.static.flickr.com/2802/4175583674_3a5c7533c3_o.png" alt="" width="470" height="150" /></a></p>
<p>ตั้งเวลาตามใจชอบเลยครับ(ตรงนี้ไม่เกี่ยวกับ SMS Alert ใน Script ครับ)</p>
<p style="text-align: left;">เสร็จสิ้นสำหรับส่วนของ Google Calendar ครับต่อไปมาถึงตัว Shell Script กันบ้าง</p>
<p style="text-align: left;">ผมได้เอา Script ของ <span>Vivek Gite แห่ง </span><a href="http://cyberciti.biz" target="_blank">cyberciti.biz</a> มาแก้ไขนิดหน่อยครับ ต้นฉบับอยู่ที่ <a href="http://bash.cyberciti.biz/monitoring/monitor-windows-linux-server-with-ping-script/" target="_blank">http://bash.cyberciti.biz/monitoring/monitor-windows-linux-server-with-ping-script/</a></p>
<p>ผมตั้งชื่อ Shell Script ตัวนี้ว่า <a href="http://imrgill.com//wp-content/uploads/2009/observman.tar.bz2">observman.sh</a> &lt;&lt;กดดาวน์โหลด</p>
<pre>
<div class="codesnip-container" >#!/bin/bash
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
# -------------------------------------------------------------------------
# Copyright (c) 2006 nixCraft project
# This script is licensed under GNU GPL version 2.0 or above
# Modify by mrGilL
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Setup SMS User below
# See URL for more info:
# http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html
# http://imrgill.com/2009/12/11/monitor-server-with-sms-alert-shell-script/
# -------------------------------------------------------------------------

# add ip / hostname separated by blank space
HOSTS="192.168.1.2 eng.ru.ac.th imrgill.com www.pca.co.th"

# no ping request
COUNT=5

# Set SMS Username (Google Calendar)
GCUSER="user@gmail.com"
GCPASSWD="gmail-passwd" 

for myHost in $HOSTS
do
  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ]; then
    # 100% failed
    wget --force-html --recursive --no-check-certificate -nd --delete-after "https://imrgill.com/google_sms/gsms.php?username=$GCUSER&amp;password=$GCPASSWD&amp;title=Server $myHost Down"
  fi
done</div>
</pre>
<p>ใส่ IP หรือชื่อ Host ของ Server ที่ต้องการ Monitor ลงไป หากมีหลายเครื่องให้คั่นด้วยเว้นวรรค</p>
<p>ต่อมาแก้ไข GCUSER และ GCPASSWD เป็นของท่าน(Gmail ของท่าน)</p>
<p>อย่าลืมกำหนดสิทธิ์ให้มันรันได้ด้วยนะครับ</p>
<pre>
<div class="codesnip-container" >root@mrgill-laptop:/root# chmod +x observman.sh</div>
</pre>
<p>สุดท้ายจับ Shell Script ของเราใส่ใน Crontab โดย</p>
<pre>
<div class="codesnip-container" >root@mrgill-laptop:~# crontab -e</div>
</pre>
<p>ผมตั้งให้มันเช็คทุก 15 นาทีครับ</p>
<pre>
<div class="codesnip-container" ># m h  dom mon dow   command
0-59/15 * * * * /root/observman.sh &gt; /dev/null</div>
</pre>
<p>ลองทดสอบง่ายๆ ดูครับ ใช้ไอพีเครื่องในวงแลนคุณก็ได้ จากนั้นไป disable การ์ดแลนหรือจะถอดสายแลนของเครื่องที่คุณต้องการ Monitor ก็ได้ รอประมาณ 2 นาทีจะมี SMS ส่งจาก Google มาหาคุณ</p>
<p style="text-align: left;"><strong>ภาพตัวอย่างหากแก้ไขถูกต้องครับ</strong></p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm5.static.flickr.com/4025/4210341646_7a76249947_o.png" alt="" width="486" height="300" /><br />
จะมี event add เข้าไปใน google calendar</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2554/4210341648_3b51cc4c89_o.jpg" alt="" width="640" height="480" /><br />
ภาพข้อความจาก google sms</p>
<p>*หมายเหตุ  : มีคนถามมาว่าทำไมต้องส่งข้อมูลผ่าน blog ผมด้วย ส่งเข้า Google เลยไม่ได้เหรอ คำตอบก็คือมันต้องมี API ติดต่อไปยัง Google Calendar ครับ ซึ่งผมได้ฝังไว้บน blog ของผมเอง และหากใครกังวลเรื่องความปลอดภัยผมเองก็มีไฟล์ API ให้โหลดเอาไว้ติดตั้งบน Server ตัวเองได้ครับซึ่งสามารถดาวน์โหลดได้จากที่นี่ <a href="http://imrgill.com/wp-content/uploads/2009/google_sms.tar.bz2">google_sms.tar.bz2</a> โหลดเสร็จแล้วก็เอาไปแตกไว้ใน wwwroot และอย่าลืมไปแก้ URL  ใน Shell Script ด้วยนะครับ</p>
<p>หวังว่าบทความนี้คงเป็นประโยชน์กับผู้อ่าน<br />
แหล่งข้อมูล : <a href="http://www.thaiadmin.org/board/index.php?topic=114285.0">http://www.thaiadmin.org/board/index.php?topic=114285.0</a><br />
<a href="http://bash.cyberciti.biz/monitoring/monitor-windows-linux-server-with-ping-script/">http://bash.cyberciti.biz/monitoring/monitor-windows-linux-server-with-ping-script/</a></p>
  
<div class="wp_license">
<p><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/th/"><img src="http://i.creativecommons.org/l/by-nc-sa/3.0/th/88x31.png" alt="Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Thailand" class="alignleft" style="margin-top:4px;" />
</a>This work  is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/th/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Thailand</a>.</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://imrgill.com/2009/12/11/monitor-server-with-sms-alert-shell-script.html/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>Google Public DNS บน Ubuntu</title>
		<link>http://imrgill.com/2009/12/08/google-public-dns-on-ubuntu.html</link>
		<comments>http://imrgill.com/2009/12/08/google-public-dns-on-ubuntu.html#comments</comments>
		<pubDate>Tue, 08 Dec 2009 07:19:39 +0000</pubDate>
		<dc:creator>mrgill</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google public dns]]></category>
		<category><![CDATA[nameserver]]></category>

		<guid isPermaLink="false">http://imrgill.com/?p=415</guid>
		<description><![CDATA[ไม่นานมานี้ Google เปิดให้บริการใหม่นั้นคือ Google Public DNS ซึ่งเป็นบริการสอบถามชื่อและไอพีฟรีของ Google ซึ่งสิ่งที่คุณจะได้จากบริการนี้คือ 1. ความเร็วในการใช้งานบราวเซอร์ 2. ความปลอดภัยที่ดีกว่า 3. ได้ผลลัพธิ์ทันทีโดยไม่ต้อง Redirect มาดูกันว่าเราจะใช้ Google Public DNS บน Ubuntu ได้ยังไง สำหรับใครที่ใช้ Ubuntu Desktop หรือ Linux Server ที่ Fix IP ก็สามารถเข้าไปแก้ไขไฟล์ /etc/resolv.conf ได้โดยตรง ตัวอย่าง root@mrgill-laptop:~# nano /etc/resolv.conf จากนั้นแก้ไขข้อมูลในไฟล์ /etc/resolv.conf ให้เป็น nameserver 8.8.8.8 nameserver 8.8.4.4 และสำหรับใครที่ใช้ Ubuntu Desktop แล้วรับ DHCP มาทุกครั้งที่ renew ip เราจะได้ [...]]]></description>
			<content:encoded><![CDATA[<p>ไม่นานมานี้ Google เปิดให้บริการใหม่นั้นคือ Google Public DNS ซึ่งเป็นบริการสอบถามชื่อและไอพีฟรีของ Google ซึ่งสิ่งที่คุณจะได้จากบริการนี้คือ</p>
<p>1. ความเร็วในการใช้งานบราวเซอร์<br />
2. ความปลอดภัยที่ดีกว่า<br />
3. ได้ผลลัพธิ์ทันทีโดยไม่ต้อง Redirect</p>
<p>มาดูกันว่าเราจะใช้ Google Public DNS บน Ubuntu ได้ยังไง</p>
<p>สำหรับใครที่ใช้ Ubuntu Desktop หรือ Linux Server ที่ Fix IP ก็สามารถเข้าไปแก้ไขไฟล์ /etc/resolv.conf ได้โดยตรง</p>
<p><strong>ตัวอย่าง</strong></p>
<pre>
<div class="codesnip-container" >root@mrgill-laptop:~# nano /etc/resolv.conf</div>
</pre>
<p>จากนั้นแก้ไขข้อมูลในไฟล์ /etc/resolv.conf ให้เป็น</p>
<pre>
<div class="codesnip-container" >nameserver 8.8.8.8
nameserver 8.8.4.4</div>
</pre>
<p>และสำหรับใครที่ใช้ Ubuntu Desktop แล้วรับ DHCP มาทุกครั้งที่ renew ip เราจะได้ dns ที่ dhcp แจกมาให้ซึ่งวิธีแก้ไขนี้ทำได้โดย<br />
<span id="more-415"></span><br />
1. คลิกขวาที่ Applet Network Manager บริเวร Notification Area จากนั้นเลือก Edit Connections</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2536/4168637292_dd04bd71fc_o.jpg" alt="" width="421" height="177" />Edit Connections</p>
<p style="text-align: left;">2. จะปรากฎหน้าจอ Network Connections ขึ้นมา แล้วเลือก Connection ที่คุณใช้ ตัวอย่างของผมใช้ Wireless ที่มี SSID ที่ชื่อ mrgill_wifi จากนั้นคลิกที่ปุ่ม Edit</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2550/4168637294_ef0ba7574c_o.jpg" alt="" width="442" height="322" />Network Connections</p>
<p style="text-align: left;">3. จะเห็นหน้าจอ Editing</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2564/4168637304_e799e738e8_o.jpg" alt="" width="385" height="499" />Editing</p>
<p style="text-align: left;">ให้เปลี่ยน Method จาก Automatic (DHCP) เป็น Automatic (DHCP) address only</p>
<p style="text-align: left;">จากนั้นในช่อง DNS servers ให้กรอก 8.8.8.8, 8.8.4.4 ลงไป ดังรูป</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2547/4168637308_96aef2664b_o.jpg" alt="" width="385" height="500" />Editing (2)</p>
<p style="text-align: left;">จากนั้นคลิกปุ่ม Apply</p>
<p style="text-align: left;">4. สั่งให้ Ubuntu ใช้ DNS ที่เพิ่งเปลี่ยนไปโดยคลิกที่ Applet Network Manager จากนั้นเลือกเน็ตเวิร์คที่คุณใช้</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2682/4168637310_9b7be0f868_o.jpg" alt="" width="344" height="302" />เลือก Network ที่คุณใช้งาน</p>
<p style="text-align: left;"><img class="aligncenter" src="http://farm3.static.flickr.com/2648/4168637314_66061f8a93_o.jpg" alt="" width="346" height="174" /><img class="aligncenter" src="http://farm3.static.flickr.com/2554/4167876119_bf5ec40a5c_o.jpg" alt="" width="344" height="174" /></p>
<p style="text-align: left;">5. ดูผลที่ได้ว่า DNS เปลี่ยนเป็นที่เรากำหนดหรือยังโดยคลิกขวาที่ Applet Network Manager แล้วคลิก Connection Information</p>
<p style="text-align: left;"><img class="aligncenter" src="http://farm3.static.flickr.com/2564/4167949259_da69a2c0b2_o.jpg" alt="" width="341" height="171" /></p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2761/4168707880_caa87bdebc_o.jpg" alt="" width="368" height="433" />Connection Information</p>
<p style="text-align: left;">สังเกตตรง Primary DNS กับ Secondary DNS จะเป็น IP ของ Google Public DNS แล้ว</p>
<p style="text-align: left;">หรือใครจะใช้คำสั่ง</p>
<pre>
<div class="codesnip-container" >root@mrgill-laptop:~# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4</div>
</pre>
<p>ก็จะได้ผลเหมือนกัน</p>
<p>6. สุดท้ายก็ทดลองเปิด Browser แล้วเข้าเว็บกันเลยครับผม</p>
<p>รายละเอียดเพิ่มเติม : <a href="http://code.google.com/speed/public-dns/" target="_blank">http://code.google.com/speed/public-dns/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://imrgill.com/2009/12/08/google-public-dns-on-ubuntu.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>จะเอา /var/lib/mysql บน Ubuntu ไปไว้ที่อื่นทำอย่างไร</title>
		<link>http://imrgill.com/2009/11/09/how-to-move-mysql-data-folder-to-another-path.html</link>
		<comments>http://imrgill.com/2009/11/09/how-to-move-mysql-data-folder-to-another-path.html#comments</comments>
		<pubDate>Mon, 09 Nov 2009 07:57:58 +0000</pubDate>
		<dc:creator>mrgill</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://imrgill.com/?p=332</guid>
		<description><![CDATA[ต้องการเอา /var/lib/mysql ไปไว้ที่อื่นครับเพราะกลัวเวลาเครื่องมีปัญหาอาจทำให้ข้อมูลหายได้เพราะ /var/lib/mysql อยู่ใน / เลย(ไม่ได้แบ่ง partition แยกออกมา) วิธีแรกที่ผมทำเลยคือ root@ubuntu:~# mv /var/lib/mysql /data/mysql root@ubuntu:~# ln -s /data/mysql /var/lib/mysql ก็คือ move จาก /var/lib/mysql ไปไว้ที่ /data/mysql ผลคือตอน restart mysql มันจะฟ้องว่า root@ubuntu:~# /etc/init.d/mysql restart * Stopping MySQL database server mysqld [ OK ] * Starting MySQL database server mysqld [fail] ไปใน /var/log/syslog ก็เจอ error ประมาณนี้ แล้วจะทำไงดี root@ubuntu:~# [...]]]></description>
			<content:encoded><![CDATA[<p>ต้องการเอา /var/lib/mysql ไปไว้ที่อื่นครับเพราะกลัวเวลาเครื่องมีปัญหาอาจทำให้ข้อมูลหายได้เพราะ /var/lib/mysql อยู่ใน / เลย(ไม่ได้แบ่ง partition แยกออกมา) วิธีแรกที่ผมทำเลยคือ</p>
<pre>
<div class="codesnip-container" >root@ubuntu:~# mv /var/lib/mysql /data/mysql
root@ubuntu:~# ln -s /data/mysql /var/lib/mysql</div>
</pre>
<p>ก็คือ move จาก /var/lib/mysql ไปไว้ที่ /data/mysql ผลคือตอน restart mysql มันจะฟ้องว่า</p>
<pre>
<div class="codesnip-container" >root@ubuntu:~# /etc/init.d/mysql restart
* Stopping MySQL database server mysqld                                 [ OK ]
* Starting MySQL database server mysqld                                 [fail]</div>
</pre>
<p>ไปใน /var/log/syslog ก็เจอ error ประมาณนี้ แล้วจะทำไงดี</p>
<pre>
<div class="codesnip-container" >root@ubuntu:~# tail -f /var/log/syslog
Nov  9 02:36:29 ubuntu kernel: [ 2394.732730] type=1503 audit(1257752189.048:131): operation="open" pid=5484 parent=5483 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov  9 02:36:30 ubuntu kernel: [ 2395.745479] type=1503 audit(1257752190.061:132): operation="open" pid=5494 parent=5493 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov  9 02:36:31 ubuntu kernel: [ 2396.761345] type=1503 audit(1257752191.080:133): operation="open" pid=5504 parent=5503 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov  9 02:36:31 ubuntu kernel: [ 2396.774493] type=1503 audit(1257752191.092:134): operation="open" pid=5513 parent=5512 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
Nov  9 02:36:31 ubuntu /etc/init.d/mysql[5520]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Nov  9 02:36:31 ubuntu /etc/init.d/mysql[5520]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
Nov  9 02:36:31 ubuntu /etc/init.d/mysql[5520]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Nov  9 02:36:31 ubuntu /etc/init.d/mysql[5520]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!</div>
</pre>
<p><span id="more-332"></span><br />
ผมไปเจอคำตอบที่นี่ครับ<br />
<a href="http://forums.mysql.com/read.php?24,211657,225700#msg-225700">http://forums.mysql.com/read.php?24,211657,225700#msg-225700</a><br />
เขาบอกว่าให้เข้าไปแก้ไฟล์ /etc/apparmor.d/usr.sbin.mysqld ผมก็จัดไป</p>
<pre>
<div class="codesnip-container" >root@ubuntu:~# /etc/apparmor.d/usr.sbin.mysqld</div>
</pre>
<p>โดยเปลี่ยนจาก</p>
<pre>
<div class="codesnip-container" ># vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include 

/usr/sbin/mysqld {
  #include
  #include
  #include
  #include
  #include 

  capability dac_override,
  capability sys_resource,
  capability setgid,
  capability setuid,

  network tcp,

  /etc/hosts.allow r,
  /etc/hosts.deny r,

  /etc/mysql/*.pem r,
  /etc/mysql/conf.d/ r,
  /etc/mysql/conf.d/* r,
  /etc/mysql/my.cnf r,
  /usr/sbin/mysqld mr,
  /usr/share/mysql/** r,
  /var/log/mysql.log rw,
  /var/log/mysql.err rw,
<span style="color: #ff0000;">  /var/lib/mysql/ r,
  /var/lib/mysql/** rwk,</span>
  /var/log/mysql/ r,
  /var/log/mysql/* rw,
  /var/run/mysqld/mysqld.pid w,
  /var/run/mysqld/mysqld.sock w,
}</div>
</pre>
<p>ให้เปลี่ยนเป็น</p>
<pre>
<div class="codesnip-container" ># vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include 

/usr/sbin/mysqld {
  #include
  #include
  #include
  #include
  #include 

  capability dac_override,
  capability sys_resource,
  capability setgid,
  capability setuid,

  network tcp,

  /etc/hosts.allow r,
  /etc/hosts.deny r,

  /etc/mysql/*.pem r,
  /etc/mysql/conf.d/ r,
  /etc/mysql/conf.d/* r,
  /etc/mysql/my.cnf r,
  /usr/sbin/mysqld mr,
  /usr/share/mysql/** r,
  /var/log/mysql.log rw,
  /var/log/mysql.err rw,
<span style="color: #ff0000;">  /data/mysql/ r,
  /data/mysql/** rwk,</span>
  /var/log/mysql/ r,
  /var/log/mysql/* rw,
  /var/run/mysqld/mysqld.pid w,
  /var/run/mysqld/mysqld.sock w,
}</div>
</pre>
<p>แต่อย่าเพิ่งลบ Symbolic Link นะครับยังจำเป็นต้องใช้<br />
จากนั้นก็สั่ง Restart Apparmor โดย</p>
<pre>
<div class="codesnip-container" >root@ubuntu:~# /etc/init.d/apparmor restart</div>
</pre>
<p>จากนั้นลองสั่ง Restart Mysql อีกครั้ง</p>
<pre>
<div class="codesnip-container" >root@ubuntu:~# /etc/init.d/mysql restart
 * Stopping MySQL database server mysqld                                [ OK ]
 * Starting MySQL database server mysqld                                [ OK ]
 * Checking for corrupt, not cleanly closed and upgrade needing tables.</div>
</pre>
<p>ก็คงจบแต่เพียงเท่านี้</p>
]]></content:encoded>
			<wfw:commentRss>http://imrgill.com/2009/11/09/how-to-move-mysql-data-folder-to-another-path.html/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>จะเข้า Recovery Mode บน Ubuntu 9.10 Karmic Koala ยังไง</title>
		<link>http://imrgill.com/2009/11/09/how-to-ubuntu-910-boot-as-recovery-mode.html</link>
		<comments>http://imrgill.com/2009/11/09/how-to-ubuntu-910-boot-as-recovery-mode.html#comments</comments>
		<pubDate>Mon, 09 Nov 2009 00:13:00 +0000</pubDate>
		<dc:creator>mrgill</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[boot]]></category>
		<category><![CDATA[grub2]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[rescue]]></category>

		<guid isPermaLink="false">http://imrgill.com/?p=323</guid>
		<description><![CDATA[สวัสดีตอนเช้าครับ ฮาๆ ยังไม่ได้นอนเลย เมื่อคืนนั่งลง Ubuntu Server ให้เพื่อนทั้งคืนจนถึงเช้า นั่งทำให้ Ubuntu Server หน้าตาเหมือน Ubuntu Desktop วิธีการก็ง่ายๆ ครับ $ sudo apt-get install ubuntu-desktop ก็ลงไว้ให้เพื่อนมันใช้งานง่ายๆ ครับ ลงไปลงมามีปัญหาจำเป็นต้องเข้า Recovery Mode เอ๊ะแต่เจ้า 9.10 นี่มันเข้า Boot Menu ของ Grub2 ยังไงหวา ปกติมันวิ่งๆ แล้วก็เข้าหน้า login เลย กด Esc เหมือน 9.04 แล้วก็ยังเข้าไม่ได้ ก็ลอง Search ใน Google ดูก็พบคำตอบครับคือต้องกด Shift ค้างไว้ตอน Boot มันก็จะแสดงหน้าเมนูของ Grub2 มาให้เลือกนั้นเอง]]></description>
			<content:encoded><![CDATA[<p>สวัสดีตอนเช้าครับ ฮาๆ ยังไม่ได้นอนเลย เมื่อคืนนั่งลง Ubuntu Server ให้เพื่อนทั้งคืนจนถึงเช้า นั่งทำให้ Ubuntu Server หน้าตาเหมือน Ubuntu Desktop วิธีการก็ง่ายๆ ครับ</p>
<pre>
<div class="codesnip-container" >$ sudo apt-get install ubuntu-desktop</div>
</pre>
<p>ก็ลงไว้ให้เพื่อนมันใช้งานง่ายๆ ครับ ลงไปลงมามีปัญหาจำเป็นต้องเข้า Recovery Mode เอ๊ะแต่เจ้า 9.10 นี่มันเข้า Boot Menu ของ Grub2 ยังไงหวา ปกติมันวิ่งๆ แล้วก็เข้าหน้า login เลย กด Esc เหมือน 9.04 แล้วก็ยังเข้าไม่ได้ ก็ลอง Search ใน Google ดูก็พบคำตอบครับคือต้องกด <strong><em>Shift</em></strong> ค้างไว้ตอน Boot มันก็จะแสดงหน้าเมนูของ Grub2 มาให้เลือกนั้นเอง</p>
]]></content:encoded>
			<wfw:commentRss>http://imrgill.com/2009/11/09/how-to-ubuntu-910-boot-as-recovery-mode.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>20 ขั้นตอนการทำ Hardening Linux Server</title>
		<link>http://imrgill.com/2009/11/02/20-step-for-hardening-linux-server.html</link>
		<comments>http://imrgill.com/2009/11/02/20-step-for-hardening-linux-server.html#comments</comments>
		<pubDate>Mon, 02 Nov 2009 07:22:52 +0000</pubDate>
		<dc:creator>mrgill</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[operating system]]></category>
		<category><![CDATA[os]]></category>

		<guid isPermaLink="false">http://imrgill.com/?p=283</guid>
		<description><![CDATA[การ Hardening เป็นการทำให้เครื่องเซิร์ฟเวอร์มีความปลอดภัยมากยิ่งขึ้น ซึ่งสามารถแยกออกเป็นการทำ Hardening OS และ Hardening Application ในส่วนของ Application เราคงไม่พูดถึงในส่วนนี้ ที่จะพูดถึงในวันนี้คือการ Hardening OS ครับซึ่งสามารถเข้าไปอ่านขั้นตอนการทำ Hardengin Linux Server ได้ที่ http://www.cyberciti.biz/tips/linux-security.html]]></description>
			<content:encoded><![CDATA[<p>การ Hardening เป็นการทำให้เครื่องเซิร์ฟเวอร์มีความปลอดภัยมากยิ่งขึ้น ซึ่งสามารถแยกออกเป็นการทำ Hardening OS และ Hardening Application ในส่วนของ Application เราคงไม่พูดถึงในส่วนนี้</p>
<p>ที่จะพูดถึงในวันนี้คือการ Hardening OS ครับซึ่งสามารถเข้าไปอ่านขั้นตอนการทำ Hardengin Linux Server ได้ที่</p>
<h2><a href="http://www.cyberciti.biz/tips/linux-security.html" target="_blank">http://www.cyberciti.biz/tips/linux-security.html</a></h2>
<p><!-- wp_ad_camp_2 --></p>
]]></content:encoded>
			<wfw:commentRss>http://imrgill.com/2009/11/02/20-step-for-hardening-linux-server.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ไฟล์ Binary Shoutcast ภาษาไทย</title>
		<link>http://imrgill.com/2009/10/23/shoutcast-thai-patch.html</link>
		<comments>http://imrgill.com/2009/10/23/shoutcast-thai-patch.html#comments</comments>
		<pubDate>Thu, 22 Oct 2009 19:48:11 +0000</pubDate>
		<dc:creator>mrgill</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[shoutcast]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[ภาษาไทย]]></category>

		<guid isPermaLink="false">http://imrgill.com/blog/?p=143</guid>
		<description><![CDATA[เมื่อสองปีก่อนผมเคยเขียนบทความเรื่อง การทำสถานีวิทยุ Online ด้วย Shoutcast Server ฉบับ Mr_Gill แล้วก็ได้รับการตอบรับอย่างดี(มีคน copy ไปโพสเพียบ)  หลังจากนั้นก็ห่างหายไปกับเรื่อง streaming ไปเลย สัปดาห์ก่อนมีคนถามเรื่อง shoutcast ภาษาไทย วันนี้ก็เลยเอาไฟล์ binary ที่แก้ไขเป็นภาษาไทยแล้วทั้งของ windows และ linux มาฝากครับ สำหรับ Linux sc_serv_1.9.8_Linux.tar.bz2 Console สำหรับ Windows  sc_serv_1.9.8_win32_console.tar.bz2 GUI สำหรับ Windows sc_serv_1.9.8_win32_gui.tar.bz2 วิธีนำไปใช้ ก็นำไปทับไฟล์เก่าได้เลยครับ ลองเอาไปใช้กันดูครับ]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-144 alignleft" style="border: 0pt none; margin: 0px;" title="sc-logo" src="http://imrgill.com/wp-content/uploads/2009/10/sc-logo.png" alt="sc-logo" width="400" height="113" /></p>
<p>เมื่อสองปีก่อนผมเคยเขียนบทความเรื่อง <a href="http://learners.in.th/blog/mrgill/51511">การทำสถานีวิทยุ Online ด้วย Shoutcast Server ฉบับ Mr_Gill</a> แล้วก็ได้รับการตอบรับอย่างดี(มีคน copy ไปโพสเพียบ)  หลังจากนั้นก็ห่างหายไปกับเรื่อง streaming ไปเลย สัปดาห์ก่อนมีคนถามเรื่อง shoutcast ภาษาไทย วันนี้ก็เลยเอาไฟล์ binary ที่แก้ไขเป็นภาษาไทยแล้วทั้งของ windows และ linux มาฝากครับ</p>
<ul>
<li>สำหรับ Linux <a href="http://learners.in.th/file/gillclub/sc_serv_1.9.8_Linux.tar.bz2">sc_serv_1.9.8_Linux.tar.bz2</a></li>
<li>Console สำหรับ <a href="http://learners.in.th/file/gillclub/sc_serv_1.9.8_win32_console.tar.bz2">Windows  sc_serv_1.9.8_win32_console.tar.bz2</a></li>
<li>GUI สำหรับ <a href="http://learners.in.th/file/gillclub/sc_serv_1.9.8_win32_gui.tar.bz2">Windows sc_serv_1.9.8_win32_gui.tar.bz2</a></li>
</ul>
<p><!-- wp_ad_camp_2 --><br />
วิธีนำไปใช้ ก็นำไปทับไฟล์เก่าได้เลยครับ</p>
<p>ลองเอาไปใช้กันดูครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://imrgill.com/2009/10/23/shoutcast-thai-patch.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

