2011년 6월 8일 수요일

[CentOS] NTP 서버 설정

NTP 서버 설정

>ntp 서버 : 192.168.0.10
>client 서버 : 192.168.0.25


[Server 설정]

1. ntp 설치

[root@localhost ~]# yum install ntp
Loaded plugins: dellsysid, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.tt.co.kr
 * extras: centos.tt.co.kr
 * updates: centos.tt.co.kr
base                                                                 | 2.1 kB     00:00     
dell-omsa-indep                                                      | 1.9 kB     00:00     
dell-omsa-specific                                                   | 1.9 kB     00:00     
extras                                                               | 2.1 kB     00:00     
updates                                                              | 1.9 kB     00:00     
updates/primary_db                                                   | 588 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package        Arch              Version                             Repository       Size
============================================================================================
Installing:
 ntp            x86_64            4.2.2p1-9.el5.centos.2.1            base            1.3 M

Transaction Summary
============================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
ntp-4.2.2p1-9.el5.centos.2.1.x86_64.rpm                              | 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.x86_64 0:4.2.2p1-9.el5.centos.2.1                                                     

Complete!


2. ntp.conf 환경설정

[root@localhost ~]# vi /etc/ntp.conf 

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1

# Hosts on local network are less restricted.
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap      <= 주석 제거

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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         <= 추가

#broadcast 192.168.1.255 key 42         # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 key 42             # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8


3. 서비스 시작

[root@localhost ~]# service ntpd start
Starting ntpd: [  OK  ]


4. ntpd 프로세스 확인

[root@localhost ~]# ps -ef|grep ntp
ntp       4443     1  0 15:15 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root      4448  4329  0 15:15 pts/0    00:00:00 grep ntp


5. 부팅 시 ntpd 데몬이 실행되도록 설정

[root@localhost ~]# chkconfig ntpd on


6. 시간 동기화 확인

[root@localhost ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*ntp.postech.ac. .GPS.            1 u   22   64   37    8.006   -1.552  10.856
+mail.funix.net  211.115.194.21   3 u   19   64   37    2.744   -1.836   1.333
 LOCAL(0)        .LOCL.          10 l   17   64   37    0.000    0.000   0.001


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



[Clinet 설정]

1. Client에서 수동으로 시간 동기화

[root@client ~]# yum install ntp

[root@client ~]# ntpdate 192.168.0.10

 8 Jun 16:01:28 ntpdate[3692]: adjust time server 192.168.0.11 offset -0.006139 sec


** 참조 : http://www.pool.ntp.org/ko/use.html
          http://www.pool.ntp.org/zone/asia

댓글 없음:

댓글 쓰기