NTP server

NTP server ili Network Time Protocol server je nešto što obavezno treba imati u mreži (radi po portu 123, UDP, i kao source i kao destination).
Ali kod nas se javlja jedan dodatni problem vezan za vreme, a on se zove “Daylight saving time” (DST), ili dodavanje odnosno oduzimanje po 60min dva puta godišnje.
Ako imate NTP server u mreži, koji skida vreme sa satelita (GPS sinhronizacija), može vam se desiti da imate baš takav problem sa datih +/-60min. Onda se takva podešavanja rade na Linux NTP serverima koji sa GPS uređaja primaju vreme :
Because NTP is based on UTC which does not have a daylight savings time period, a switchover is not necessary inside the NTP system. The operation systems of servers and clients are solely responsible for switching from/to DST.
Samim podešavanjem vremenske zone i lokaliteta određujemo da li se koristi DST ili ne, i Linux server se prema tome automatski namešta.
Ali šta ako u mreži imamo jedan GPS uređaj (koji ne prepoznaje DST) i nekoliko običnih Linux servera (koji prepoznaju DST), i svi oni treba zajedno da predstavljaju izvore tačnog vremena?
Pa lokalni Linux koji od sva tri prima vreme radiće sasvim OK, bez obzira na to da li njegov izvor poštuje ili nepoštuje DST :
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 28 64 377 0.000 0.000 0.001
*ne.poštuje.DST .GPS. 1 u 674 1024 377 1.358 2.784 0.390
+poštuje.DST 10.10.10.110 6 u 796 1024 377 3.918 -153.49 4.115
+poštuje.DST 10.10.10.11 5 u 858 1024 377 7.605 -122.96 128.946

Problem se javlja ako mi želimo da nam serveri niže strate budu primarni izvor vremena, a GPS uređaj (koji od svih ima najnižu stratu, i time se smatra najboljim) bude u stvari bekap.
Ovo se rešava tako što u /etc/ntp.conf fajlu željene server višlje strate proglasimo za prefered :
server ne.poštuje.DST.ide.na.GPS
restrict ne.poštuje.DST.ide.na.GPS mask 255.255.255.255 nomodify notrap noquery
server poštuje.DST.lošija.strata prefer
restrict poštuje.DST.lošija.strata mask 255.255.255.255 nomodify notrap noquery
server poštuje.DST.lošija.strata prefer
restrict poštuje.DST.lošija.strata mask 255.255.255.255 nomodify notrap noquery

Objašnjenja oznaka koje se javljaju u ovom ispisu :
* = current time source
# = source selected, distance exceeds maximum value
o = source selected, Pulse Per Second (PPS) used
+ = source selected, included in final set
x = source false ticker
. = source selected from end of candidate list
– = source discarded by cluster algorithm
blank = source discarded high stratum, failed sanity

refid: remote source’s synchronization source
stratum: stratum level of the source
t: types available
l = local (such as a GPS, WWVB)
u = unicast (most common)
m = multicast
b = broadcast
– = netaddr
when: number of seconds passed since last response
poll: polling interval, in seconds, for source
reach: indicates success/failure to reach source, 377 all attempts successful
delay: indicates the roundtrip time, in milliseconds, to receive a reply
offset: indicates the time difference, in milliseconds, between the client server and source
disp/jitter: indicates the difference, in milliseconds, between two samples

Relevantni fajlovi :
/etc/ntp.conf – konfiguracioni fajl
/usr/share/zoneinfo/* – u ovim fajlovima (koji su po lokacijama) je i podatak o DST!
/etc/timezone – kod mene je :
Europe/Belgrade
/etc/localtime – binarni/nečitljiv fajl
/var/log/messages – log fajl
/etc/ntp/keys
/etc/ntp/ntpservers – spisak NTP servera na koje je naš server uperen
/etc/ntp/step-tickers – spisak NTP servera za sinhronizaciju pri boot-u mašine
/etc/sysconfig/clock – podešena vremenska zona (podešava se kroz grafiku) :
ZONE=”Europe/Belgrade” – koja je vremenska zona u pitanju
UTC=false – Coordinated Universal Time, Zulu, Griničko vreme ili GTM. Hardversko podešavanje sata.
ARC=false – upotreba “normal UNIX epoch” vremena

Provera rada NTP servera :
#date – ovo daje vrednost varijable okoliša “TZ” (environmental variable)
Thu Feb 7 08:56:30 CET 2013
#ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 14 64 377 0.000 0.000 0.001
*10.10.10.11 .GPS. 1 u 86 128 377 0.214 -3.627 28.616
# ntpstat
synchronised to NTP server (10.10.10.11) at stratum 2
time correct to within 116 ms
polling server every 128 s
# pgrep ntpd – daje PID procesa
# ntpdc -c loopinfo
offset: -0.003627 s
frequency: 104.299 ppm
poll adjust: 7
watchdog timer: 445 s
# ntpq -crv
assID=0 status=0664 leap_none, sync_ntp, 6 events, event_peer/strat_chg,
version=”ntpd 4.2.0a@1.1190-r Thu Oct 5 04:11:32 EDT 2006 (1)”?,
processor=”i686″, system=”Linux/2.6.9-55.ELsmp”, leap=00, stratum=2,
precision=-20, rootdelay=1.344, rootdispersion=38.929, peer=44461,
refid=10.10.10.11,
reftime=d4bdfc04.1fd16766 Thu, Feb 7 2013 11:10:12.124, poll=10,
clock=0xd4bdfdf0.e7e6e653, state=4, offset=0.738, frequency=142.349,
noise=0.562, jitter=0.191, stability=12.189
# zdump -v /etc/localtime|grep 2013 – Kada DST stupa na snagu u lokalu
/etc/localtime Sun Mar 31 00:59:59 2013 UTC = Sun Mar 31 01:59:59 2013 CET isdst=0 gmtoff=3600
/etc/localtime Sun Mar 31 01:00:00 2013 UTC = Sun Mar 31 03:00:00 2013 CEST isdst=1 gmtoff=7200
/etc/localtime Sun Oct 27 00:59:59 2013 UTC = Sun Oct 27 02:59:59 2013 CEST isdst=1 gmtoff=7200
/etc/localtime Sun Oct 27 01:00:00 2013 UTC = Sun Oct 27 02:00:00 2013 CET isdst=0 gmtoff=3600

Dobar link1 i još jedan link2 i link3

Comments are closed.