본문 바로가기

IT인생_스크랩/Linux

NTP 시간서버 설정


[  출처 : http://blog.naver.com/junix/80087384442  ]



만약 기존에 아래와 같이 rdate와 cron을 통한 시간동기화 설정이 되어있다면 주석처리 한다.

------------------------------------------------------------------------------------

[root@localhost ~]# grep rdate /etc/rc.local

[root@localhost ~]# crontab -l | grep rdate
#05 00 * * * rdate -s time.bora.net

------------------------------------------------------------------------------------

 

NTP Client 설정

 

ntp 프로세스가 구동되고 있는지 확인한다.

[root@localhost ~]# ps -ef | grep ntp
root     30621 30551  0 16:02 pts/2    00:00:00 grep ntp

 

없다면 ntp 패키지가 설치되어 있는지 확인한다.

[root@localhost ~]# rpm -qa| grep ntp
chkfontpath-1.10.1-1.1

 

ntp 패키지가 없다면 ntp client 패키지를 설치한다.

[root@localhost ~]# yum install ntp
Loading "fastestmirror" plugin
Determining fastest mirrors
 * base: centos.mirror.cdnetworks.com
 * updates: centos.mirror.cdnetworks.com
 * addons: centos.mirror.cdnetworks.com
 * extras: centos.mirror.cdnetworks.com
base                      100% |=========================| 1.1 kB    00:00    
primary.xml.gz            100% |=========================| 878 kB    00:00    
base      : ################################################## 2508/2508
updates                   100% |=========================|  951 B    00:00    
primary.xml.gz            100% |=========================| 183 kB    00:00    
updates   : ################################################## 282/282
addons                    100% |=========================|  951 B    00:00    
extras                    100% |=========================| 1.1 kB    00:00    
primary.xml.gz            100% |=========================|  96 kB    00:00    
extras    : ################################################## 309/309
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package ntp.i386 0:4.2.2p1-9.el5.centos.2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 ntp                     i386       4.2.2p1-9.el5.centos.2  updates           1.3 M

Transaction Summary
=============================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        

Total download size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): ntp-4.2.2p1-9.el5. 100% |=========================| 1.3 MB    00:00    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: ntp                          ######################### [1/1]

Installed: ntp.i386 0:4.2.2p1-9.el5.centos.2
Complete!


시간 동기화를 위한 서버 정보를 추가한다. (참조 : http://www.pool.ntp.org/zone/asia, http://time.ewha.or.kr/domestic.shtml)

[root@localhost ~]# vi /etc/ntp.conf
#server 0.centos.pool.ntp.org -> 주석처리
#server 1.centos.pool.ntp.org -> 주석처리
#server 2.centos.pool.ntp.org -> 주석처리
server kr.pool.ntp.org
server ntp.postech.ac.kr
server ntp.xbsd.kr

 

서버 시간을 최초 1번 동기화한다.

[root@localhost ~]# ntpdate kr.pool.ntp.org
20 Jun 16:42:17 ntpdate[21883]: adjust time server 115.139.9.150 offset 0.005223 sec

 

시간 동기화를 자동으로 관리하기 위한 데몬을 실행한다.

[root@localhost ~]# service ntpd start
ntpd (을)를 시작 중:                                       [  OK  ]

 

프로세스가 실행되었는지 확인한다.

[root@localhost ~]# ps -ef | grep ntp
ntp       7587     1  0 16:41 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g

 

부팅시에 ntpd 데몬이 실행되도록 한다.

[root@localhost ~]# chkconfig ntpd on

 

시간 동기화를 확인한다. * 표시가 있어야 한다. (1~2분정도 되면 sync가 된다.)

[root@localhost ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*218.234.23.44   211.115.194.21   3 u   27   64   37    2.137   -6.036   7.250
+202.71.100.67   91.189.94.4      3 u   23   64   37  294.291   95.675   3.859
+doga.jp         133.243.238.243  2 u   26   64   37   42.602   -5.859   3.721
 LOCAL(0)        .LOCL.          10 l   22   64   37    0.000    0.000   0.001

 

* 는 현재 sync 를 받고 있음을 의미
+ ntp 접속은 가능하지만 sync 를 하고 있지는 않음을 의미
- ntp 접속은 가능하지만 sync 가능 리스트에서 제외 된 경우
blank 또는 INIT 는 접속이 불가능함을 의미

[출처] NTP 시간서버 설정|작성자

'IT인생_스크랩 > Linux' 카테고리의 다른 글

TCPDUMP 사용법  (0) 2010.06.24
리눅스 시스템 Bonding  (0) 2010.06.23
리눅스 관리자가 알아야 할 50가지  (0) 2010.06.23
Gentoo Linux 설치하기  (0) 2010.06.23
리눅스 시스템 모니터링  (0) 2010.06.23