Wstęp
Ta strona przedstawia przykładową konfigurację systemu Debian 8 do synchronizacji czasu systemu z serwerami NTPD w Polsce.
Strona oparta o źródła:
- https://wiki.debian.org/TimeZoneChanges
- https://wiki.debian.org/DateTime#Set_the_time_automatically
- http://www.pool.ntp.org/zone/pl
Procedura konfiguracyjna
Ustawienie poprawne strefy czasowej dla systemu
[root@debian8-01 ~]# dpkg-reconfigure tzdata
Powyższe uruchomi kreator w trybie tekstowym, który ustawi wskazaną strefę czasową modyfikując pliki /etc/localtime oraz /etc/timezone. Na przykład po wskazaniu Europe/Warsaw:
[root@debian8-01 ~]# dpkg-reconfigure tzdata Current default time zone: 'Europe/Warsaw' Local time is now: Fri Jan 20 00:20:43 CET 2017. Universal Time is now: Thu Jan 19 23:20:43 UTC 2017. [root@debian8-01 ~]# cat /etc/timezone Europe/Warsaw [root@debian8-01 ~]# md5sum /etc/localtime 2ed881ef7e09c844c009673ded84c798 /etc/localtime [root@debian8-01 ~]# md5sum /usr/share/zoneinfo/Europe/Warsaw 2ed881ef7e09c844c009673ded84c798 /usr/share/zoneinfo/Europe/Warsaw
Instalacja oprogramowania
[root@debian8-01 ~]# apt install ntp
Ustawienie listy serwerów z których będzie pobierany czas
Na świecie istnieją miliony serwerów NTP, które zrzeszone są na stronie pool.ntp.org. Bazując na liście serwerów w Polsce należy zmodyfikować linie rozpoczynające się od dyrektywy server:
[root@debian8-01 ~]# vim /etc/ntp.conf [root@debian8-01 ~]# grep pool /etc/ntp.conf # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will # pool: <http://www.pool.ntp.org/join.html> server 0.pl.pool.ntp.org server 1.pl.pool.ntp.org server 2.pl.pool.ntp.org server 3.pl.pool.ntp.org
Zrestartowanie demona ntpd
[root@debian8-01 ~]# /etc/init.d/ntp restart [ ok ] Restarting ntp (via systemctl): ntp.service. [root@debian8-01 ~]# /etc/init.d/ntp status ● ntp.service - LSB: Start NTP daemon Loaded: loaded (/etc/init.d/ntp) Active: active (running) since Thu 2017-01-19 23:50:43 CET; 4s ago Process: 7118 ExecStop=/etc/init.d/ntp stop (code=exited, status=0/SUCCESS) Process: 7128 ExecStart=/etc/init.d/ntp start (code=exited, status=0/SUCCESS) CGroup: /system.slice/ntp.service └─7135 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 109:114 Jan 19 23:50:43 debian8-01 systemd[1]: Started LSB: Start NTP daemon. Jan 19 23:50:43 debian8-01 ntpd[7135]: proto: precision = 0.110 usec Jan 19 23:50:43 debian8-01 ntpd[7135]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123 Jan 19 23:50:43 debian8-01 ntpd[7135]: Listen and drop on 1 v6wildcard :: UDP 123 Jan 19 23:50:43 debian8-01 ntpd[7135]: Listen normally on 2 lo 127.0.0.1 UDP 123 Jan 19 23:50:43 debian8-01 ntpd[7135]: Listen normally on 3 eth0 10.0.2.15 UDP 123 Jan 19 23:50:43 debian8-01 ntpd[7135]: Listen normally on 4 lo ::1 UDP 123 Jan 19 23:50:43 debian8-01 ntpd[7135]: Listen normally on 5 eth0 fe80::a00:27ff:feba:e69 UDP 123 Jan 19 23:50:43 debian8-01 ntpd[7135]: peers refreshed Jan 19 23:50:43 debian8-01 ntpd[7135]: Listening on routing socket on fd #22 for interface updates
Weryfikacja
[root@debian8-01 ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== vega.cbk.poznan 193.219.28.147 3 u 20 64 3 11.929 -1.003 0.186 ip-159-253-242- 194.146.251.100 2 u 17 64 3 13.710 -0.673 1.604 stratum-2.test. 195.187.245.55 2 u 17 64 3 14.158 -0.648 2.205 news-archive.ic 247.92.156.107 2 u 17 64 3 12.368 -3.044 0.495 [root@debian8-01 ~]# date Fri Jan 20 22:35:36 CET 2017
Patrz także
- Komenda date - ustawienie czasu ręcznie i wyświetlanie aktualnej godziny i daty
- Komenda ntpdate - jednorazowa synchronizacja czasu z serwerami ntpd
TODO na tej stronie
- Jak skonfigurować demon NTPD do pobierania aktualnego czasu - Mariusz Zalewski
- LPI - date, /etc/ntp.conf, ntpd, ntpdate - Mariusz Zalewski
- LPI - pool.ntp.org - Mariusz Zalewski
- LPI - Strefy czasowe /usr/share/zoneinfo/ /etc/timezone /etc/localtime - Mariusz Zalewski
Add Comment