<?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; Performance</title>
	<atom:link href="http://spalinux.com/category/performance/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>ใช้ yum ปรับปรุงเวอร์ชั่นของแพ็คเกจ</title>
		<link>http://spalinux.com/2012/05/use-yum-to-update-package-version</link>
		<comments>http://spalinux.com/2012/05/use-yum-to-update-package-version#comments</comments>
		<pubDate>Mon, 07 May 2012 09:34:13 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[CentOS 6]]></category>
		<category><![CDATA[Linux Installation]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Yum]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=2322</guid>
		<description><![CDATA[ทางทีมดูแลพัฒนา CentOS จะคอยดูแลปรับปรุงโปรแกรมและออกเวอร์ชั่นใหม่ตาม RedHat อยู่เสมอ ไฟล์แพ็คเกจเวอร์ชั่นใหม่นี้ จะถูกเก็บไว้ใน repos ชื่อ updates เพื่อให้ผู้ใช้งานสามารถใช้ yum เข้ามาตรวจสอบและปรับปรุงโปรแกรมได้ ในที่นี้จะแนะนำวิธีการปรับปรุงโปรแกรมโดยใช้คำสั่ง yum ทั้งปรับปรุงเฉพาะโปรแกรม หรือปรับปรุงทุกโปรแกรมที่ติดตั้งบนเครื่องลีนุกซ์แล้ว คำเตือน แนะนำให้ทดสอบในเครื่องลีนุกซ์ทดลองดูก่อน เพื่อดูผลกระทบการปรับปรุงเวอร์ชั่นของโปรแกรม ปรับปรุงแพ็คเกจที่ระบุ สมมติว่าต้องการจะปรับปรุง (update) แพ็คเกจ openssh ใช้คำสั่ง yum list installed เพื่อดูข้อมูลแพ็คเกจ openssh ที่ติดตั้งไว้  [root@cent62-yum ~]# yum list installed openssh Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile Installed Packages openssh.x86_64       5.3p1-70.el6       @anaconda-CentOS-201112091719.x86_64/6.2 ใช้คำสั่ง yum [...]]]></description>
			<content:encoded><![CDATA[<p>ทางทีมดูแลพัฒนา CentOS จะคอยดูแลปรับปรุงโปรแกรมและออกเวอร์ชั่นใหม่ตาม RedHat อยู่เสมอ ไฟล์แพ็คเกจเวอร์ชั่นใหม่นี้ จะถูกเก็บไว้ใน repos ชื่อ updates เพื่อให้ผู้ใช้งานสามารถใช้ yum เข้ามาตรวจสอบและปรับปรุงโปรแกรมได้</p>
<p>ในที่นี้จะแนะนำวิธีการปรับปรุงโปรแกรมโดยใช้คำสั่ง yum ทั้งปรับปรุงเฉพาะโปรแกรม หรือปรับปรุงทุกโปรแกรมที่ติดตั้งบนเครื่องลีนุกซ์แล้ว</p>
<p><span style="color: #ff0000;">คำเตือน แนะนำให้ทดสอบในเครื่องลีนุกซ์ทดลองดูก่อน เพื่อดูผลกระทบการปรับปรุงเวอร์ชั่นของโปรแกรม</span></p>
<p><span id="more-2322"></span></p>
<h4>ปรับปรุงแพ็คเกจที่ระบุ</h4>
<p>สมมติว่าต้องการจะปรับปรุง (update) แพ็คเกจ openssh</p>
<p>ใช้คำสั่ง yum list installed เพื่อดูข้อมูลแพ็คเกจ openssh ที่ติดตั้งไว้ </p>
<pre>[root@cent62-yum ~]# <strong>yum list installed openssh</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Installed Packages
openssh.x86_64       5.3p1-70.el6       @anaconda-CentOS-201112091719.x86_64/6.2</pre>
<p>ใช้คำสั่ง yum list available หรือ yum list updates เพื่อดูเวอร์ชั่นที่มีให้ปรับปรุง</p>
<pre>[root@cent62-yum ~]# <strong>yum list updates openssh</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Updated Packages
openssh.x86_64                     5.3p1-70.el6_2.2                      updates</pre>
<p>ใช้คำสั่ง yum update  ตามด้วยชื่อแพ็คเกจที่ต้องการปรับปรุง</p>
<p>หมายเหตุ สังเกตการใช้คำว่า updates และ update อย่างแรก updates (มี s) เป็นชื่อ repos ส่วน update (ไม่มี s) เป็นคำสั่งของ yum เพื่อใช้ปรับปรุงแพ็คเกจเวอร์ชั่น</p>
<pre>[root@cent62-yum ~]# <strong>yum update openssh</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Update Process
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package openssh.x86_64 0:5.3p1-70.el6 will be updated
--&gt; Processing Dependency: openssh = 5.3p1-70.el6 for package: openssh-server-5.3p1-70.el6.x86_64
--&gt; Processing Dependency: openssh = 5.3p1-70.el6 for package: openssh-clients-5.3p1-70.el6.x86_64
---&gt; Package openssh.x86_64 0:5.3p1-70.el6_2.2 will be an update
--&gt; Running transaction check
---&gt; Package openssh-clients.x86_64 0:5.3p1-70.el6 will be updated
---&gt; Package openssh-clients.x86_64 0:5.3p1-70.el6_2.2 will be an update
---&gt; Package openssh-server.x86_64 0:5.3p1-70.el6 will be updated
---&gt; Package openssh-server.x86_64 0:5.3p1-70.el6_2.2 will be an update
--&gt; Finished Dependency Resolution</pre>
<pre>Dependencies Resolved</pre>
<pre>================================================================================
 Package               Arch         Version                 Repository     Size
================================================================================
Updating:
 openssh               x86_64       5.3p1-70.el6_2.2        updates       235 k
Updating for dependencies:
 openssh-clients       x86_64       5.3p1-70.el6_2.2        updates       357 k
 openssh-server        x86_64       5.3p1-70.el6_2.2        updates       297 k</pre>
<pre>Transaction Summary
================================================================================
Upgrade       3 Package(s)</pre>
<pre>Total download size: 888 k
Is this ok [y/N]:</pre>
<p>เหมือนกับการติดตั้งใหม่ yum จะตรวจสอบแพ็คเกจอื่นๆ ที่จำเป็น รวมทั้งเวอร์ชั่นที่ต้องปรับปรุงพร้อมกันไปด้วย</p>
<p>เช่นในตัวอย่างนี้ ถ้าต้องการปรับปรุงแพ็คเกจ openssh จำเป็นต้องปรับปรุง openssh-clients และ openssh-server ไปด้วย</p>
<p>พิมพ์ y แล้ว [Enter] เพื่อยืนยันการปรับปรุง</p>
<pre>Is this ok [y/N]: <strong>y</strong>
Downloading Packages:
(1/3): openssh-5.3p1-70.el6_2.2.x86_64.rpm               | 235 kB     00:01
(2/3): openssh-clients-5.3p1-70.el6_2.2.x86_64.rpm       | 357 kB     00:01
(3/3): openssh-server-5.3p1-70.el6_2.2.x86_64.rpm        | 297 kB     00:01
--------------------------------------------------------------------------------
Total                                           150 kB/s | 888 kB     00:05</pre>
<pre>Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : openssh-5.3p1-70.el6_2.2.x86_64                              1/6
  Updating   : openssh-clients-5.3p1-70.el6_2.2.x86_64                      2/6
  Updating   : openssh-server-5.3p1-70.el6_2.2.x86_64                       3/6
  Cleanup    : openssh-server-5.3p1-70.el6.x86_64                           4/6
  Cleanup    : openssh-clients-5.3p1-70.el6.x86_64                          5/6
  Cleanup    : openssh-5.3p1-70.el6.x86_64                                  6/6</pre>
<pre>Updated:
  openssh.x86_64 0:5.3p1-70.el6_2.2</pre>
<pre>Dependency Updated:
  openssh-clients.x86_64 0:5.3p1-70.el6_2.2
  openssh-server.x86_64 0:5.3p1-70.el6_2.2</pre>
<pre>Complete!</pre>
<p>ใช้คำสั่ง yum list เพื่อดูแพ็คเกจหลังการปรับปรุง</p>
<pre>[root@cent62-yum ~]# <strong>yum list installed openssh</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Installed Packages
openssh.x86_64                     5.3p1-70.el6_2.2                     @updates</pre>
<p>ลองใช้ yum list updates อีกครั้ง จะไม่มีเวอร์ชั่นใหม่ ให้ปรับปรุงอีกแล้ว</p>
<pre>[root@cent62-yum ~]# <strong>yum list updates openssh</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Error: No matching Packages to list</pre>
<p>หมายเหตุ หลังการปรับปรุงแพ็คเกจ บางโปรแกรมอาจต้องแก้ไขเพิ่มเติม เช่นหลังการปรับปรุง openssh ต้องมีการรีสตาร์ตเซอร์วิส sshd (OpenSSH Server) เพื่อให้เวอร์ชั่นใหม่มีผล</p>
<p>&nbsp;</p>
<h4>ปรับปรุงทุกแพ็คเกจในเครื่อง</h4>
<p>พิมพ์ yum list updates เพื่อดูรายชื่อแพ็คเกจทั้งหมด ที่มีเวอร์ชั่นใหม่ (ใน repos) ให้ปรับปรุง</p>
<pre>[root@cent62-yum ~]# <strong>yum list updates</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Updated Packages
at.x86_64                              3.1.10-43.el6_2.1                 updates
bind-libs.x86_64                       32:9.7.3-8.P3.el6_2.2             updates
bind-utils.x86_64                      32:9.7.3-8.P3.el6_2.2             updates
chkconfig.x86_64                       1.3.49.3-1.el6_2                  updates
cups-libs.x86_64                       1:1.4.2-44.el6_2.3                updates
...</pre>
<p>หากต้องการปรับปรุงแพ็คเกจทั้งหมด สามารถทำได้โดยพิมพ์ yum update โดยไม่ต้องตามด้วยชื่อแพ็คเกจใดๆ </p>
<pre>[root@cent62-yum ~]# <strong>yum update</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Update Process
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package at.x86_64 0:3.1.10-43.el6 will be updated
---&gt; Package at.x86_64 0:3.1.10-43.el6_2.1 will be an update
---&gt; Package bind-libs.x86_64 32:9.7.3-8.P3.el6 will be updated
---&gt; Package bind-libs.x86_64 32:9.7.3-8.P3.el6_2.2 will be an update
---&gt; Package bind-utils.x86_64 32:9.7.3-8.P3.el6 will be updated
---&gt; Package bind-utils.x86_64 32:9.7.3-8.P3.el6_2.2 will be an update</pre>
<pre>...</pre>
<pre>--&gt; Finished Dependency Resolution</pre>
<pre>Dependencies Resolved</pre>
<pre>================================================================================
 Package                   Arch     Version                     Repository
                                                                           Size
================================================================================
Installing:
 kernel                    x86_64   2.6.32-220.13.1.el6         updates    24 M
Updating:
 at                        x86_64   3.1.10-43.el6_2.1           updates    60 k
 bind-libs                 x86_64   32:9.7.3-8.P3.el6_2.2       updates   840 k
 bind-utils                x86_64   32:9.7.3-8.P3.el6_2.2       updates   178 k</pre>
<pre>...</pre>
<pre>Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade      53 Package(s)</pre>
<pre>Total download size: 68 M
Is this ok [y/N]:</pre>
<p>ผลลัพธ์จะแสดงรายชื่อแพ็คเกจทั้งหมดที่จะปรับปรุง แสดงจำนวนแพ็คเกจ และขนาดรวมที่ต้องดาวน์โหลด พิมพ์ y แล้ว [Enter] เพื่อยืนยันการปรับปรุง</p>
<pre>Is this ok [y/N]: <strong>y</strong>
Downloading Packages:
(1/54): at-3.1.10-43.el6_2.1.x86_64.rpm                  |  60 kB     00:01
(2/54): bind-libs-9.7.3-8.P3.el6_2.2.x86_64.rpm          | 840 kB     00:04
(3/54): bind-utils-9.7.3-8.P3.el6_2.2.x86_64.rpm         | 178 kB     00:01
(4/54): chkconfig-1.3.49.3-1.el6_2.x86_64.rpm            | 159 kB     00:03</pre>
<pre>...</pre>
<pre>--------------------------------------------------------------------------------
Total                                           293 kB/s |  68 MB     03:58
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : 12:dhcp-common-4.1.1-25.P1.el6_2.1.x86_64                  1/107
  Updating   : kernel-firmware-2.6.32-220.13.1.el6.noarch                 2/107
  Updating   : tzdata-2012b-3.el6.noarch                                  3/107
  Updating   : glibc-2.12-1.47.el6_2.9.x86_64                             4/107</pre>
<pre>...</pre>
<pre>Installed:
  kernel.x86_64 0:2.6.32-220.13.1.el6</pre>
<pre>Updated:
  at.x86_64 0:3.1.10-43.el6_2.1
  bind-libs.x86_64 32:9.7.3-8.P3.el6_2.2
  bind-utils.x86_64 32:9.7.3-8.P3.el6_2.2
  chkconfig.x86_64 0:1.3.49.3-1.el6_2</pre>
<pre>...</pre>
<pre>Complete!</pre>
<p>รีสตาร์ตเครื่องหลังจาก update โปรแกรมทั้งเครื่อง</p>
<p>เมื่อบู๊ตเครื่องขึ้นมาแล้ว ลองใช้ yum list updates อีกครั้ง</p>
<pre>[root@cent62-yum ~]# <strong>yum list updates</strong>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile</pre>
<p>ไม่มีแพ็คเกจให้ update อีกแล้ว หรือหมายความว่าเครื่องลีนุกซ์ของเราติดตั้งหรือปรับปรุงโปรแกรมเป็นเวอร์ชั่นใหม่ล่าสุด เท่ากับไฟล์ที่อยู่ใน repos แล้ว</p>
<p>&nbsp;</p>
<h4>ปรับปรุงเวอร์ชั่นจาก CentOS 6.0 เป็น 6.2</h4>
<p>หากเราติดตั้ง CentOS เวอร์ชั่นเก่า เช่น 6.0 แล้วต้องการปรับปรุงเป็นเวอร์ชั่นใหม่ เราสามารถใช้คำสั่ง yum update เพื่อปรับปรุงได้ แทนที่ต้องใช้แผ่นดีวีดีติดตั้งใหม่ทั้งหมด</p>
<p>แต่ไม่สามารถจะปรับปรุงข้าม Major เวอร์ชั่นได้ เช่นไม่สามารถปรับปรุงจาก 5.5 เป็น 6.2 ได้ ทำได้เฉพาะภายใต้ Major เวอร์ชั่นเดียวกันเท่านั้น</p>
<p>ตัวอย่างเครื่องที่ติดตั้ง CentOS 6.0 ไว้</p>
<pre>[root@cent60 ~]# <strong>cat /etc/redhat-release</strong>
CentOS Linux release 6.0 (Final)</pre>
<pre>[root@cent60 ~]# <strong>uname -a</strong>
Linux cent60.example.com 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 2011 x86_64 x86_64 x86_64 GNU/Linux</pre>
<p>ต้องการจะ update เป็น CentOS 6.2 สามารถใช้ yum update เพื่อปรับปรุงได้</p>
<pre>[root@cent60 ~]# <strong>yum update</strong>
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Update Process
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package abrt.x86_64 0:2.0.4-14.el6.centos set to be updated
--&gt; Processing Dependency: libreport.so.0()(64bit) for package: abrt-2.0.4-14.el6.centos.x86_64
--&gt; Processing Dependency: libabrt_dbus.so.0()(64bit) for package: abrt-2.0.4-14.el6.centos.x86_64
---&gt; Package abrt-addon-ccpp.x86_64 0:2.0.4-14.el6.centos set to be updated
--&gt; Processing Dependency: libbtparser.so.2()(64bit) for package: abrt-addon-ccpp-2.0.4-14.el6.centos.x86_64
---&gt; Package abrt-addon-kerneloops.x86_64 0:2.0.4-14.el6.centos set to be updated
--&gt; Processing Dependency: libreport-plugin-kerneloops for package: abrt-addon-kerneloops-2.0.4-14.el6.centos.x86_64
---&gt; Package abrt-addon-python.x86_64 0:2.0.4-14.el6.centos set to be updated
---&gt; Package abrt-cli.x86_64 0:2.0.4-14.el6.centos set to be updated
--&gt; Processing Dependency: libreport-cli for package: abrt-cli-2.0.4-14.el6.centos.x86_64
--&gt; Processing Dependency: libreport-plugin-mailx for package: abrt-cli-2.0.4-14.el6.centos.x86_64
---&gt; Package abrt-libs.x86_64 0:2.0.4-14.el6.centos set to be updated</pre>
<pre>...</pre>
<pre>Dependencies Resolved</pre>
<pre>================================================================================================================================
 Package                                     Arch               Version                               Repository           Size
================================================================================================================================
Installing:
 abrt                                        x86_64             2.0.4-14.el6.centos                   base                210 k
     replacing  abrt-plugin-sosreport.x86_64 1.1.13-4.el6
 kernel                                      x86_64             2.6.32-220.13.1.el6                   updates              24 M
 libreport-plugin-logger                     x86_64             2.0.5-20.el6                          base                 16 k
     replacing  abrt-plugin-logger.x86_64 1.1.13-4.el6
 libreport-plugin-rhtsupport                 x86_64             2.0.5-20.el6                          base                 24 k
     replacing  abrt-plugin-rhtsupport.x86_64 1.1.13-4.el6
Updating:
 abrt-addon-ccpp                             x86_64             2.0.4-14.el6.centos                   base                 93 k
 abrt-addon-kerneloops                       x86_64             2.0.4-14.el6.centos                   base                 63 k
 abrt-addon-python                           x86_64             2.0.4-14.el6.centos                   base                 57 k
 abrt-cli                                    x86_64             2.0.4-14.el6.centos                   base                 55 k
 abrt-libs                                   x86_64             2.0.4-14.el6.centos                   base                 53 k</pre>
<pre>...</pre>
<pre>Transaction Summary
================================================================================================================================
Install      12 Package(s)
Upgrade     220 Package(s)</pre>
<pre>Total download size: 152 M
Is this ok [y/N]:</pre>
<p>ตอบ y เพื่อยืนยันการปรับปรุง</p>
<pre>Is this ok [y/N]: <strong>y</strong>
Downloading Packages:
(1/232): abrt-2.0.4-14.el6.centos.x86_64.rpm                                                             | 210 kB     00:01
(2/232): abrt-addon-ccpp-2.0.4-14.el6.centos.x86_64.rpm                                                  |  93 kB     00:00
(3/232): abrt-addon-kerneloops-2.0.4-14.el6.centos.x86_64.rpm                                            |  63 kB     00:00
(4/232): abrt-addon-python-2.0.4-14.el6.centos.x86_64.rpm                                                |  57 kB     00:00
(5/232): abrt-cli-2.0.4-14.el6.centos.x86_64.rpm                                                         |  55 kB     00:00
(6/232): abrt-libs-2.0.4-14.el6.centos.x86_64.rpm                                                        |  53 kB     00:00</pre>
<pre>...</pre>
<pre>--------------------------------------------------------------------------------------------------------------------------------
Total                                                                                           272 kB/s | 152 MB     09:34</pre>
<pre>Is this ok [y/N]: <strong>y</strong></pre>
<p>ตอบ y เพื่อยืนยันการปรับปรุง</p>
<pre>Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : libgcc-4.4.6-3.el6.x86_64                                                                              1/456
  Updating       : setup-2.8.14-13.el6.noarch                                                                             2/456
warning: /etc/shadow created as /etc/shadow.rpmnew
  Updating       : filesystem-2.4.30-3.el6.x86_64                                                                         3/456
  Updating       : centos-release-6-2.el6.centos.7.x86_64                                                                 4/456</pre>
<pre>...</pre>
<pre>Installed:
  abrt.x86_64 0:2.0.4-14.el6.centos                               kernel.x86_64 0:2.6.32-220.13.1.el6
  libreport-plugin-logger.x86_64 0:2.0.5-20.el6                   libreport-plugin-rhtsupport.x86_64 0:2.0.5-20.el6</pre>
<pre>Dependency Installed:
  btparser.x86_64 0:0.13-1.el6                                          dhcp-common.x86_64 12:4.1.1-25.P1.el6_2.1
  libreport.x86_64 0:2.0.5-20.el6                                       libreport-cli.x86_64 0:2.0.5-20.el6
  libreport-plugin-kerneloops.x86_64 0:2.0.5-20.el6                     libreport-plugin-mailx.x86_64 0:2.0.5-20.el6
  libreport-plugin-reportuploader.x86_64 0:2.0.5-20.el6                 libreport-python.x86_64 0:2.0.5-20.el6</pre>
<pre>Updated:
  abrt-addon-ccpp.x86_64 0:2.0.4-14.el6.centos                       abrt-addon-kerneloops.x86_64 0:2.0.4-14.el6.centos
  abrt-addon-python.x86_64 0:2.0.4-14.el6.centos                     abrt-cli.x86_64 0:2.0.4-14.el6.centos
  abrt-libs.x86_64 0:2.0.4-14.el6.centos                             acl.x86_64 0:2.2.49-6.el6</pre>
<pre>...</pre>
<pre>Replaced:
  abrt-plugin-logger.x86_64 0:1.1.13-4.el6 abrt-plugin-rhtsupport.x86_64 0:1.1.13-4.el6 abrt-plugin-sosreport.x86_64 0:1.1.13-4.el6</pre>
<pre>Complete!</pre>
<p>รีสตาร์ตเครื่อง แล้วตรวจสอบผลที่ได้</p>
<pre>[root@cent60 ~]# <strong>cat /etc/redhat-release</strong>
CentOS release 6.2 (Final)</pre>
<pre>[root@cent60 ~]# <strong>uname -a</strong>
Linux cent60.example.com 2.6.32-220.13.1.el6.x86_64 #1 SMP Tue Apr 17 23:56:34 BST 2012 x86_64 x86_64 x86_64 GNU/Linux </pre>
<p>&nbsp;</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2012/05/using-yum-in-centos-6">การใช้งานคำสั่ง yum ใน CentOS 6</a></li>
<li><a href="http://spalinux.com/2012/05/change-yum-config-to-use-repos-in-thailand">เปลี่ยนคอนฟิก yum ให้มาใช้ repos ในไทย</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2012/05/use-yum-to-update-package-version/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>เปลี่ยนคอนฟิก yum ให้มาใช้ repos ในไทย</title>
		<link>http://spalinux.com/2012/05/change-yum-config-to-use-repos-in-thailand</link>
		<comments>http://spalinux.com/2012/05/change-yum-config-to-use-repos-in-thailand#comments</comments>
		<pubDate>Mon, 07 May 2012 06:49:32 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[CentOS 6]]></category>
		<category><![CDATA[Linux Installation]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Yum]]></category>
		<category><![CDATA[repos]]></category>
		<category><![CDATA[thailand]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=2312</guid>
		<description><![CDATA[หากต้องการใช้ yum ติดตั้งโปรแกรมเพิ่มเติม หรือปรับปรุงโปรแกรมเป็นเวอร์ชั่นใหม่ เราต้องใช้ repos ที่อยู่บนอินเตอร์เน็ต ดีฟอลต์จากการติดตั้ง CentOS 6.2 จะมีคอนฟิก repos ติดตั้งมาด้วย โดยจะชี้ไปยังเว็บไซต์ mirrorlist.centos.org แสดงรายชื่อเว็บไซต์ repos ที่ให้บริการดาวน์โหลดไฟล์ rpm อีกที แต่ข้อเสียของการใช้คอนฟิก repos แบบดีฟอลต์นี้ ในบางครั้งเราอาจต้องไปดาวน์โหลดไฟล์จากเว็บไซต์ที่อยู่ต่างประเทศ ทำให้ความเร็วที่ได้ค่อนข้างช้า ในบทนี้ขอแนะนำวิธีเปลี่ยนคอนฟิก repos ของ yum ให้ชี้มายังเว็บไซต์ในประเทศไทย ตัวอย่างคอนฟิกไฟล์ CentOS-Base.repo ซึ่งเก็บคอนฟิก repos ชื่อ  base, extras, updates [root@cent62-yum ~]# cat /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of [...]]]></description>
			<content:encoded><![CDATA[<p>หากต้องการใช้ yum ติดตั้งโปรแกรมเพิ่มเติม หรือปรับปรุงโปรแกรมเป็นเวอร์ชั่นใหม่ เราต้องใช้ repos ที่อยู่บนอินเตอร์เน็ต</p>
<p>ดีฟอลต์จากการติดตั้ง CentOS 6.2 จะมีคอนฟิก repos ติดตั้งมาด้วย โดยจะชี้ไปยังเว็บไซต์ mirrorlist.centos.org แสดงรายชื่อเว็บไซต์ repos ที่ให้บริการดาวน์โหลดไฟล์ rpm อีกที</p>
<p>แต่ข้อเสียของการใช้คอนฟิก repos แบบดีฟอลต์นี้ ในบางครั้งเราอาจต้องไปดาวน์โหลดไฟล์จากเว็บไซต์ที่อยู่ต่างประเทศ ทำให้ความเร็วที่ได้ค่อนข้างช้า</p>
<p>ในบทนี้ขอแนะนำวิธีเปลี่ยนคอนฟิก repos ของ yum ให้ชี้มายังเว็บไซต์ในประเทศไทย</p>
<p><span id="more-2312"></span>ตัวอย่างคอนฟิกไฟล์ CentOS-Base.repo ซึ่งเก็บคอนฟิก repos ชื่อ  base, extras, updates</p>
<pre>[root@cent62-yum ~]# <strong>cat /etc/yum.repos.d/CentOS-Base.repo</strong>
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
<span style="color: #0000ff;">mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=os</span>
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
...</pre>
<p>จากคอนฟิก repos ชื่อ &#8220;base&#8221;  จะดึงข้อมูลชื่อเว็บไซต์ที่คอนฟิกไว้ในออปชั่น &#8220;mirrorlist&#8221; แต่ตอนใช้งานจริงจะต้องแทนค่าตัวแปร</p>
<p>ใช้คำสั่ง yum-config-manager ตามด้วยชื่อ repos เพื่อแสดงคอนฟิก &#8220;base&#8221; ผลลัพธ์จะมีการแทนที่ค่าตัวแปรที่ ($) ที่เขียนไว้ในไฟล์คอนฟิก</p>
<pre>[root@cent62-yum ~]# <strong>yum-config-manager base</strong>
Loaded plugins: fastestmirror
================================== repo: base ==================================
[base]
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/6
baseurl =
...
<span style="color: #0000ff;">mirrorlist = http://mirrorlist.centos.org/?release=6&amp;arch=x86_64&amp;repo=os</span>
mirrorlist_expire = 86400
name = CentOS-6 - Base
...</pre>
<p>ใช้คำสั่ง curl เพื่อดึงข้อมูลจากเว็บไซต์ที่ระบุไว้ใน &#8220;mirrorlist&#8221; จะได้รายชื่อเว็บไซต์ที่ใช้เป็น repos ได้</p>
<pre>[root@cent62-yum ~]# <strong>curl 'http://mirrorlist.centos.org/?release=6&amp;arch=x86_64&amp;repo=os'</strong>

http://mirrors.psu.ac.th/pub/centos/6.2/os/x86_64/

http://mirror.issp.co.th/centos/6.2/os/x86_64/

http://mirror1.ku.ac.th/centos/6.2/os/x86_64/

http://mirror.yourconnect.com/centos/6.2/os/x86_64/

http://mirrors.btte.net/centos/6.2/os/x86_64/

...</pre>
<p>ผลลัพธ์ที่ได้จะเปลี่ยนไปเรื่อยๆ</p>
<p>รันคำสั่ง yum repolist เพื่อดูข้อมูล repos ที่จะใช้ หากรันครั้งแรก จะมีการดึงข้อมูล repos ใหม่จากอินเตอร์เน็ต หากเป็นการรันครั้งต่อๆ ไป จะใช้ข้อมูลที่เก็บไว้ในเครื่องแทน (cache)</p>
<pre>[root@cent62-yum ~]# <strong>yum repolist</strong>
Loaded plugins: fastestmirror, security
Determining fastest mirrors
 * base: <span style="color: #0000ff;">mirrors.btte.net</span>
 * extras: <span style="color: #0000ff;">mirrors.btte.net</span>
 * updates: <span style="color: #0000ff;">mirrors.btte.net</span>
base                                                     | 3.7 kB     00:00
base/primary_db                                          | 4.5 MB     00:23
extras                                                   | 3.5 kB     00:00
extras/primary_db                                        | 6.3 kB     00:00
updates                                                  | 3.5 kB     00:00
updates/primary_db                                       | 3.0 MB     00:10
repo id                        repo name                                  status
base                           CentOS-6 - Base                            6,294
extras                         CentOS-6 - Extras                              4
updates                        CentOS-6 - Updates                           832
repolist: 7,130</pre>
<p>ปัญหาหากใช้คอนฟิกดีฟอลต์แบบนี้อย่างที่กล่าวไว้ตอนแรก เราไม่สามารถควบคุมได้ว่าจะได้ใช้ repos จากเว็บไซต์ไหน เช่นจากตัวอย่างที่รัน เป็นเว็บไซต์จากประเทศจีน</p>
<p>&nbsp;</p>
<h4>เปลี่ยนมาใช้ repos ในไทย</h4>
<p>เพื่อความเร็วในการดาวน์โหลดไฟล์ แนะนำให้ใช้ repos จากเว็บไซต์ในเมืองไทย ดูง่ายๆ ชื่อโดเมนของเว็บไซต์ลงท้ายด้วย .th จากผลลัพธ์ของคำสั่ง curl จะมี</p>
<ul>
<li>http://mirrors.psu.ac.th/pub/centos/6.2/os/x86_64/</li>
<li>http://mirror.issp.co.th/centos/6.2/os/x86_64/</li>
<li>http://mirror1.ku.ac.th/centos/6.2/os/x86_64/</li>
</ul>
<p>การเปลี่ยนคอนฟิก repos ให้มาใช้เว็บไซต์ที่ต้องการ ทำได้โดยแก้ไขไฟล์ repo ปิดคอนฟิก mirrorlist  แล้วตั้งค่าเว็บไซต์ในคอนฟิก baseurl</p>
<p>เช่นต้องการเปลี่ยน repos ชื่อ base, extras, updates ให้ชี้ไปยัง mirrors.psu.ac.th ทำได้โดยแก้ไขไฟล์ CentOS-Base.repo</p>
<p>สังเกตการแก้ไขคอนฟิก baseurl ในแต่ละ repos จะไม่เหมือนกัน และจะใช้ชื่อตัวแปร ($) แทนการระบุชื่อเวอร์ชั่น  ห้ามระุบุเป็น 6.2 เพราะเมื่อเวอร์ชั่นใหม่ออกมาแล้ว จะทำให้ไฟล์คอนฟิก repos นี้ใช้งานไม่ได้</p>
<pre><span>[root@cent62-yum ~]# <strong>cat /etc/yum.repos.d/CentOS-Base.repo</strong>
</span><span>...
[base]
name=CentOS-$releasever - Base
<span style="color: #0000ff;">#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=os
</span><span style="color: #0000ff;">baseurl=http://mirrors.psu.ac.th/pub/centos/$releasever/os/$basearch/
</span>gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled = 1</span></pre>
<pre><span>#released updates
[updates]
name=CentOS-$releasever - Updates
<span style="color: #0000ff;">#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=updates
</span><span style="color: #0000ff;">baseurl=http://mirrors.psu.ac.th/pub/centos/$releasever/updates/$basearch/
</span>gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled = 1</span></pre>
<pre><span>#additional packages that may be useful
[extras] name=CentOS-$releasever - Extras
<span style="color: #0000ff;">#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=extras
</span><span style="color: #0000ff;">baseurl=http://mirrors.psu.ac.th/pub/centos/$releasever/extras/$basearch/
</span>gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled = 1 </span></pre>
<p>ใช้คำสั่ง yum repolist โดยเพิ่มออปชั่น &#8216;-v&#8217; เพื่อดูข้อมูลเพิ่มเติมของแต่ละ repos</p>
<pre>[root@cent62-yum ~]# <strong>yum -v repolist</strong>
Loading "fastestmirror" plugin
Loading "security" plugin
Config time: 0.044
Yum Version: 3.2.29
Loading mirror speeds from cached hostfile
Setting up Package Sacks
pkgsack time: 0.073
Repo-id      : base
Repo-name    : CentOS-6 - Base
Repo-revision: 1324003045
Repo-updated : Fri Dec 16 09:38:07 2011
Repo-pkgs    : 6,294
Repo-size    : 5.1 G
<span style="color: #0000ff;">Repo-baseurl : http://mirrors.psu.ac.th/pub/centos/6/os/x86_64/</span>
Repo-expire  : 21,600 second(s) (last: Mon May  7 13:16:01 2012)

Repo-id      : extras
Repo-name    : CentOS-6 - Extras
Repo-revision: 1327502687
Repo-updated : Wed Jan 25 21:44:47 2012
Repo-pkgs    : 4
Repo-size    : 3.0 M
<span style="color: #0000ff;">Repo-baseurl : http://mirrors.psu.ac.th/pub/centos/6/extras/x86_64/</span>
Repo-expire  : 21,600 second(s) (last: Mon May  7 13:16:02 2012)

Repo-id      : updates
Repo-name    : CentOS-6 - Updates
Repo-revision: 1336165833
Repo-updated : Sat May  5 04:31:48 2012
Repo-pkgs    : 832
Repo-size    : 1.7 G
<span style="color: #0000ff;">Repo-baseurl : http://mirrors.psu.ac.th/pub/centos/6/updates/x86_64/</span>
Repo-expire  : 21,600 second(s) (last: Mon May  7 13:16:02 2012)

repolist: 7,130</pre>
<p>หลังจากเปลี่ยนแล้ว ตอนนี้ yum จะดาวน์โหลดไฟล์จาก repos ตามเว็บไซต์ที่เราระบุใน baseurl แทน</p>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2012/05/change-yum-config-to-use-repos-in-thailand/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>คุณสมบัติใหม่ของ Fedora 16</title>
		<link>http://spalinux.com/2012/01/new-features-of-fedora-16</link>
		<comments>http://spalinux.com/2012/01/new-features-of-fedora-16#comments</comments>
		<pubDate>Sat, 21 Jan 2012 16:07:59 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Linux Installation]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora 16]]></category>
		<category><![CDATA[systemd]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1606</guid>
		<description><![CDATA[ด้วยความตั้งใจของ RedHat ตั้งแต่แรก คือใส่คุณสมบัติใหม่ๆ เข้าไปใน Fedora อยู่ตลอด เพื่อเป็นการทดสอบการใช้งาน และถ้าได้ผลดี ค่อยนำไปใส่ไว้ใน RedHat Enterprise อีกที ดังนั้นจะเห็นแต่ละเวอร์ชั่นของ Fedora จะมีโปรแกรม มีวิธีการคอนฟิกแบบใหม่ๆ บางครั้งก็ทำให้ผู้ดาวน์โหลดมาติดตั้ง งงไปเลยเหมือนกัน ยิ่งเวอร์ชั่นหลังๆ การเปลี่ยนแปลงค่อนข้างมาก ล่าสุดมีการนำวิธีการบู๊ต โดยใช้ systemd ช่วยทำให้บู๊ตได้เร็วขึ้นมาก ในที่นี้จะแสดงเฉพาะคุณสมบัติใหม่ๆ ของ Fedora 16 ตั้งแต่การติดตั้ง และการทดสอบบู๊ตเบื้องต้น เมนูการบู๊ตติดตั้งเปลี่ยนไป เหลือแค่สองเมนูเท่านั้น น่าจะเป็นประโยชน์สำหรับผู้ใช้ โดยเฉพาะมือใหม่จะได้ไม่งงกับเวอร์ชั่นก่อนๆ ที่มีให้เลือกหลายเมนู &#160; การติดตั้ง Fedora 16 ต้องสร้าง partition พิเศษขึ้นมา ประเภท &#8220;BIOS Boot&#8221; ขนาด 1 MB สำหรับบู๊ต &#160; Linux Kernel เวอร์ชั่น 3 [...]]]></description>
			<content:encoded><![CDATA[<p>ด้วยความตั้งใจของ RedHat ตั้งแต่แรก คือใส่คุณสมบัติใหม่ๆ เข้าไปใน Fedora อยู่ตลอด เพื่อเป็นการทดสอบการใช้งาน และถ้าได้ผลดี<br />
ค่อยนำไปใส่ไว้ใน RedHat Enterprise อีกที</p>
<p>ดังนั้นจะเห็นแต่ละเวอร์ชั่นของ Fedora จะมีโปรแกรม มีวิธีการคอนฟิกแบบใหม่ๆ บางครั้งก็ทำให้ผู้ดาวน์โหลดมาติดตั้ง งงไปเลยเหมือนกัน<br />
ยิ่งเวอร์ชั่นหลังๆ การเปลี่ยนแปลงค่อนข้างมาก ล่าสุดมีการนำวิธีการบู๊ต โดยใช้ systemd ช่วยทำให้บู๊ตได้เร็วขึ้นมาก</p>
<p>ในที่นี้จะแสดงเฉพาะคุณสมบัติใหม่ๆ ของ Fedora 16 ตั้งแต่การติดตั้ง และการทดสอบบู๊ตเบื้องต้น</p>
<p><span id="more-1606"></span></p>
<p>เมนูการบู๊ตติดตั้งเปลี่ยนไป เหลือแค่สองเมนูเท่านั้น น่าจะเป็นประโยชน์สำหรับผู้ใช้ โดยเฉพาะมือใหม่จะได้ไม่งงกับเวอร์ชั่นก่อนๆ<br />
ที่มีให้เลือกหลายเมนู</p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/01/f01.png"><img class="alignnone size-full wp-image-1607" title="f01" src="http://spalinux.com/wp-content/uploads/2012/01/f01.png" alt="" width="640" height="480" /></a></p>
<p>&nbsp;</p>
<p>การติดตั้ง Fedora 16 ต้องสร้าง partition พิเศษขึ้นมา ประเภท &#8220;BIOS Boot&#8221; ขนาด 1 MB สำหรับบู๊ต</p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/01/f11.png"><img class="alignnone size-full wp-image-1608" title="f11" src="http://spalinux.com/wp-content/uploads/2012/01/f11.png" alt="" width="1024" height="768" /></a></p>
<p>&nbsp;</p>
<p>Linux Kernel เวอร์ชั่น 3 ออกมาได้ซักพัก ทีมงาน Fedora ก็ไม่รอช้า ใส่เวอร์ชั่น 3.1 มาให้เลย</p>
<p>&nbsp;</p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/01/f18.png"><img class="alignnone size-full wp-image-1609" title="f18" src="http://spalinux.com/wp-content/uploads/2012/01/f18.png" alt="" width="720" height="400" /></a></p>
<p>&nbsp;</p>
<p>ด้วยคุณสมบัติของ systemd ลองจับเวลาดู การบู๊ตจะเร็วกว่าเมื่อเทียบกับเวอร์ชั่นก่อนๆ</p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/01/f19.png"><img class="alignnone size-full wp-image-1610" title="f19" src="http://spalinux.com/wp-content/uploads/2012/01/f19.png" alt="" width="720" height="400" /></a></p>
<p>&nbsp;</p>
<p>หน้าจอการล็อกอิน และแสดงข้อมูลเบื้องต้นหลังจากการบู๊ต</p>
<p><a href="http://spalinux.com/wp-content/uploads/2012/01/f20.png"><img class="alignnone size-full wp-image-1611" title="f20" src="http://spalinux.com/wp-content/uploads/2012/01/f20.png" alt="" width="720" height="400" /></a></p>
<p>&nbsp;</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://docs.fedoraproject.org/en-US/Fedora/16/html/Release_Notes/index.html" target="_blank">Release Notes for Fedora 16</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2012/01/new-features-of-fedora-16/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>upgrade kernel บน CentOS 5.6</title>
		<link>http://spalinux.com/2011/08/upgrade_kernel_on_centos_5-6</link>
		<comments>http://spalinux.com/2011/08/upgrade_kernel_on_centos_5-6#comments</comments>
		<pubDate>Sun, 14 Aug 2011 16:13:18 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Kernel]]></category>
		<category><![CDATA[Linux Installation]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[upgrade kernel]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1450</guid>
		<description><![CDATA[ด้วยเหตุผลทางด้านประสิทธิภาพ ต้องการลงโปรแกรม library หรือ driver ของอุปกรณ์บางตัว ที่ต้องใช้ kernel เวอร์ชั่นใหม่ ในบทความนี้ ขอแนะนำวิธีการ upgrade kernel บน CentOS 5.6  โดยการดาวน์โหลดไฟล์ rpm แล้วนำมาติดตั้งเองด้วยคำสั่ง rpm คำเตือน  - การ upgrade kernel อาจมีผลกระทบกับระบบ เช่น driver ที่ติดตั้งเอง ลองบนเครื่องทดสอบให้แน่ใจก่อนปรับปรุงจริง  - หลัง upgrade kernel ต้องรีบู๊ตเครื่อง เพื่อให้ kernel ใหม่มีผล แนะนำให้อยู่หน้าเครื่องตอนรีบู๊ต เผื่อมีปัญหาจะได้แก้ไขได้ ใช้คำสั่ง uname -a เพื่อตรวจสอบเวอร์ชั่น kernel ที่รันอยู่ [root@cent56 ~]# uname -a Linux cent56.example.com 2.6.18-238.el5 #1 SMP Thu Jan [...]]]></description>
			<content:encoded><![CDATA[<p>ด้วยเหตุผลทางด้านประสิทธิภาพ ต้องการลงโปรแกรม library หรือ driver ของอุปกรณ์บางตัว ที่ต้องใช้ kernel เวอร์ชั่นใหม่</p>
<p>ในบทความนี้ ขอแนะนำวิธีการ upgrade kernel บน CentOS 5.6  โดยการดาวน์โหลดไฟล์ rpm แล้วนำมาติดตั้งเองด้วยคำสั่ง rpm</p>
<p><span id="more-1450"></span></p>
<p><span style="color: #ff0000;">คำเตือน<br />
 - การ upgrade kernel อาจมีผลกระทบกับระบบ เช่น driver ที่ติดตั้งเอง ลองบนเครื่องทดสอบให้แน่ใจก่อนปรับปรุงจริง<br />
 - หลัง upgrade kernel ต้องรีบู๊ตเครื่อง เพื่อให้ kernel ใหม่มีผล แนะนำให้อยู่หน้าเครื่องตอนรีบู๊ต เผื่อมีปัญหาจะได้แก้ไขได้</span></p>
<p>ใช้คำสั่ง uname -a เพื่อตรวจสอบเวอร์ชั่น kernel ที่รันอยู่</p>
<pre>[root@cent56 ~]# <strong>uname -a
</strong>Linux cent56.example.com <span style="color: #0000ff;">2.6.18-238.el5</span> #1 SMP Thu Jan 13 15:51:15 EST 2011 x86_64 x86_64 x86_64 GNU/Linux</pre>
<p>ใช้คำสั่ง rpm เพื่อดูไฟล์ rpm ของ kernel</p>
<pre>[root@cent56 ~]# <strong>rpm -qa | grep kernel
</strong>kernel-headers-2.6.18-238.el5.x86_64
kernel-2.6.18-238.el5.x86_64
kernel-devel-2.6.18-238.el5.x86_64</pre>
<p>สำหรับ CentOS สามารถดาวน์โหลดไฟล์ rpm มาจากเว็บ updates</p>
<p>เช่นเว็บ updates ของ CentOS 5.6 ในเมืองไทย สามารถดาวน์โหลดได้ที่</p>
<p>http://mirror1.ku.ac.th/centos/5.6/updates/x86_64/RPMS/</p>
<p>ตัวอย่างไฟล์ kernel ที่ต้องดาวน์โหลด เวอร์ชั่นล่าสุด ณ ตอนที่เขียนคือ 2.6.18-238.19.1</p>
<ul>
<li>kernel-2.6.18-238.19.1.el5.x86_64.rpm</li>
<li>kernel-headers-2.6.18-238.19.1.el5.x86_64.rpm</li>
<li>kernel-devel-2.6.18-238.19.1.el5.x86_64.rpm</li>
</ul>
<p>ใช้คำสั่ง rpm ด้วยออปชั่น &#8216;-U&#8217; เพื่อปรับปรุง (upgrade) ไฟล์ rpm เป็นเวอร์ชั่นใหม่</p>
<pre>[root@cent56 ~]# <strong>rpm -U kernel-2.6.18-238.19.1.el5.x86_64.rpm</strong></pre>
<pre>[root@cent56 ~]# <strong>rpm -U kernel-headers-2.6.18-238.19.1.el5.x86_64.rpm</strong></pre>
<pre>[root@cent56 ~]# <strong>rpm -U kernel-devel-2.6.18-238.19.1.el5.x86_64.rpm</strong></pre>
<p>ตรวจสอบหลังจากปรับปรุง</p>
<pre>[root@cent56 ~]# <strong>rpm -qa | grep kernel
</strong>kernel-2.6.18-238.19.1.el5.x86_64
kernel-headers-2.6.18-238.19.1.el5.x86_64
kernel-devel-2.6.18-238.19.1.el5.x86_64</pre>
<p>หากใช้วิธีนี้ในการ upgrade แบบ rpm นี้ จะมีการแก้ไขไฟล์ grub.conf โดยอัตโนมัติ</p>
<pre>[root@cent56 ~]# <strong>cat /etc/grub.conf
</strong># grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-238.19.1.el5)
        root (hd0,0)
        kernel /vmlinuz-<span style="color: #0000ff;">2.6.18-238.19.1</span>.el5 ro root=LABEL=/
        initrd /initrd-<span style="color: #0000ff;">2.6.18-238.19.1</span>.el5.img</pre>
<p>ตรวจสอบความถูกต้องของไฟล์ grub.conf  แล้วรีบู๊ตเครื่องหลังจากการ upgrade<br />
เมื่อบู๊ตเสร็จเรียบร้อย ใช้คำสั่ง uname เพื่อตรวจสอบเวอร์ชั่น kernel</p>
<pre>[root@cent56 ~]# uname -a
Linux cent56.example.com <span style="color: #0000ff;">2.6.18-238.19.1</span>.el5 #1 SMP Fri Jul 15 07:31:24 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux</pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/08/upgrade_kernel_on_centos_5-6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>เลือกออปชัน grep ให้เหมาะ ลดเวลาค้นหาได้มาก</title>
		<link>http://spalinux.com/2011/06/choose-grep-option-to-minimize-run-time</link>
		<comments>http://spalinux.com/2011/06/choose-grep-option-to-minimize-run-time#comments</comments>
		<pubDate>Fri, 24 Jun 2011 16:23:37 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[egrep]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[regexp]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1387</guid>
		<description><![CDATA[ช่วงนี้รับงาน เพื่อเขียนโปรแกรมดึงข้อมูลจาก text file ทำเป็นรายงานสรุป โดยข้อมูลที่ได้มา มีจำนวนบรรทัดมากมายมหาศาล รวมๆ แล้วเป็น หมื่นล้านบรรทัด ต้องหากระบวนการที่มีประสิทธิภาพมากที่สุดในการเขียนโปรแกรม และเมื่อได้วิธีการที่ผู้เขียนคิดว่าดีที่สุดแล้ว เลยนำมาเปรียบเทียบแชร์เล่าสู่กันฟัง ข้อมูลที่อยู่ในไฟล์ แยกเป็นบรรทัด เหมือนกับ CSV ไฟล์ งานแรกที่ต้องทำคือ เขียนโปรแกรมเพื่อดึงข้อมูลเฉพาะบรรทัดที่มีคำที่ต้องการเท่านั้น หมายเหตุ เพื่อไม่ให้เวลาเพี้ยนไปเนื่องจากการทำ cached file บน Linux  ทุกครั้งก่อนรันคำสั่ง จะรัน cat เพื่อพยายามให้ไฟล์อยู่ใน cached เหมือนกันทุกครั้ง เนื่องจากข้อมูลมีปริมาณมาก การแสดงผลออกหน้าจอจะทำให้เวลาที่ได้เพี้ยนไป ดังนั้น ในการรันทุกคำสั่ง output ที่ได้ จะถูกส่งไปยัง /dev/null ใช้คำสั่ง time เพื่อจับเวลาในการรันคำสั่ง ตัวอย่างการรันคำสั่ง cat ทุกครั้ง เพื่อพยายามโหลดไฟล์ข้อมูลเข้า cached [user1@devel tmp]$ time cat test-data.txt &#62; /dev/null [...]]]></description>
			<content:encoded><![CDATA[<p>ช่วงนี้รับงาน เพื่อเขียนโปรแกรมดึงข้อมูลจาก text file ทำเป็นรายงานสรุป โดยข้อมูลที่ได้มา มีจำนวนบรรทัดมากมายมหาศาล รวมๆ แล้วเป็น หมื่นล้านบรรทัด</p>
<p>ต้องหากระบวนการที่มีประสิทธิภาพมากที่สุดในการเขียนโปรแกรม และเมื่อได้วิธีการที่ผู้เขียนคิดว่าดีที่สุดแล้ว เลยนำมาเปรียบเทียบแชร์เล่าสู่กันฟัง</p>
<p>ข้อมูลที่อยู่ในไฟล์ แยกเป็นบรรทัด เหมือนกับ CSV ไฟล์ งานแรกที่ต้องทำคือ เขียนโปรแกรมเพื่อดึงข้อมูลเฉพาะบรรทัดที่มีคำที่ต้องการเท่านั้น</p>
<p><span id="more-1387"></span></p>
<p>หมายเหตุ</p>
<ul>
<li>เพื่อไม่ให้เวลาเพี้ยนไปเนื่องจากการทำ cached file บน Linux  ทุกครั้งก่อนรันคำสั่ง จะรัน cat เพื่อพยายามให้ไฟล์อยู่ใน cached เหมือนกันทุกครั้ง</li>
<li>เนื่องจากข้อมูลมีปริมาณมาก การแสดงผลออกหน้าจอจะทำให้เวลาที่ได้เพี้ยนไป ดังนั้น ในการรันทุกคำสั่ง output ที่ได้ จะถูกส่งไปยัง /dev/null</li>
<li>ใช้คำสั่ง time เพื่อจับเวลาในการรันคำสั่ง</li>
</ul>
<p>ตัวอย่างการรันคำสั่ง cat ทุกครั้ง เพื่อพยายามโหลดไฟล์ข้อมูลเข้า cached</p>
<pre>[user1@devel tmp]$ <strong>time cat test-data.txt &gt; /dev/null</strong></pre>
<pre>real    0m0.519s
user    0m0.247s
sys     0m0.272s</pre>
<p>ใช้คำสั่ง wc -l เพื่อนับจำนวนบรรทัดของไฟล์ ไฟล์ข้อมูลที่ใช้ทดสอบ มีจำนวนบรรทัด 5,825,368 บรรทัด</p>
<pre>[user1@devel tmp]$ <strong>wc -l cat test-data.txt
</strong>5813492</pre>
<p>ต้องการดึงข้อมูลจากบรรทัดที่มีคำว่า &#8220;jan&#8221; หรือมีคำว่า &#8220;feb&#8221;</p>
<h4>grep -E หรือ egrep (extended-regexp)</h4>
<p>เราสามารถใช้คำสั่ง grep ตามด้วยออปชั่น -E หรือคำสั่ง egrep เพื่อเลือกเฉพาะบรรทัดที่มีคำที่ต้องการแบบมีเงื่อนไข extended regular expression</p>
<pre>[user1@devel tmp]$ <strong>time grep -E "(jan|feb)" test-data.txt  &gt; /dev/null</strong></pre>
<pre><span style="color: #ff0000;">real    0m22.070s</span>
user    0m19.298s
sys     0m3.038s</pre>
<p>หรือใช้คำสั่ง egrep ก็ให้ผลเหมือนกัน</p>
<pre>[user1@devel tmp]$ <strong>time egrep "(jan|feb)" test-data.txt &gt; /dev/null</strong></pre>
<pre><span style="color: #ff0000;">real    0m21.530s</span>
user    0m19.133s
sys     0m2.831s</pre>
<p>ใช้เวลาไปประมาณ 20 กว่าวินาที ก็ได้ผลลัพธ์ที่ต้องการ</p>
<p>แต่เมื่อคิดคำนวนคร่าวๆ   5 ล้านกว่าบรรทัด ใช้เวลา 20 วินาที แล้ว 10,000 ล้านบรรทัดล่ะ นี่ยังไม่รวมกระบวนการอื่นๆ ที่ต้องทำต่อไปอีกนะ &#8211;&#8221;</p>
<h4>grep แยกทีละคำ</h4>
<p>เมื่อคิดเรื่องเวลาแล้ว เลยหาวิธีใหม่ คือทดลอง grep แยกทีละคำ</p>
<p>หาเฉพาะที่มีคำว่า &#8220;jan&#8221; เวลาที่ใช้แค่ 1 วินาทีกว่าๆ</p>
<pre>[user1@devel tmp]$ <strong>time grep "jan" test-data.txt &gt; /dev/null</strong></pre>
<pre><span style="color: #ff0000;">real    0m1.472s</span>
user    0m1.522s
sys     0m0.375s</pre>
<p>หาเฉพาะที่มีคำว่า &#8220;feb&#8221; เวลาที่ใช้ไม่ถึงวินาที</p>
<pre>[user1@devel tmp]$ <strong>time grep "feb" test-data.txt &gt; /dev/null</strong></pre>
<pre><span style="color: #ff0000;">real    0m0.464s</span>
user    0m0.381s
sys     0m0.108s</pre>
<p>รวมๆ แล้ว เร็วกว่ามาก grep แยกทีละคำก็น่าจะดี แต่คงยุ่งยากในการเขียนโปรแกรมพอสมควร ยิ่งถ้ามีคำที่ต้องการค้นหาเพิ่มมาอีก</p>
<h4>*** grep -P (perl-regexp) ***</h4>
<p>อ่าน man page ของ grep พบอีกออปชั่น  -P เป็นการค้นหาคำแบบใช้เงื่อนไขของ Perl regular expression</p>
<pre>[user1@devel tmp]$ <strong>time grep -P "(jan|feb)" test-data.txt &gt; /dev/null</strong></pre>
<pre><span style="color: #0000ff;">real    0m2.063s
</span>user    0m2.143s
sys     0m0.358s</pre>
<p>ลดลงเวลาลงเกือบ 10 เท่า เมื่อเปรียบเทียบกับ grep -E แถมไม่ต้องยุ่งยากกับการเขียนโปรแกรมมากนัก</p>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/06/choose-grep-option-to-minimize-run-time/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>กระจายงาน Interrupts ที่ได้รับ ให้ Multi-CPU, Cores</title>
		<link>http://spalinux.com/2011/05/distribute_interrupts_over_processors_cores</link>
		<comments>http://spalinux.com/2011/05/distribute_interrupts_over_processors_cores#comments</comments>
		<pubDate>Sun, 29 May 2011 17:01:39 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Kernel]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[Interrupts]]></category>
		<category><![CDATA[irqbalance]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1343</guid>
		<description><![CDATA[หากคุณประสบปัญหา ssh login เข้าเครื่อง Linux Server แล้วต้องรอหลายวินาที กว่า prompt login จะขึ้น แต่หลังจาก login เข้าไปในระบบได้ ก็สามารถรันคำสั่งต่างๆ ทำงานได้ ไม่ได้ช้ามากแต่ประการใด บทความนี้อาจช่วยคุณแก้ไขปัญหาได้ คำสั่งที่ใช้ดูรายงานการทำงานของ CPU คือ mpstat อยู่ในชุดโปรแกรม sysstat รันคำสั่ง mpstat ตามด้วยออปชั่น &#8220;-P ALL&#8221; เพื่อดูผลลัพธ์แยกตาม CPU หมายเหตุ นอกจากคำสั่ง mpstat แล้ว อาจใช้คำสั่ง top ดูโหลดของ CPU ก็ได้ [root@devel ~]# mpstat -P ALL Linux 2.6.18-194.el5 (devel.example.com)   05/22/2011 04:00:49 PM  CPU   %user   %nice    %sys %iowait    [...]]]></description>
			<content:encoded><![CDATA[<p>หากคุณประสบปัญหา ssh login เข้าเครื่อง Linux Server แล้วต้องรอหลายวินาที กว่า prompt login จะขึ้น</p>
<p>แต่หลังจาก login เข้าไปในระบบได้ ก็สามารถรันคำสั่งต่างๆ ทำงานได้ ไม่ได้ช้ามากแต่ประการใด</p>
<p>บทความนี้อาจช่วยคุณแก้ไขปัญหาได้</p>
<p><span id="more-1343"></span></p>
<p>คำสั่งที่ใช้ดูรายงานการทำงานของ CPU คือ mpstat อยู่ในชุดโปรแกรม sysstat</p>
<p>รันคำสั่ง mpstat ตามด้วยออปชั่น &#8220;-P ALL&#8221; เพื่อดูผลลัพธ์แยกตาม CPU</p>
<p>หมายเหตุ นอกจากคำสั่ง mpstat แล้ว อาจใช้คำสั่ง top ดูโหลดของ CPU ก็ได้</p>
<pre>[root@devel ~]# <strong>mpstat -P ALL
</strong>Linux 2.6.18-194.el5 (devel.example.com)   05/22/2011</pre>
<pre>04:00:49 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
04:00:49 PM  all   25.13    0.00    0.09    0.14    0.01    0.08    0.00   74.55   2267.62
04:00:49 PM    <span style="color: #ff0000;"><strong>0</strong></span>    9.39    0.00    0.16    1.04    0.09    0.92    0.00   88.40   <span style="color: #ff0000;"><strong>2267.62
</strong></span>04:00:49 PM    1   21.11    0.00    0.11    0.17    0.00    0.00    0.00   78.62      0.00
04:00:49 PM    2   27.66    0.00    0.09    0.09    0.00    0.00    0.00   72.15      0.00
04:00:49 PM    3   28.54    0.00    0.09    0.07    0.00    0.00    0.00   71.30      0.00
04:00:49 PM    4   31.10    0.00    0.10    0.07    0.00    0.00    0.00   68.73      0.00
04:00:49 PM    5   29.38    0.00    0.10    0.05    0.00    0.00    0.00   70.47      0.00
04:00:49 PM    6   16.91    0.00    0.08    0.04    0.00    0.00    0.00   82.97      0.00
04:00:49 PM    7   20.46    0.00    0.08    0.04    0.00    0.00    0.00   79.42      0.00</pre>
<p>จากคำสั่ง mpstat นี้จะเห็นว่า เฉพาะ CPU0 เท่านั้นที่มีตัวเลข &#8220;intr/s&#8221;  ไม่เท่ากับ 0</p>
<p>&#8220;intr/s&#8221; คือจำนวน interrupts (IRQ) ที่ CPU ได้รับ เฉลี่ยต่อ วินาที</p>
<p>การ ssh login เข้าเครื่อง ถือเป็นการ interrupts อย่างหนึ่ง ที่ต้องมี CPU มาทำหน้าที่รับ ก่อนส่งไปประมวลผลต่อไป</p>
<h4>การแก้ไข</h4>
<p>โปรแกรมที่สามารถช่วยกระจายการรับ interrupts ให้ CPU หลายตัวได้ คือ irqbalance</p>
<p>โดยดีฟอลต์ของการติดตั้ง Linux ส่วนใหญ่แล้ว จะรัน irqbalance ด้วย แต่ถ้าปิดไป แนะนำให้รันขึ้นมาใหม่ และรันทิ้งไว้ตลอดเวลา สำหรับเครื่องที่มี CPU หลายตัว หรือหลาย Core</p>
<p>ตรวจสอบการรัน irqbalance ด้วยคำสั่ง service หรือคำสั่ง ps</p>
<pre>[root@devel ~]# <strong>service irqbalance status
</strong>irqbalance is stopped
[root@devel ~]#</pre>
<pre>[root@devel ~]# <strong>ps -ef | grep irqbalance
</strong>[root@devel ~]#</pre>
<p>รันเซอร์วิส irqbalance</p>
<pre>[root@devel ~]# <strong>service irqbalance start
</strong>Starting irqbalance:                                       [  OK  ]</pre>
<p>ตรวจสอบดูโปรเซสอีกครั้ง</p>
<pre>[root@devel ~]# <strong>ps -ef | grep irqbalance
</strong>root     19003     1  0 16:03 ?        00:00:00 irqbalance</pre>
<p>หลังจากรันเซอร์วิส irqbalance ไปซักพักแล้ว ลองรันคำสั่ง mpstat อยู่เรื่อยๆ จะเห็นตัวเลข &#8220;intr/s&#8221; ของ CPU อื่นๆ เริ่มขึ้นมา แสดงว่า เริ่มมีการกระจาย IRQ ให้ CPU หลายๆ ตัวแล้ว</p>
<pre>[root@devel ~]# <strong>mpstat -P ALL
</strong>Linux 2.6.18-194.el5 (devel.example.com)   05/22/2011</pre>
<pre>04:05:10 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
04:05:10 PM  all   25.13    0.00    0.09    0.14    0.01    0.08    0.00   74.55   2268.53
04:05:10 PM    0    9.39    0.00    0.16    1.04    0.09    0.92    0.00   88.40   2267.99
04:05:10 PM    1   21.11    0.00    0.11    0.17    0.00    0.00    0.00   78.62      0.00
04:05:10 PM    2   27.66    0.00    0.09    0.09    0.00    0.00    0.00   72.15      0.00
04:05:10 PM    3   28.54    0.00    0.09    0.07    0.00    0.00    0.00   71.30      <span style="color: #ff0000;">0.01
</span>04:05:10 PM    4   31.10    0.00    0.10    0.07    0.00    0.00    0.00   68.73      <span style="color: #ff0000;"><strong>0.01
</strong></span>04:05:10 PM    5   29.37    0.00    0.10    0.05    0.00    0.00    0.00   70.47      <strong><span style="color: #ff0000;">0.01
</span></strong>04:05:10 PM    6   16.91    0.00    0.08    0.04    0.00    0.00    0.00   82.97      <span style="color: #ff0000;"><strong>0.08
</strong></span>04:05:10 PM    7   20.46    0.00    0.08    0.04    0.00    0.00    0.00   79.42      <strong><span style="color: #ff0000;">0.09</span></strong></pre>
<p>ลอง ssh login อีกครั้ง น่าจะดีขึ้น</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2008/06/fedora_9_minimal_service_description">รายละเอียดของแต่ละ service ใน Fedora 9</a></li>
<li><a href="http://spalinux.com/2011/05/using_sysstat_to_monitor_system">ตรวจสอบการทำงานเครื่องด้วย sysstat</a></li>
<li><a href="http://www.irqbalance.org/" target="_blank">What is irqbalance?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/05/distribute_interrupts_over_processors_cores/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ตรวจสอบการทำงานเครื่องด้วย sysstat</title>
		<link>http://spalinux.com/2011/05/using_sysstat_to_monitor_system</link>
		<comments>http://spalinux.com/2011/05/using_sysstat_to_monitor_system#comments</comments>
		<pubDate>Sun, 22 May 2011 11:28:58 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[sysstat]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1338</guid>
		<description><![CDATA[ก่อนที่จะปรับแต่งค่าคอนฟิกเพื่อเพิ่มพลังให้เครื่องได้นั้น  เราต้องเก็บรายละเอียดสถิติการทำงานของเครื่องก่อน เพื่อวิเคราะห์ดูว่า ส่วนไหนมีการใช้งานมากน้อยอย่างไร และนำผลที่ได้มาเพื่อเปรียบเทียบ วัดผลการทดสอบ ก่อนและหลังการแก้ไขคอนฟิก จึงจำเป็นต้องติดตั้งโปรแกรมเพิ่มเติม โปรแกรมที่นิยมใช้กัน คือ iostat, sar, mpstat ซึ่งถูกรวมไว้เป็นชุดโปรแกรมชื่อ sysstat ไฟล์ rpm สำหรับติดตั้ง ถ้าเป็น RedHat, CentOS จะมีอยู่ในแผ่นดีวีดีติดตั้งอยู่แล้ว แต่ถ้าเป็น Fedora ต้องดาวน์โหลดเพิ่มเติมจาก Fedora Everything ตัวอย่างการติดตั้ง sysstat บน CentOS 5.5 [root@devel ~]# mount /dev/cdrom   /media [root@devel ~]# cd /media/CentOS/ [root@devel CentOS]# ls -l sysstat-7.0.2-3.el5.x86_64.rpm -rw-rw-r-- 4 root root 177451 Mar 17  2009 sysstat-7.0.2-3.el5.x86_64.rpm [...]]]></description>
			<content:encoded><![CDATA[<p>ก่อนที่จะปรับแต่งค่าคอนฟิกเพื่อเพิ่มพลังให้เครื่องได้นั้น  เราต้องเก็บรายละเอียดสถิติการทำงานของเครื่องก่อน เพื่อวิเคราะห์ดูว่า ส่วนไหนมีการใช้งานมากน้อยอย่างไร และนำผลที่ได้มาเพื่อเปรียบเทียบ วัดผลการทดสอบ ก่อนและหลังการแก้ไขคอนฟิก</p>
<p>จึงจำเป็นต้องติดตั้งโปรแกรมเพิ่มเติม โปรแกรมที่นิยมใช้กัน คือ iostat, sar, mpstat ซึ่งถูกรวมไว้เป็นชุดโปรแกรมชื่อ sysstat</p>
<p><span id="more-1338"></span></p>
<p>ไฟล์ rpm สำหรับติดตั้ง ถ้าเป็น RedHat, CentOS จะมีอยู่ในแผ่นดีวีดีติดตั้งอยู่แล้ว แต่ถ้าเป็น Fedora ต้องดาวน์โหลดเพิ่มเติมจาก Fedora Everything</p>
<p>ตัวอย่างการติดตั้ง sysstat บน CentOS 5.5</p>
<pre>[root@devel ~]# <strong>mount /dev/cdrom   /media</strong></pre>
<pre>[root@devel ~]# <strong>cd /media/CentOS/
</strong>[root@devel CentOS]# <strong>ls -l sysstat-7.0.2-3.el5.x86_64.rpm</strong>
-rw-rw-r-- 4 root root 177451 Mar 17  2009 sysstat-7.0.2-3.el5.x86_64.rpm</pre>
<pre>[root@devel CentOS]# <strong>rpm -ivh sysstat-7.0.2-3.el5.x86_64.rpm
</strong>Preparing...                ########################################### [100%]
   1:sysstat                ########################################### [100%]</pre>
<pre>[root@devel CentOS]# <strong>cd ~
</strong>[root@devel ~]# <strong>umount /media
</strong>[root@devel ~]#</pre>
<h4>iostat วัดการใช้งาน Disk</h4>
<p>ตัวอย่างผลลัพธ์จากคำสั่ง iostat แสดงปริมาณ การ read/write โดยแยกตาม Disk/Partition</p>
<pre>[root@devel ~]# <strong>iostat
</strong>Linux 2.6.18-194.el5 (devel.example.com)   05/22/2011</pre>
<pre>avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          25.10    0.00    0.18    0.14    0.00   74.58</pre>
<pre>Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               3.24        18.36       213.87   69399070  808554725
sda1              0.00         0.00         0.00       1602          4
sda2              2.82        11.13       139.51   42073602  527428384
sda3              0.20         7.04        29.05   26602763  109816920
sda4              0.22         0.19        45.31     720679  171309417</pre>
<h4>sar วัดการใช้งาน CPU</h4>
<p>ตัวอย่างผลลัพธ์จากคำสั่ง sar เพื่อตรวจสอบ % การใช้งาน CPU โดยวัดค่าทุกๆ 10 วินาที จำนวน 3 ครั้ง</p>
<pre>[root@devel ~]# <strong>sar 10 3
</strong>Linux 2.6.18-194.el5 (devel.example.com)   05/22/2011</pre>
<pre>06:16:45 PM       CPU     %user     %nice   %system   %iowait    %steal     %idle
06:16:55 PM       all      0.00      0.00      0.01      0.03      0.00     99.97
06:17:05 PM       all      0.17      0.00      0.06      0.08      0.00     99.70
06:17:15 PM       all      0.01      0.00      0.00      0.06      0.00     99.93
Average:          all      0.06      0.00      0.02      0.05      0.00     99.87</pre>
<pre> </pre>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/05/using_sysstat_to_monitor_system/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>การปรับแต่งประสิทธิภาพของ Linux</title>
		<link>http://spalinux.com/2011/05/linux_performance_tuning</link>
		<comments>http://spalinux.com/2011/05/linux_performance_tuning#comments</comments>
		<pubDate>Sat, 21 May 2011 17:15:29 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1332</guid>
		<description><![CDATA[นานแล้ว ไม่ได้ดูเรื่อง performance อย่างจริงจัง เพราะเครื่องส่วนใหญ่ที่ติดตั้ง แค่ปรับแต่งค่าคอนฟิกนิดหน่อยก็สามารถใช้งานได้อย่างดีแล้ว เนื่องด้วยทั้ง CPU, Memory, Disk รุ่นใหม่ๆ ค่อนข้างเร็ว แต่ช่วงนี้ เครื่องเซิร์ฟเวอร์ที่ติดตั้งไปหลายๆ เครื่อง โดนกระหน่ำใช้งานอย่างหนักทั้ง read และ write จึงต้องหาวิธีปรับแต่ง รีดพลังความสามารถจากทุกส่วนประกอบของเครื่องเลย เคยเขียนบนเว็บไซต์ไปบ้างแล้ว ถึงการปรับแต่งพื้นฐาน แต่คราวนี้ขอลงรายละเอียดมากหน่อย เพื่ออาจเป็นประโยชน์กับผู้ดูแลระบบที่กำลังประสบปัญหา โดนผู้ใช้ (users) บ่นเป็นประจำ คำแนะนำ/คำเตือน ในการปรับแต่งค่าคอนฟิก  - ทดสอบบนเครื่องทดลอง (test/development) ให้เข้าใจและแน่ใจถึงผลกระทบจากการแก้ไขคอนฟิก ก่อนแก้ไขบนเครื่อง production  - ใช้หลักสถิติในการทดสอบ คือทดสอบหลายๆ ครั้ง แล้วนำผลที่ได้มาเปรียบเทียบกัน  - สำรองข้อมูล หรือคอนฟิกก่อนการแก้ไข เผื่อแก้ไขแล้วมีปัญหา จะได้แก้กลับได้  - แก้ไขคอนฟิกในช่วงเวลาไม่มีการใช้งาน หรือใช้งานน้อยที่สุด เพราะการแก้ไขบางอย่าง อาจจำเป็นต้องรีสตาร์ต service เอกสารหนึ่งที่ผู้เขียนแนะนำ คือ &#8220;IBM Redbooks [...]]]></description>
			<content:encoded><![CDATA[<p>นานแล้ว ไม่ได้ดูเรื่อง performance อย่างจริงจัง เพราะเครื่องส่วนใหญ่ที่ติดตั้ง แค่ปรับแต่งค่าคอนฟิกนิดหน่อยก็สามารถใช้งานได้อย่างดีแล้ว เนื่องด้วยทั้ง CPU, Memory, Disk รุ่นใหม่ๆ ค่อนข้างเร็ว</p>
<p>แต่ช่วงนี้ เครื่องเซิร์ฟเวอร์ที่ติดตั้งไปหลายๆ เครื่อง โดนกระหน่ำใช้งานอย่างหนักทั้ง read และ write จึงต้องหาวิธีปรับแต่ง รีดพลังความสามารถจากทุกส่วนประกอบของเครื่องเลย</p>
<p>เคยเขียนบนเว็บไซต์ไปบ้างแล้ว ถึงการปรับแต่งพื้นฐาน แต่คราวนี้ขอลงรายละเอียดมากหน่อย เพื่ออาจเป็นประโยชน์กับผู้ดูแลระบบที่กำลังประสบปัญหา โดนผู้ใช้ (users) บ่นเป็นประจำ <img src='http://spalinux.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><span id="more-1332"></span></p>
<p><span style="color: #ff0000;">คำแนะนำ/คำเตือน ในการปรับแต่งค่าคอนฟิก</span></p>
<p> - ทดสอบบนเครื่องทดลอง (test/development) ให้เข้าใจและแน่ใจถึงผลกระทบจากการแก้ไขคอนฟิก ก่อนแก้ไขบนเครื่อง production<br />
 - ใช้หลักสถิติในการทดสอบ คือทดสอบหลายๆ ครั้ง แล้วนำผลที่ได้มาเปรียบเทียบกัน<br />
 - สำรองข้อมูล หรือคอนฟิกก่อนการแก้ไข เผื่อแก้ไขแล้วมีปัญหา จะได้แก้กลับได้<br />
 - แก้ไขคอนฟิกในช่วงเวลาไม่มีการใช้งาน หรือใช้งานน้อยที่สุด เพราะการแก้ไขบางอย่าง อาจจำเป็นต้องรีสตาร์ต service</p>
<p>เอกสารหนึ่งที่ผู้เขียนแนะนำ คือ &#8220;IBM Redbooks : Linux Performance and Tuning Guidelines&#8221; ซึ่งสามารถดาวน์โหลดได้ฟรีจากเว็บไซต์ IBM</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://www.redbooks.ibm.com/abstracts/redp4285.html" target="_blank">Linux Performance and Tuning Guidelines &#8211; An IBM Redpaper publication</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/05/linux_performance_tuning/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>การใช้งานเบื้องต้น Sun Grid Engine</title>
		<link>http://spalinux.com/2011/01/how_to_use_sun_grid_engine</link>
		<comments>http://spalinux.com/2011/01/how_to_use_sun_grid_engine#comments</comments>
		<pubDate>Sat, 29 Jan 2011 09:22:25 +0000</pubDate>
		<dc:creator>editor</dc:creator>
				<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Oracle Grid Engine]]></category>
		<category><![CDATA[Submit Job]]></category>
		<category><![CDATA[Sun Grid Engine]]></category>

		<guid isPermaLink="false">http://spalinux.com/?p=1245</guid>
		<description><![CDATA[หลังจากติดตั้ง Sun Grid ทั้งเครื่อง qmaster และ execd host เรียบร้อยแล้ว บทความนี้จะแนะนำวิธีการใช้งานเบื้องต้นของ Sun Grid Engine เพื่อดูสถานะของเครื่อง งานที่รัน และวิธีการส่งงานอย่างง่ายๆ ตั้งค่าตัวแปร setting.sh ต้องรัน source ไฟล์ /gridware/sge/MyCell/common/settings.sh เพื่อตั้งค่าตัวแปรของ sge ก่อนที่จะรันคำสั่ง วิธีการรัน ใช้คำสั่ง source หรือ . เว้นวรรคแล้วตามด้วยชื่อไฟล์ /gridware/sge/MyCell/common/settings.sh [root@cent55-sge ~]# . /gridware/sge/MyCell/common/settings.sh ลองรันคำสั่ง set เพื่อดูค่าตัวแปรที่ถูกตั้งค่า เกี่ยวกับ sge [root@cent55-sge ~]# set &#124; grep -i sge MANPATH=/gridware/sge/man:/usr/share/man/en:/usr/share/man:/usr/local/share/man PATH=/gridware/sge/bin/lx24-amd64:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin SGE_CELL=MyCell SGE_CLUSTER_NAME=MyCluster SGE_ROOT=/gridware/sge คำสั่ง qconf [...]]]></description>
			<content:encoded><![CDATA[<p>หลังจากติดตั้ง Sun Grid ทั้งเครื่อง qmaster และ execd host เรียบร้อยแล้ว บทความนี้จะแนะนำวิธีการใช้งานเบื้องต้นของ Sun Grid Engine เพื่อดูสถานะของเครื่อง งานที่รัน และวิธีการส่งงานอย่างง่ายๆ</p>
<p><span id="more-1245"></span></p>
<h4>ตั้งค่าตัวแปร setting.sh</h4>
<p>ต้องรัน source ไฟล์ /gridware/sge/MyCell/common/settings.sh เพื่อตั้งค่าตัวแปรของ sge ก่อนที่จะรันคำสั่ง</p>
<p>วิธีการรัน ใช้คำสั่ง source หรือ . เว้นวรรคแล้วตามด้วยชื่อไฟล์ /gridware/sge/MyCell/common/settings.sh</p>
<pre>[root@cent55-sge ~]# <strong>. /gridware/sge/MyCell/common/settings.sh</strong></pre>
<p>ลองรันคำสั่ง set เพื่อดูค่าตัวแปรที่ถูกตั้งค่า เกี่ยวกับ sge</p>
<pre>[root@cent55-sge ~]# <strong>set | grep -i sge
</strong>MANPATH=<span style="color: #0000ff;">/gridware/sge/man</span>:/usr/share/man/en:/usr/share/man:/usr/local/share/man
PATH=<span style="color: #0000ff;">/gridware/sge/bin/lx24-amd64</span>:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
<span style="color: #0000ff;">SGE_CELL=MyCell</span>
<span style="color: #0000ff;">SGE_CLUSTER_NAME=MyCluster</span>
<span style="color: #0000ff;">SGE_ROOT=/gridware/sge</span></pre>
<h4>คำสั่ง qconf ดูคอนฟิก</h4>
<p>ใช้คำสั่ง qconf ตามด้วยออปชั่น เพื่อดูค่าคอนฟิกต่างๆ ของ sge</p>
<p>รันคำสั่ง qconf -ss เพื่อดูชื่อเครื่องที่มีสิทธิส่งงานหรือใช้คำสั่ง qsub ได้ (show a list of all submit hosts)</p>
<pre>[root@cent55-sge ~]# <strong>qconf -ss
</strong>cent55-node1.spalinux.com
cent55-node2.spalinux.com
cent55-sge.spalinux.com</pre>
<p>รันคำสั่ง qconf -sel เพื่อดูชื่อเครื่องที่ทำหน้าที่รันงาน (show a list of all exec servers)</p>
<pre>[root@cent55-sge ~]# <strong>qconf -sel
</strong>cent55-node1.spalinux.com
cent55-node2.spalinux.com</pre>
<h4>คำสั่ง qstat ดูสถานะ</h4>
<p>ใช้คำสั่ง qstat ตามด้วยออปชั่น เพื่อดูสถานะของงาน (job) และ queue ในการรันงาน</p>
<p>รันคำสั่ง qstat -f เพื่อดูสถานะของเครื่อง execd host และงานที่รัน</p>
<pre>[root@cent55-sge ~]# <strong>qstat -f
</strong>queuename                      qtype resv/used/tot. load_avg arch          states
---------------------------------------------------------------------------------
all.q@cent55-node1.spalinux.co BIP   0/0/1          0.00     lx24-amd64
---------------------------------------------------------------------------------
all.q@cent55-node2.spalinux.co BIP   0/0/1          0.34     lx24-amd64</pre>
<h4>ทดสอบการส่ง job</h4>
<p>เริ่มต้นจะทดลองส่ง job แบบง่ายๆ รันไฟล์ simple.sh ที่มาจากการติดตั้งโปรแกรม Sun Grid Engine</p>
<p>ไฟล์ simple เป็น shell script ที่รันคำสั่ง date รอ (sleep) 20 วินาที แล้วรันคำสั่ง date อีกครั้ง</p>
<pre>[root@cent55-sge ~]# <strong>cat /gridware/sge/examples/jobs/simple.sh
</strong>#!/bin/sh
#
#
# (c) 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.</pre>
<pre># This is a simple example of a SGE batch script</pre>
<pre># request Bourne shell as shell for job
#$ -S /bin/sh</pre>
<pre>#
# print date and time
date
# Sleep for 20 seconds
sleep 20
# print date and time again
date</pre>
<p>ใช้คำสั่ง qsub ตามด้วยชื่อไฟล์ที่ต้องการรัน</p>
<pre>[root@cent55-sge ~]# <strong>qsub /gridware/sge/examples/jobs/simple.sh
</strong>Your job <span style="color: #0000ff;">206</span> ("simple.sh") has been submitted</pre>
<p>ใช้คำสั่ง qstat -f เพื่อดูสถานะของ job</p>
<pre>[root@cent55-sge ~]# <strong>qstat -f
</strong>queuename                      qtype resv/used/tot. load_avg arch          states
---------------------------------------------------------------------------------
all.q@cent55-node1.spalinux.co BIP   0/0/1          0.00     lx24-amd64
---------------------------------------------------------------------------------
all.q@cent55-node2.spalinux.co BIP   0/0/1          0.09     lx24-amd64</pre>
<pre>############################################################################
 - PENDING JOBS - PENDING JOBS - PENDING JOBS - PENDING JOBS - PENDING JOBS
############################################################################
<span style="color: #0000ff;">    206 0.00000 simple.sh  root         qw    01/29/2011 15:43:06     1</span></pre>
<p>ทดลองพิมพ์คำสั่ง qstat -f ไปเรื่อยๆ ช่วงแรก job 206 จะอยู่ในสถานะ PENDING JOBS คือรอการรัน</p>
<p>ผ่านไปไม่นาน สถานะของ job 206 จะเริ่มรันบนเครื่อง execd host ในตัวอย่างนี้รันบนเครื่อง node1</p>
<pre>[root@cent55-sge ~]# <strong>qstat -f
</strong>queuename                      qtype resv/used/tot. load_avg arch          states
---------------------------------------------------------------------------------
all.q@cent55-node1.spalinux.co BIP   0/1/1          0.00     lx24-amd64
<span style="color: #0000ff;">    206 0.55500 simple.sh  root         r     01/29/2011 15:43:15     1
</span>---------------------------------------------------------------------------------
all.q@cent55-node2.spalinux.co BIP   0/0/1          0.09     lx24-amd64</pre>
<p>หากล็อกอินเครื่อง node1 แล้วใช้คำสั่ง ps  จะเห็นโปรเซสของ job 206</p>
<pre style="text-align: justify;">[root@cent55-node1 ~]# <strong>ps -ef
</strong>...
sgeadmin  2192  2129  0 15:43 ?        00:00:00 sge_shepherd-206 -bg
root      2193  2192  0 15:43 ?        00:00:00 <span style="color: #0000ff;">-sh /gridware/sge/MyCell/spool/cent55-node1/job_scripts/206
</span>root      2218  2193  0 15:43 ?        00:00:00 sleep 20
root      2221  1754  0 15:43 pts/0    00:00:00 ps -ef</pre>
<p>ดูไฟล์โปรเซสที่รันบนเครื่อง node1 ซึ่งก็คือไฟล์ simple.sh นั่นเอง</p>
<pre>[root@cent55-node1 ~]# cat /gridware/sge/MyCell/spool/cent55-node1/job_scripts/206
#!/bin/sh
#
#
# (c) 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.</pre>
<pre># This is a simple example of a SGE batch script</pre>
<pre># request Bourne shell as shell for job
#$ -S /bin/sh</pre>
<pre>#
# print date and time
date
# Sleep for 20 seconds
sleep 20
# print date and time again
date</pre>
<p>หลังจากรันงานเสร็จสิ้น สถานะ job 206 ก็จะหายไปจากคำสั่ง qstat</p>
<pre>[root@cent55-sge ~]# <strong>qstat -f
</strong>queuename                      qtype resv/used/tot. load_avg arch          states
---------------------------------------------------------------------------------
all.q@cent55-node1.spalinux.co BIP   0/0/1          0.00     lx24-amd64
---------------------------------------------------------------------------------
all.q@cent55-node2.spalinux.co BIP   0/0/1          0.09     lx24-amd64</pre>
<p>ผลลัพธ์ที่ได้จากการรันไฟล์ simple.sh จะถูกเก็บไว้บนเครื่อง execd host ที่ทำหน้าที่รัน เช่นในที่นี้คือบน node1</p>
<p>ไฟล์ simple.sh.o206 เก็บผลลัพธ์ standard output จากการรัน job 206</p>
<pre>[root@cent55-node1 ~]# <strong>cat simple.sh.o206
</strong>Sat Jan 29 15:43:14 ICT 2011
Sat Jan 29 15:43:34 ICT 2011</pre>
<p>ไฟล์ simple.sh.e206 เก็บผลลัพธ์ standard error จากการรัน job</p>
<pre>[root@cent55-node1 ~]# <strong>cat simple.sh.e206</strong></pre>
<p>ในที่นี้ไม่มี error จากการรัน ไฟล์จึงว่างเปล่า</p>
<h4>ข้อมูลอ้างอิง</h4>
<ul>
<li><a href="http://spalinux.com/2011/01/install_sun_grid_engine_on_centos_5-5">ติดตั้ง Sun Grid Engine บน CentOS 5.5</a></li>
<li><a href="http://spalinux.com/2011/01/configure_sun_grid_engine_qmaster_host">คอนฟิก Sun Grid Engine qmaster host</a></li>
<li><a href="http://spalinux.com/2011/01/configure_sun_grid_engine_execd_host">คอนฟิก Sun Grid Engine execution (execd) host</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spalinux.com/2011/01/how_to_use_sun_grid_engine/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

