RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR
리눅스시스템/설정  2014/01/22 19:40

NTP

리눅스 서버에서 시간 동기화

 

 


stratum 이란?

NTP 방식은 stratum이라는 계층구조를 가지고 있다.


stratum 0 은 GPS 나 세슘 원자 시계등 시간을 구하는 장비를 의미한다.


stratum 1 은 GPS 위성으로 부터 표준 시각정보를 받는 타임 서버를 말한다. ( NTP Primary Time Server 혹은 stratum 1 이라고 부름 )

                 stratum 0에서 직접 시간을 동기화 하는 서버


stratum 2 은 stratum 1에 시간을 동기화 하는 서버를 말한다. ( NTP Secondary Time Server 혹은 stratum 2 이라고 부름 )


stratum 2 부터는 아래로 트리형식으로 내려간다.


* stratum 계층 구조를 사용하는 이유

-> 모든 서버가 stratum 1 서버에 접근해서 시간을 동기화 할 경우 부하가 발생하여서 재대로 서비스를 할 수 없기 때문에

    stratum 1에 시간을 참조하는 stratum 2 서버를 참조하여서 부하를 분산하기 위해서 계층 구조를 사용한다.

-> stratum 1 ~ 15 까지의 편차가 m/s(micro seconds, 1/1000초) 이므로, 굳이 stratum 1 이나 2를 사용할 필요가 없다.

-> 내부 NTP 서버를 구축 할 경우 stratum 1 ~ 15 계층에서 표준 시간을 동기화하여 내부 Client 서버들에게 시간을 동기화 시켜준다.


* stratum 2 list (국내 NTP 서버 리스트)
ntp.ewha.net, ticktock.ewha.net, ntp1.epidc.co.kr, ntp2.epidc.co.kr, time.bora.net, time.korserve.net,
t2.korserve.net, rokkorclub.net, time.wonkwang.ac.kr, noc6-3.koren21.net, kr.pool.ntp.org, time.bora.net, time.nuri.net

최신 목록은 http://time.ewha.net/domestic.shtml 에서 확인을 하도록 한다




UTC 이란?

UTC (Universal Time Coordinated)은 원자시계로(stratum 0) 부터 측정한 공식적인 표준 시간을 말한다.




NTP protocol 포트 번호

NTP protocol은  UDP 123 포트를 사용한다

ntpdate -u 옵션으로 포트 번호 변경 가능


방화벽이 있을 경우 UDP 123포트를 해제하거나 다른 포트 변경해서 사용.



 

1. 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

-> 기본으로 모든 권한을 주지는 않음을 의미한다. (IPV4)
restrict -6 default kod nomodify notrap nopeer noquery

-> 기본으로 모든 권한을 주지는 않음을 의미한다. (IPV6)

 

# 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

-> 서버 자신에 대해서는 모든 권한을 가진다. (IPV4)


restrict -6 ::1

-> 서버 자신에 대해서는 모든 권한을 가진다. (IPV6)


# 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).
#server 0.rhel.pool.ntp.org  -> 주석 처리 ( default NTP서버 주소 )
#server 1.rhel.pool.ntp.org  -> 주석 처리 ( default NTP서버 주소 )

#server 2.rhel.pool.ntp.org  -> 주석 처리 ( default NTP서버 주소 )

server 105.102.50.81           -> 설정할 NTP 주소  ( NTP 서버 주소가 domain일 경우 /etc/resolv.conf 에 DNS를 등록해야한다 )
server 105.102.50.82           -> 설정할 NTP 주소

 

 

# 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   -> 주석 처리  ( 자신의 서버를 다른 Client에게 동기화를 허용 )

#fudge  127.127.1.0 stratum 10           -> 주석 처리  ( 자신의 서버를 다른 Client에게 동기화를 허용 )

 

 

# 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
~


 


2. ntpd 데몬 재시작

# service ntpd stop


# service ntpd start


# chkconfig ntpd on


 

3. ntpd 상태 확인

# ntpq -p


   remote                    refid           st    t    when poll reach   delay   offset  jitter
  ==============================================================================
  * 10.10.10.1      220.73.142.73      2      u     62   64   377    0.822    6.191   0.052
  + 10.10.10.2      192.168.17.8       2       u     60   64   377    1.217    6.426   0.187
  - 10.10.10.3      192.12.19.20       2       u     60   64   17    2.427    2.205   0.226
     10.10.10.4      192.36.144.22     2       u     58   64    0    1.540    3.777   0.051


