Server-Side/Linux2010. 12. 21. 16:44
서버간 시간을 동기화 하고 싶은경우 NTP를 쓴다.

서버 환경 : CentOS 5.X 64bit

사용법
# service ntp start
# ntpdate -b time.bora.net ntp.postech.ac.kr ntp.xbsd.pe.kr ntp1.epidc.co.kr
5분 정도 위에 적용된다고 한다.

확인하기
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 118.219.234.251 115.139.9.150    2 u   28   64  377    2.883   -5.119   0.702
+222.239.76.226  132.239.1.6      2 u   33   64  377    1.986   -3.639   1.175
*115.139.9.150   .GPS.            1 u   25   64  377    5.783   -6.177   1.033
 LOCAL(0)        .LOCL.          10 l   23   64  377    0.000    0.000   0.001

sync 상태 - 라인 제일 앞에 기호
* 는 현재 sync 를 받고 있음을 의미하며 
+ ntp 접속은 가능하지만 sync 를 하고 있지는 않음을 의미
- ntp 접속은 가능하지만 sync 가능 리스트에서 제외 된 경우
blank 또는 INIT 는 접속이 불가능함을 의미합니다.
이외에 .(dot) 또는 # 등의 기호가 나올 경우엔 기다리시거나 의미를 두지 않아도 됨.


참고 사이트
Posted by 준피
Server-Side/Linux2010. 12. 21. 16:33
# ntpdate -b time.bora.net ntp.postech.ac.kr ntp.xbsd.pe.kr ntp1.epidc.co.kr
21 Dec 15:49:29 ntpdate[1234] no server suitable for synchronization found

NTP를 이용해서 시간을 동기화시키는데 위와 같은 에러가 난다면 방화벽을 의심해보자.
NTP는 123 udp 포트를 사용하므로 열어주자.

서버환경 : CentOS 5.x 64bit




Posted by 준피
Server-Side/Linux2010. 12. 20. 20:19
Add Dag RPM Repository
# vi /etc/yum.repos.d/Dag.repo
-----------------------------------
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1
protetc=0
-----------------------------------

Install & configure monit
# yum install monit
# vi /etc/monit.conf
-----------------------------------
set daemon 120
set logfile syslog facility log_daemon
set idfile /var/monit/id
set statefile /var/monit/state

set mailserver localhost
set alert your@email.com

set httpd port 80 and
     use address localhost
     allow localhost

check process apache with pidfile /usr/local/apache/logs/httpd.pid
    start program = "/etc/init.d/httpd start" with timeout 60 seconds
    stop program = "/etc/init.d/httpd stop"
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart
    if totalmem > 200.0 MB for 5 cycles then restart
    if children > 250 then restart
    if loadavg(5min)greater than 10 for 8 cycles then stop
-----------------------------------

start monit
# service monit start




