Saturday 27 June 2009

ติดตั้ง MySQL บน Fedora 10

ด้วยข้อดีหลายๆ อย่างที่มีเพิ่มใน MySQL เวอร์ชั่น 5.1 ไม่ว่าจะเป็น partitioning, replication, storage engine, และอื่นๆ ทางเราแนะนำให้ upgrade เป็นเวอร์ชั่นใหม่

บทความนี้จะแนะนำวิธีการ upgrade MySQL บน Fedora 10 ซึ่งเวอร์ชั่นที่มากับแผ่นดีวีดีติดตั้งจะเป็นเวอร์ชั่น 5.0.67 โดยจะปรับปรุงเฉพาะ MySQL แต่จะไม่มีการปรับปรุง ส่วนอื่นๆ ที่มาต่อเชื่อม เช่น PHP ยังคงใช้ไฟล์ rpm ชื่อ php-mysql ที่อยู่ในแผ่นติดตั้ง Fedora 10 สร้างมาสำหรับ MySQL 5.0

ตรวจสอบ MySQL ที่ติดตั้งและสำรองข้อมูล

ใช้คำสั่ง rpm เพื่อตรวจสอบว่ามี MySQL ติดตั้งอยู่หรือไม่

[root@mysql5 ~]# rpm -qa | grep -i mysql mysql-5.0.67-2.fc10.x86_64 mysql-server-5.0.67-2.fc10.x86_64 php-mysql-5.2.6-5.x86_64 mysql-libs-5.0.67-2.fc10.x86_64 perl-DBD-MySQL-4.005-8.fc9.x86_64

ปิดเว็บเซิร์ฟเวอร์หรือโปรแกรมอื่นๆ ที่มีการเชื่อมต่อเข้ากับ database ตัวนี้

[root@mysql5 ~]# service httpd stop Stopping httpd:                                            [  OK  ]

ใช้คำสั่ง mysqldump เพื่อสำรองข้อมูลของ database ทั้งหมด บันทึกเป็นไฟล์เก็บไว้

[root@mysql5 ~]# mysqldump -u root -p --all-databases > mysql-5.0-dump.sql

ปิดเซอร์วิส MySQL Database Server

[root@mysql5 ~]# service mysqld stop Stopping MySQL:                                            [  OK  ]

ถอดโปรแกรม MySQL และโปรแกรมที่เกี่ยวข้องที่ติดตั้งอยู่

ใช้คำสั่ง rpm -ev เพื่อถอดโปรแกรม MySQL และโปรแกรมที่เกี่ยวข้องออก

[root@mysql5 ~]# rpm -ev mysql-server warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave [root@mysql5 ~]# rpm -ev mysql [root@mysql5 ~]# rpm -ev perl-DBD-MySQL [root@mysql5 ~]# rpm -ev php-mysql [root@mysql5 ~]# rpm -ev mysql-libs warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

ติดตั้ง MySQL 5.1

ดาวน์โหลด MySQL 5.1 จากเว็บไซต์ สามารถดูเว็บไซต์ดาวน์โหลดได้ในข้อมูลอ้างอิง สำหรับการติดตั้งบน Fedora 10 แนะนำให้เลือกเป็นไฟล์ rpm ที่สร้างขึ้นมาสำหรับ Red Hat Enterprise Linux 5 RPM โดยไฟล์ที่ต้องดาวน์โหลดมาประกอบด้วย

  • Server
  • Client
  • Shared compatibility

หมายเหตุ เวอร์ชั่นล่าสุด ณ ตอนที่เขียนบทความนี้เป็นเวอร์ชั่น 5.1.31

ใช้คำสั่ง rpm -ivh เพื่อติดตั้งไฟล์ rpm ที่ดาวน์โหลดมา ตามลำดับดังนี้

