Monday, January 10, 2011

วิธีติดตั้ง Munin ในโฮสติ้งที่ใช้ DirectAdmin และ CentOS

เอาใจสาวก CentOS หน่อยค่ะ หลังจากที่ลงบทความเดียวกันนี้แต่เป็นสำหรับ Debian ในคราวนี้ใช้ CentOS 5.4 ใหม่ล่าสุดในการทดสอบ ก็ผ่านฉลุยค่ะ เรียง step ตามไปเลยค่ะ
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.i386.rpm
(เช็ค version ล่าสุดจาก https://rpmrepo.org/RPMforge/Using)
yum install munin munin-node
chkconfig –levels 235 munin-node on
/etc/init.d/munin-node start
chown -R munin:munin /var/www/munin
ln -s /var/www/munin /var/www/html/munin
service httpd restart && service crond restart
ต่อไปเราจะมาเพิ่มการ monitor apache กับ mysql กัน
ln -s /usr/share/munin/plugins/apache_* /etc/munin/plugins/
nano /etc/httpd/conf/extra/httpd-info.conf
แก้ไขไฟล์ดังนี้

SetHandler server-status
#Order deny,allow
#Deny from all
#Allow from .example.com
ExtendedStatus On
เซฟให้เรียบร้อย
*** ปล. ถ้าเปิดตามด้านบนนี้สามารถเช็ค status ของ apache ได้ด้วยว่าเว็บไหนใช้งานเยอะโดยการพิมพ์ http://ip/server-status
ln -s /usr/share/munin/plugins/mysql_* /etc/munin/plugins/
*สำหรับผู้ที่ลง squid แล้วต้องการ monitor*
ln -s /usr/share/munin/plugins/apache_* /etc/munin/plugins/
nano /etc/munin/plugin-conf.d/munin-node
แก้ไขดังนี้
[mysql*]
env.mysqlopts -u [ใส่ user อาจจะเป็น root] – p[ใส่ password] !!! ระวังอย่างเว้นวรรคหลัง -p (แต่หลัง -u ต้องเว้นวรรค)
หากไม่ทราบว่า password mysql root เป็นอะไรให้ cat /usr/local/directadmin/scripts/setup.txt ออกมาดู
*สำหรับผู้ที่ลง squid แล้วต้องการ monitor ให้เพิ่มด้านล่างเข้าไปในไฟล์นี้ด้วย*
[squid*]
user root
env.squidport 8080
/etc/init.d/httpd restart
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
/etc/init.d/munin-node restart
เสร็จแล้วค่ะ รอสัก 5 นาที เหมือนเดิม ให้กราฟขึ้น จากนั้นก็ลองเข้า http://server ip/munin ก็เป็นอันสมบูรณ์
แถมทิ้งท้ายด้วยการทำ .htaccess กันคนมาเปิดดู status server ของเรา
nano /var/www/html/munin/.htaccess
เขียนไฟล์ดังนี้
AuthType Basic
AuthName “Members Only”
AuthUserFile /var/www/munin/.htpasswd
require valid-user เซฟซะ
htpasswd -c /var/www/munin/.htpasswd admin
แล้วกรอก password (ของ user ชื่อ admin)
- จบแล้วจ้า -

0 comments:

Post a Comment

 
Design by GURU