Posted by 준피
Server-Side/Linux2010. 12. 20. 17:31
인스톨
# pecl install xdebug
downloading xdebug-2.0.3.tgz ...
Starting to download xdebug-2.0.3.tgz (286,325 bytes)
...........................................................done: 286,325 bytes
66 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
/usr/bin/phpize: /tmp/pear/download/xdebug-2.0.3/build/shtool: /bin/sh: bad interpreter: Permission denied
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
ERROR: `phpize' failed
에러 발견!

root가 shell interpreter를 수행할 수 있는지 확인하기
# bin/sh
sh-3.2# exit
exit
#
OK!

permission 확인하기
#ls -ld /tmp/
drwxrwxrwx 17 root root 4096 Jun 18 07:41 /tmp/
OK!

mount 확인하기
# grep tmp /etc/fstab
LABEL=/tmp /tmp ext3 defaults,noexec,nodev,nosuid 1 2
tmpfs /dev/shm tmpfs defaults 0 0
이거다!
/tmp 는 'noexec' flag로 마운트가 되었다. 그래서 pecl로 xdebug를 설치할 때 실패했다.
그렇다면 pecl과 관련된 경로를 변경하자!

PEAR 경로 변경하기
# pear config-show | grep tmp
PEAR Installer download download_dir /tmp/pear/download
PEAR Installer temp directory temp_dir /tmp/

# pear config-set download_dir /root/tmp/pear/download
# pear config-set temp_dir /root/rmp

# pear config-show | grep tmp
PEAR Installer download        download_dir    /root/tmp/pear/download
PEAR Installer temp directory  temp_dir        /root/tmp/
OK!

Reinstall
# pecl install xdebug
여전히 에러가 난다!

# strace pecl install xdebug 2>&1
# cd /tmp && rm -fr pear pear-build-root
# ln -s /root/tmp/pear-build-root .     <= 마지막에 "." 이 있다!
# mkdir /root/tmp/pear-build-root
# pecl install xdebug
.
.
.
Build process completed successfully
Installing '/usr/lib64/php/modules/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.1.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=xdebug.so" to php.ini
OK!

설치 확인해보기
# echo 'zend_extension="/usr/lib64/php/modules/xdebug.so"'  > /etc/php.d/xdebug.ini
# php -i | grep xdebug
/etc/php.d/xdebug.ini,
xdebug
.
.
.

OK!

module 추가하기
# vi /usr/local/apache/conf/php.ini
------------------>append<-----------------
extension=xdebug.so
---------------------------------------------
# service httpd restart
<?php phpinfo();?> 를 통해서 xdebug 모듈이 추가되었음을 확인할 수 있다.

xdebug 사용해보기
# vi /usr/local/apache/htdocs/xdebug_test.php
<?php
    
function fix_string($a)
    {
        echo 
"Called @ ".
            
xdebug_call_file().
            
":".
            
xdebug_call_line().
            
" from ".
            
xdebug_call_function();
    }

    
$ret fix_string(array('Derick'));
?>

output 확인하기
go to http://your.ip.address/xdebug_test.php
return >
Called @ /usr/local/apache/htdocs/xdebug_test.php:12 from {main}


참고 사이트
xdebug 설치(문제해결 포함)

Posted by 준피
Server-Side/Linux2010. 12. 19. 09:26
thold : 임의로 정해준 한계치가 넘으면 알람 메일을 보내주는 플러그인 (v0.41)
monitor : 시스템 다운시 알람 사운드를 울려주는 플러그인 (v1.2)

Download & move to plugins
download thold-latest.tgz, monitor-v1.2-1.tgz in /usr/local/src
# cd /usr/local/src
# tar xzfv thold-latest.tgz
# tar xzfv monitor-v1.2-1.tgz

# mv ./thold-0.41 /usr/local/cacti/plugins/thold-0.41
# mv ./monitor /usr/local/cacti/plugins/monitor
# cd /usr/local/cacti/plugins
# ln -s ./thold-0.41/ ./thold

Configure cacti
# vi /usr/local/cacti/include/config.php
---------------->append<-----------------
$plugins[] = 'thold';
$plugins[] = 'monitor';
-------------------------------------------

이상하게 설치했음에도 불구하고 
'User Management' -> 'admin' -> 'Realm Permissions'  로 가도 아무런 변화가 없다.
그래서 clog라는 다른 plugin을 설치했더니 'Plugin Management' 에 clog라는 항목이 뜬다.
그리고 install icon이 있길래 클릭을 해서 설치를 했다.
아! 이거다 싶었다.

분명히 plugins/ 디렉토리에 monitor와 thold가 있음에도 불구하고 web에서는 list에 뜨지 않았다.
http://your.ip.address/cacti/plugins.php?mode=install&id=monitor
http://your.ip.address/cacti/plugins.php?mode=install&id=thold
라고 url로 접근했더니 설치가 되는것이다.

아, 이것때문에 이른 아침부터 나와서 작업을 한건데......어쨋듯 잘 풀려서 다행...

plugins download
Posted by 준피