[root@mysql5 rhel5]# rpm -ivh MySQL-client-community-5.1.31-0.rhel5.x86_64.rpm Preparing...                ########################################### [100%]    1:MySQL-client-community ########################################### [100%]
[root@mysql5 rhel5]# rpm -ivh MySQL-shared-compat-5.1.31-0.rhel5.x86_64.rpm Preparing...                ########################################### [100%]    1:MySQL-shared-compat    ########################################### [100%] [root@mysql5 rhel5]# rpm -ivh MySQL-server-community-5.1.31-0.rhel5.x86_64.rpm Preparing...                ########################################### [100%]    1:MySQL-server-community ########################################### [100%]
ERROR: 1136  Column count doesn't match value count at row 1 090214 11:59:07 [ERROR] Aborting
090214 11:59:07 [Warning] Forcing shutdown of 2 plugins 090214 11:59:07 [Note] /usr/sbin/mysqld: Shutdown complete
Installation of system tables failed!  Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
    shell> /usr/sbin/mysqld --skip-grant &
and use the command line tool /usr/bin/mysql to connect to the mysql database and look at the grant tables:
    shell> /usr/bin/mysql -u root mysql     mysql> show tables
Try 'mysqld --help' if you have problems with paths.  Using --log gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at http://www.mysql.com/.  Please consult the MySQL manual section 'Problems running mysql_install_db', and the manual section that describes problems on your OS.  Another information source are the MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before mailing us!  And remember, if you do mail us, you MUST use the /usr/bin/mysqlbug script!
Starting MySQL.[  OK  ] Giving mysqld 2 seconds to start

หลังจากติดตั้ง เซอร์วิส MySQL จะรันขึ้นมาโดยอัตโนมัติ

ตรวจสอบไฟล์ rpm ของ MySQL 5.1 ที่ปรับปรุง

[root@mysql5 rhel5]# rpm -qa | grep -i mysql MySQL-shared-compat-5.1.31-0.rhel5.x86_64 MySQL-client-community-5.1.31-0.rhel5.x86_64 MySQL-server-community-5.1.31-0.rhel5.x86_64

ใช้คำสั่ง mysql เพื่อตรวจสอบเวอร์ชั่น และรายละเอียดอื่นๆ ของ database server ที่ปรับปรุงไป

[root@mysql5 rhel5]# mysql -u root -p Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.31-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select version(); +------------------+ | version()        | +------------------+ | 5.1.31-community | +------------------+ 1 row in set (0.00 sec)
mysql> show engines; +------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints | +------------+---------+----------------------------------------------------------------+--------------+------+------------+ | InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        | | MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         | | BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         | | CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         | | MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         | | FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       | | ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         | | MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         | +------------+---------+----------------------------------------------------------------+--------------+------+------------+ 8 rows in set (0.00 sec)
mysql> exit

ติดตั้ง rpm ของ โปรแกรมอื่นๆ กลับเข้าไปเหมือนเดิม เช่น php-mysql ไฟล์จะอยู่ในแผ่นดีวีดีติดตั้ง

[root@mysql5 ~]# mount /dev/cdrom /media/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@mysql5 ~]# cd /media/Packages/ [root@mysql5 Packages]# rpm -ivh php-mysql-5.2.6-5.x86_64.rpm Preparing...                ########################################### [100%]    1:php-mysql              ########################################### [100%]
[root@mysql5 Packages]# cd / [root@mysql5 /]# umount /media/ [root@mysql5 /]#

รันเว็บเซิร์ฟเวอร์กลับเหมือนเดิม

[root@mysql5 /]# service httpd start Starting httpd:                                            [  OK  ]

Saturday 13 June 2009

Firefox 3.6 vs. Google Chrome 2 vs. Safari 4 vs. Opera 10

While companies are working on their next-generation web browsers, Betanewshas managed to test the performance of the upcoming ones, such as:

Firefox 3.5, Firefox 3.6, Google Chrome, Google Chrome 2, Safari 4, Opera 10. Test also includes Internet Explorer 7 and 8.

About

As it says: “Tests combine the Acid3 standards test with three trusted performance tests for CSS rendering and JavaScript speed.”

And now… The results.

Firefox 3.6 vs. Google Chrome 2 vs. Safari 4 vs. Opera 10
More is better

Speaking of latest stable releases, Betanews claims that while Firefox 3.0.8 scored 4.7, the latest 3.0.9 release was actually slower (scored 4.37).

Friday 12 June 2009

การทดสอบประสิทธิภาพการทำงานระหว่าง Ubuntu 9.04 vs. Fedora 11