- reach : 최근 8번 이내의 polling 에 대한 응답 여부.
- delay : network delay time.
- offset : local time 과 참조하는(ntp server) 와의 시간차이 보정값. ( 10초 이내 )
- jitter : 시간측정시 네트워크 지연으로 생기는 latency 차이에 대한 값.
 



remote : /etc/ntp.conf에 설정된 ntp서버 HOST/IP 주소이다 (stratum 2 이상 계층)

refid    : /etc/ntp.conf에 설정된 ntp서버가 표준 NTP서버를 바라보는 주소(stratum 1 계층) 

st        : stratum 계층 표시 (16 계층이 넘어가면 ntp 설정이 잘안된다고 볼 수 있다)

t         : 단층(Layer)의 타입 (l:Local, u:unicast, m:multicast, b:broadcast

when  : 마지막으로 packet을 수신한 이후 경과한 시간 (단위 : 초)

poll     : polling 간격 (단위 : 초)

reach  : 도달가능한 register 를 8진수로 표현한 값

delay  : Polling insterval 지연예상시간 (단위 : 밀리초)

offset  : 시간 차이, 단층(Layer)의 offset (단위 : 밀리초)

jitter    : 단층(Layer)의 분산 (단위 : 밀리초)


' ' (reject, 거부)   : 거리가 멀어서 사용되지 않는 서버

'X'                      : falseticker 검사결과 사용되지 않는 서버

'.' (excess, 초과) : 참조서버가 많아서 사용되지 않는 서버

'-'                       : clustering 검사결과 사용되지 않는 서버

'+'                       : 접속 테스트를 합격하여 언제든지 참조가 가능한 서버

'#'                       : 동기 거리가 멀지만 참조가 가능한 서버

'*'                       : 동기중인 서버

'o'                       : 동기중인 서버(동기는 PPS 신호로부터 간접적으로 행해짐)

 

 


 

4. ntpd 상태 확인

< poll에 대한 설명 > 

각 서버마다 network이나 기타 이유로 인하여 poll은 달라지게 된다.

기본적으로 minpoll64s(26)이고. maxpoll1,024s(210)이다. 이 옵션의 경우에는 ntp.conf에 삽입하여 사용도 가능하다.

minpoll 64 ; 16s(24)보다 작을 수 없다.

maxpoll 1024 ; 36.4h(217) 보다 클 수 없다.


< NTP packet 발송 주기 >

- Broadcast Type : 64초 마다 1개의 Transaction ( Packet 1개 )을 보냄 -> 지속

- unicast     Type : 64초 마다 1개의 Transaction ( Packet 2개 )을 보냄 -> 8 번

                            64초 마다 5개의 Transaction  연속 성공 시            -> 128초 주기로 변경

                            128초 마다 5개의 Transaction  연속 성공 시           -> 256초 주기로 변경

                            256초 마다 5개의 Transaction  연속 성공 시           -> 512초 주기로 변경

                            512초 마다 5개의 Transaction  연속 성공 시           -> 1024초 주기로 변경

                            실패시 64초로 poll 주기 변경


< reach에 대한 설명 >

reach  : 도달가능한 register 를 8진수로 표현한 값

reach 값은 타임서버에 완전히 접속하기 위한 8진수로 377이여야 합니다.

deleay 값은 작은 값이어야 합니다.

offset 값은 양수면 NTP서버 시간보다 로컬서버의 시간이 느린것, 음수면 로컬서버의 시간이 빨른것,

                 + - 으로 offset값이 500 이상 차이나면 동기화가 재대로 안된것.

jitter 값은 서버중 적어도 하나는 1000ms(1초) 미만이어야 한다.



# cat /etc/ntp.conf ( Default 설정 값 & 옵션 ) 

restrict
-> ntp 참조를 제한하거나 허용할 서버의 리스트들과 제한 및 허용에 대한 룰을 정하는 옵션입니다.

restrict default
-> 기본으로모든 권한을 주지는 않고 설정한 아이피 및 대역대에게만 권한을 준다.

restrict ignore
-> 기본으로모든 권한을 주고  설정한 아이피 및 대역대에게만 권한을 주지 않는다.

restrict : Deny all packets and queries
kod : Send Kiss-Of-Death packet on access violation
nomodify : Deny ntpq / ntpdc queries that attempt to modify the server //설정변경 관련 명령을 무시
notrap : Deny control message trap service //이벤트 트랩 무시
noquery : Deny all ntpq / ntpdc queries
noserve : Deny all queries - except ntpq / ntpdc
notrust : Deny access unless cryptographically authenticated (ver 4.2 onwards)
nopeer : Deny all packets that attempt to establish a peer association //클라이언트에 시간서비스를 제공하되 peer memory를 할당하여 관리하지 않도록함
--
server : Specifies that a server is running on the host (own local clock)
fudge : Passes additional information to the clock driver
stratum 10 : Manually sets the Stratum the server should operate at (1-15)
driftfile : Specifies the location of the frequency file //시간오차의 평균값 저장
broadcastdelay : Sets the propagation delay from the server when broadcasting
keys : Store a list of keys needed for any cryptographic links


# cat /etc/sysconfig/ntpd

# Drop root to id 'ntp:ntp' by default.
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

-> -x 옵션은 SLEW모드


# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK=no

->


# Additional options for ntpdate
NTPDATE_OPTIONS=""


< NTP 데몬 운용모드 >

NTP 데몬의 운용모드에는 STEP 모드와 SLEW모드 2가지가 존재한다.


STEP : STEP 모드일 경우는 순간적으로 시각을 동기화 시키므로 시각의 후퇴(과거 시간으로 돌아감)가 발생하여 시스템에 영향이 있음.

SLEW : SLEW 모드일 경우는 시각의 차이를 서서히 보정하므로 시각의 후퇴는 발생하지 않음.




 



 

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

 

ntpdate

# date

-> 현재 시간 확인


# ntpdate <NTP서버 IP>

-> ntpdate으로 ntp 서버시간을 실시간으로 적용한다.

-> ntpdate 명령어를 쳤을 경우 the NTP socket is in use, exiting 라는 메세지가 나오면 ntp 데몬이 running 중이여서 나오는것으로

    ntpd데몬을 stop해주고 다시 진행해준다.

 

2014/01/22 19:40 2014/01/22 19:40
http://zosel.net/trackback/93
from.Ugg On Line  2015/11/09 13:41
nike id trainers
from.Ugg Shop On Line  2015/11/09 13:53
nike free 4.0 v3
from.Ugg Baby  2015/11/09 15:23
nike free run 3 v2
from.Boots Ugg Outlet  2015/11/09 16:07
mcm london
from.Discount shopping  2016/03/06 02:32
::: ZOSEL ::: :: NTPD
from.new zealand supplements  2016/03/06 06:02
::: ZOSEL ::: :: NTPD
from.may quet 3d  2016/05/10 14:01
::: ZOSEL ::: :: NTPD
from.may scan 2 mat toc do cao  2016/05/10 14:16
::: ZOSEL ::: :: NTPD
from.Alicja po drugiej stronie lustra chomikuj  2016/06/19 22:35
::: ZOSEL ::: :: NTPD
from.Alicja po drugiej stronie lustra chomikuj  2016/06/19 22:36
::: ZOSEL ::: :: NTPD
from.skoda octavia  2016/06/20 03:36
::: ZOSEL ::: :: NTPD
from.skoda octavia  2016/06/20 03:36
::: ZOSEL ::: :: NTPD
from.Web Page  2016/06/22 11:57
::: ZOSEL ::: :: NTPD
from.Web Page  2016/06/22 11:57
::: ZOSEL ::: :: NTPD
from.old it disposal  2017/05/04 13:05
::: ZOSEL ::: :: NTPD
from.old it disposal  2017/05/04 13:05
::: ZOSEL ::: :: NTPD
from.advocare spark recall  2018/04/28 14:11
::: ZOSEL ::: :: NTPD
from.top machine vision inspeciton system manufacturer  2019/11/07 11:18
::: ZOSEL ::: :: NTPD
from.spiderman costume kids  2019/12/02 05:54
::: ZOSEL ::: :: NTPD
from.wonder woman costume 2017  2019/12/04 18:27
::: ZOSEL ::: :: NTPD
from.the flash jay garrick costume  2019/12/04 19:55
::: ZOSEL ::: :: NTPD
from.research by the staff of diigo.com  2019/12/04 19:56
::: ZOSEL ::: :: NTPD
from.lady death deadpool cosplay  2020/01/14 04:02
::: ZOSEL ::: :: NTPD
from.the flash season 2 zoom costume  2020/01/14 09:01
::: ZOSEL ::: :: NTPD
from.avengers black widow costume diy  2020/01/15 03:12
::: ZOSEL ::: :: NTPD
from.new joker costume  2020/01/16 19:44
::: ZOSEL ::: :: NTPD
from.childrens spiderman costume  2020/01/17 09:32
::: ZOSEL ::: :: NTPD
from.homemade spiderman suit  2020/01/17 15:57
::: ZOSEL ::: :: NTPD
from.spider man costumes  2020/01/17 20:56
::: ZOSEL ::: :: NTPD
from.ps4 spiderman suits  2020/01/19 03:14
::: ZOSEL ::: :: NTPD
from.spider man symbiote suit  2020/01/19 06:08
::: ZOSEL ::: :: NTPD
from.answers.informer.com official blog  2020/01/19 10:04
::: ZOSEL ::: :: NTPD
from.additional hints  2020/01/21 02:43
::: ZOSEL ::: :: NTPD
from.visit their website  2020/01/22 02:20
::: ZOSEL ::: :: NTPD
from.herrkl盲der utlopp billiga nike tv氓f盲rgad tr盲ningsoverall i  2020/01/23 12:02
<a href="http://www.invugaming.com/sombrillo/tips-till-barnrum">tips till barnrum</a><a href="http://www.invugaming.com/stecker/b%c3%a4sta-present-alpha-industries-herrar-polar-jacket-jackor">b盲sta present alpha industries herrar polar jacket jackor</a...
from.a cool way to improve  2020/01/25 08:10
::: ZOSEL ::: :: NTPD
from.thor costume infinity war  2020/01/26 00:54
::: ZOSEL ::: :: NTPD
from.recommended  2020/01/26 05:28
::: ZOSEL ::: :: NTPD
from.super hero cosplay costumes  2020/01/26 07:22
::: ZOSEL ::: :: NTPD
from.Click That Link  2020/01/26 07:56
::: ZOSEL ::: :: NTPD
from.our source  2020/01/28 01:17
::: ZOSEL ::: :: NTPD
from.the flash costume mask  2020/01/28 10:54
::: ZOSEL ::: :: NTPD
from.just click the next article  2020/01/28 19:28
::: ZOSEL ::: :: NTPD
from.black spiderman suit  2020/01/29 06:51
::: ZOSEL ::: :: NTPD
from.dillards online credit application  2020/01/29 16:21
::: ZOSEL ::: :: NTPD
from.http://javawirelessconnection.biz/  2020/02/05 02:05
::: ZOSEL ::: :: NTPD
from.marine deep cycle  2020/02/15 18:17
::: ZOSEL ::: :: NTPD
from.portable car battery charger rental  2020/02/20 16:15
::: ZOSEL ::: :: NTPD
from.lead acid batteries create  2020/02/26 21:31
::: ZOSEL ::: :: NTPD
from.visit here  2020/06/13 13:20
::: ZOSEL ::: :: NTPD
from.visit here  2020/08/22 15:29
::: ZOSEL ::: :: NTPD
from.visit here  2020/08/22 15:57
::: ZOSEL ::: :: NTPD
from.visit here  2020/08/22 16:37
::: ZOSEL ::: :: NTPD
from.visit here  2020/10/02 11:40
::: ZOSEL ::: :: NTPD
from.visit here  2020/10/25 13:50
::: ZOSEL ::: :: NTPD
from.visit here  2020/10/25 14:17
::: ZOSEL ::: :: NTPD
from.visit here  2020/12/26 17:59
::: ZOSEL ::: :: NTPD
from.visit here  2021/01/21 10:06
::: ZOSEL ::: :: NTPD
ZOSEL:Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
전체 (209)
리눅스시스템 (92)
윈도우시스템 (16)
프로그램 (7)
네트워크시스템 (7)
최근관심 (1)
«   2024/05   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
  1. yeezyboost-350.co.uk  2021
    yeezyboost-350.co.uk
  2. 강남역 풀싸롱  2021
    강남역 풀싸롱
  3.   2021
  1. 2018/02 (1)
  2. 2017/03 (2)
  3. 2016/12 (2)