NTP 서버 환경 구축 하기 – 시간 동기화

자!!  NTP 란?
Network Time Protocal 의 줄임말입니다.
네트워크로 연결되어 있는 컴퓨터들끼리 클록 시각을 동기화시키는데 사용되는 프로토콜
이라고합니다.
서버데몬 실행시 Port는 UDP 23번을 사용합니다.  방화벽에 막혀있으면 서비스가 불가능하겠죠?
NTP서버및클라이언트 개념은 /etc/conf파일을 수정하기 나름입니다.
해당구축 플랫폼의 서버 3대의 시간을 동기화시키기 위해
1번서버에 NTP설정을 하고
2번,3번 서버가 1번으로 바라보도록 NTP설정을 해주면 됩니다.
결국에 같은설정될 수도 아닐수도 있겠죠
그리고 굳이 동기화 시키지 않고 한번만 혹은 때때로 하실경우엔
ntpdate [ServerIP]를 사용하시면 됩니다. 그러나 이 경우는 rdate와 별반차이가 없기에
윗부분만 설명드리도록 하겠습니다.
* Server IP : 10.1.1.1
* Client IP : 10.1.1.2
1. NTP 설치
root# yum -y install ntp
2. NTP구성(굵게 표시한부분만 따라오세요)
root# 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
# 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.1.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).
#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
#NTP Server List (Start)
server time.bora.net
server time.nuri.net
server ntp1.gngidc.net
server ntp2.gngidc.net
##NTP Server List (END)
# 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
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
restrict None mask 255.255.255.255 nomodify notrap noquery
:wq       (vi 나오기)
3. NTP 데몬 가동
root# service ntpd start
이상 NTP 구성입니다.
클라이언트의 경우
방법1. 무조건 되는 방법
 굵게 표시된 server를  다 삭제하시고 server 10.1.1.1로 변경하는 방법이 있습니다.
방법2. 같은 네트워크대역시 추천드립니다.(Boardcast, Multicast, Manycast 셋중택일)
root# cat /dev/null > /etc/ntp.conf
root# cat >> /etc/ntp.conf << EOF
server 10.1.1.1
multicastclient 224.0.1.1  
EOF
 
[ Part. Comment ]
*확인방법 3가지(Process, Netstat, ntpq)
1. Process 확인
root# ps -ef| grep ntp
ntp      27421     1  0 13:02 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid
2. netstat 확인
root# netstat -anp | grep ntp
udp        0      0 10.1.1.1:123                0.0.0.0:*                               27421/ntpd
3. net 상태확인 (루트만가능 : 구동 이후 2~3분 경과시 출력됨.)
root # netq -p
     remote           refid      st t when poll reach   delay   offset  jitter
=================================================================
 10.1.1.1        211.115.194.21   3 u   11   64    3    0.311   37.229   8.749

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

2 Responses

  1. 2022년 6월 18일

    2stitching

  2. 2023년 1월 27일

    2tourists

페이스북/트위트/구글 계정으로 댓글 가능합니다.