For this testing our system we used was anIntel Core 2 Duo E8400clocked at 4.00GHz,ASUS P5E64 WS Professionalmotherboard, 2GB of DDR3 memory, a Western Digital 160GB WD1600JS-00M SATA hard drive, and aNVIDIA GeForce 9800GTgraphics card. Ubuntu 9.04 ships with the Linux 2.6.29 kernel, GNOME 2.26.1, X Server 1.6.0, GCC 4.3.3, and an EXT3 file-system by default. Fedora 11 was using the Linux 2.6.29 kernel, GNOME 2.26.1, X Server 1.6.2 RC1, xf86-video-nouveau 0.0.10, GCC 4.4.0, and an EXT4 file-system by default. The x86_64 builds of both Fedora 11 and Ubuntu 9.04 were used.

We were using the latest Phoronix Test Suite code for managing our testing process, which will go on to form the2.0 Sandtorgrelease. Older versions of our testing software are available in the Fedora and Ubuntu repositories. The test profiles we used included timed PHP compilation, Apache benchmarking, LAME MP3 encoding, Ogg encoding, FFmpeg, GMPbench, Bwfirt, C-Ray, timed MAFFT alignment, Threaded I/O Tester, PostMark, Dbench, GraphicsMagick, OpenSSL, Crafty, Sunflow Rendering System, dcraw, Minion, SQLite, and PostgreSQL pgbench.

Saturday 6 June 2009

ถ้าต้องการเพิ่ม user บน fedora core I ให้มีสิทธิ์เท่ากับ root

add user และ add password ที่เราจะใช้ไปก่อนครับ เช่น
useradd bob
passwd bob

จากนั้นก็ทำให้เป็น root Afro โดยใช้ editer เปิด file ขึ้นมาครับ ผมใช้ vi ตามตัวอย่างครับ
# vi /etc/passwd

ไปที่ บรรทัด
bob:x:500:500::/home/bob:/bin/bash
ครับ

แก้ไข uid และ gid เป็น 0 เหมือน root ซึ่งก็คือ
bob:x:0:0::/home/bob:/bin/bash

จากนั้นก็ save และออกครับ

login เป็น user ที่เราสร้างครับ ในตัวอย่างคือ bob ครับ
ก็จะได้สิทธิ # มาครอบครองครับ

การกำหนดให้ root ไม่สามารถ ssh เข้ามา server ได้โดยตรง

โดยปรกติ เมื่อเรา Install linux ระบบจะยอมให้ root สามารถที่จะ ssh เข้ามาได้โดย default ซึ่งแน่นอนว่า การทำเช่นนี้จะทำให้ระบบมีความ security ลดลง เราจึงไม่ควรให้ user คนใดสามารถ ssh เข้ามาได้โดยตรง เพราะเมื่อไรที่เข้ามาได้โดยตรง เราก็จะไม่สามารถรู้ได้เลยว่า root คนนั้นคือใคร
การแก้ไขก็ทำได้โดย

1. login เข้าเป็น User ธรรมดา
[aoddy@fedora ~]$ who
aoddy pts/1 Sep 12 07:57 (192.0.0.2)

2. su เป็น root
[aoddy@fedora ~]$ su -
Password:

3. ทำการแก้ไขไฟล์ /etc/ssh/sshd_config
[root@fedora ~]# vi /etc/ssh/sshd_config

4. ค้นหาบรรทัดที่ขึ้นต้นด้วย
#PermitRootLogin yes

5. นำ comment (#) ออก แล้ว ก็เปลี่ยนจาก yes เป็น no
PermitRootLogin no

6. save ไฟล์ /etc/ssh/sshd_config ด้วยคำสั่ง :wq!

7. ทำการ restart service sshd ด้วย คำสั่ง
[root@fedora ~]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]

Monday 1 June 2009

โปรแกรม Open Source สำหรับ Window

Video Playback

VLC

VLC

Plays more video files than most players: Quicktime, AVI, DIVX, OGG, and more. Pretty good interface.
Download Page
MPlayer

MPlayer

Similar to VLC-- plays loads of video formats.
Download Page
media player classic

Media Player Classic

Compact, but powerful media player. Plays anything under the sun. No install necessary.
Download Page

DVD Ripping / Video Conversion

media coder

Media Coder

Great tool for ripping CDs, DVDs, etc and converting between tons of video formats.
Download Page

Yum (Yellow dog Updater, Modified)

