NTP는 Network Time Protocal 의 줄임말로 네트워크로 연결되어 있는 컴퓨터들끼리 시각을 동기화시키는데 사용되는 프로토콜입니다.
서버데몬 실행시 Port는 UDP 23번을 사용합니다. 방화벽에 막혀있으면 서비스가 불가능하겠죠?
NTP서버및클라이언트 개념은 /etc/conf파일을 수정하기 나름입니다. 해당구축 플랫폼의 서버 3대의 시간을 동기화시키기 위해
1번 서버에 NTP설정을 하고 2번,3번 서버가 1번으로 바라보도록 NTP설정을 해주면 됩니다.
결국에 같은설정될 수도 아닐수도 있겠죠 그리고 굳이 동기화 시키지 않고 한번만 혹은 간혹 수동으로 하실 경우에는 ntpdate [ServerIP]를 사용하시면 됩니다.
그러나 이 경우는 rdate와 별반차이가 없기에 윗부분만 설명드리도록 하겠습니다.
NTP 설치
yum -y install ntp |
---|
NTP구성
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 iburst
server time.nuri.net iburst
server ntp1.gngidc.net iburst
server ntp2.gngidc.net ibust
# 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 나오기)
NTP 데몬 가동
service ntpd start |
---|
클라이언트의 경우
방법 1. 무조건 되는 방법 굵게 표시된 server를 다 삭제하시고 server 10.1.1.1로 변경하는 방법이 있습니다.
방법 2. 같은 네트워크 대역시 추천드립니다. (Boardcast, Multicast, Manycast 셋중택일)
cat /devull > /etc/ntp.confcat >> /etctp.conf << EOF server 10.1.1.1 multicastclient 224.0.1.1EOF |
---|
확인방법 3가지 (Process, netstat, ntpq)
Process 확인
ps -ef\ | grep ntp ntp 27421 1 0 13:02 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid |
---|---|
netstat 확인
netstat -anp \ | grep ntpudp 0 0 10.1.1.1:123 0.0.0.0:* 27421/ntpd |
---|---|
ntp 상태확인 (루트만가능 : 구동 이후 2~3분 경과시 출력됨.)
ntpq -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 |
---|