Yum (Yellow dog Updater, Modified) เป็นตัวอัพเดตและ ตัวติดตั้ง/ตัวลบ แพ็กเกจสำหรับระบบ rpm แบบอัตโนมัติ โดย Yum จะคำนวน dependency และหาทางออก (figures out) ในการติดตั้งแพ็กเกจ โดย Yum จะช่วยให้ง่ายในการดูแลกลุ่มของเมชีนโดยปราศจากการอัพเดตแบบ manual ของแต่ละอันโดยใช้ rpm

คุณสมบัติของ Yum :
  • คลังข้อซอร์ฟแวร์จำนวนมาก (multiple repositories)
  • คอนฟิกได้ง่าย
  • การคำนวณ depency ที่ถูกต้อง
  • ทำงานเร็ว
  • พฤติกรรมที่ลงรอยกันกับ rpm (rpm-consistent behavior)
  • สนับสนุนกลุ่ม comps.xml ที่ประกอบด้วย multiple repository groups
  • อินเตอร์เฟสที่ง่าย
การใช้ yum ในการ modify ซอร์ฟแวร์มี 4 วิธีการคือ :
  • To install new software from package repositories

  • To install new software from an individual package file

  • To update existing software on your system

  • To remove unwanted software from your system

Resource อื่น ๆ ที่เกี่ยวกับการใช้งาน yum ประกอบด้วย :

Project web site

http://linux.duke.edu/projects/yum/

Users mailing list

https://lists.dulug.duke.edu/mailman/listinfo/yum/

Development mailing list

https://lists.dulug.duke.edu/pipermail/yum-devel/

Ubuntu เสียตำแหน่ง linux อันดับ 1 ให้กับ Mint

ลินุกซ์อันดับ 1 ของใครหลายคนในช่วงเวลาที่ผ่านมาคงต้องยกให้กับ Ubuntu แต่ว่าตอนนี้มันไม่ได้เป็นอย่างนั้นอีกต่อไปแล้ว Ubuntu ไม่ได้เป็นลินุกซ์อันดับ 1 แล้วในเวลานี้ เพราะว่าลินุกซ์อันดับ 1 ในเวลานี้คือ Mint 7

อ่างอิงจาก http://distrowatch.com/ จะเห็นได้ว่าช่วง 6 เดือนที่ผ่านมา Ubuntu ยังเป็นลินุกซ์อันดับ 1 อยู่ เพราะว่าที่ผ่านมา Ubuntu ได้รับความนิยมจากผู้ใช้ลินุกซ์เป็นอย่างมาก และก็ไม่มีทีท่าว่าจะมีใครมาชิงตำแหน่งนี้ไปได้ คู่ท้าชิงของ ubuntu ที่ผ่านมาและก็เคยก้าวข้าม Ubuntu ไปได้ก็คือ PCLinuxOS แต่ Ubuntu ก็สามารถเอาคืนมาได้ แต่ว่าวันนี้ PCLinuxOS ก็ได้รับความนิยมลดลง และตอนนี้ Mint ก็ได้กลายมาเป็นผู้ท้าชิง

สถิติ 6 เดือน สถิติ 7 วัน

ซึ่ง Mint ก็ไม่ใช่ใครอื่นที่ใหน แต่เป็น Ubuntu ที่ได้รับการต่อยอดเพิ่มความสามารถและปรับแต่งให้เป็นไปในรูปแบบและแนวทางของตัวเอง แต่ทำไม่ Mint ถึงได้ก้าวข้าม Ubuntu ไปได้ละ ก็เพราะว่า Ubuntu เดินพลาดดันไปมีปัญหากับกลุ่มผู้ใช้การ์ดจอ Intel ซึ่งที่ผ่านมาไม่เคยมีปัญหา และตอนนี้ Mint 7 ก็ออกมาได้ไม่นานจึงได้รับความสนใจจากผู้ที่ผิดหวังกับ Ubuntu แล้วหันไปใช้ Mint 7 กัน แต่เมื่อดูจากข้อมูล 7 วันที่ผ่านมาจะเห็นว่า openSUSE ได้จ่อท้ายมาติดๆแล้วด้วยและก็ยังได้รับความนิยมเพิ่มมากขึ้นในขณะที่ Ubuntu กลับมีความนิยมลดลง ไม่แน่ Ubuntu อาจจะตกต่ำกว่านี้ก็ได้