
Note de lucru: setare sistem Ubuntu pentru sincronizarea ceasului cu servere etalon prin Network Time Protocol (NTP).
De notat că și în Ubuntu este folosit utilitarul timedatectl plus comenzile aferente, similar cu ceea ce am descris pentru CentOS 7. Diferențele apar la instalarea și configurarea sincronizării prin NTP.
Cum activez sincronizarea ceasului local al sistemului meu Ubuntu cu serverele etalon prin Network Time Protocol – NTP?
Pe un sistem Ubuntu am verificat situația ceasului:
root@server:~# timedatectl Local time: Tue 2017-08-22 10:06:45 CEST Universal time: Tue 2017-08-22 08:06:45 UTC RTC time: Tue 2017-08-22 08:06:42 Timezone: Europe/Berlin (CEST, +0200) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2017-03-26 01:59:59 CET Sun 2017-03-26 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2017-10-29 02:59:59 CEST Sun 2017-10-29 02:00:00 CET
Așa cum observați, fusul orar este setat pe Berlin, dar am vrut să îl modific pentru București:
root@server:~# timedatectl set-timezone Europe/Bucharest root@server:~# timedatectl Local time: Tue 2017-08-22 11:07:32 EEST Universal time: Tue 2017-08-22 08:07:32 UTC RTC time: Tue 2017-08-22 08:07:29 Timezone: Europe/Bucharest (EEST, +0300) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2017-03-26 02:59:59 EET Sun 2017-03-26 04:00:00 EEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2017-10-29 03:59:59 EEST Sun 2017-10-29 03:00:00 EET
Dacă ne uităm la ambele rapoarte de mai sus, vom vedea că sincronizarea NTP era activată, dar sincronizarea nu era făcută. Pentru siguranță am mai rulat și comanda:
root@server:~# timedatectl set-ntp yes
Și am vrut să mă asigur că sincronizarea chiar funcționează. M-am orientat după ghidul oficial Ubuntu pentru a instala NTP server:
root@server:~# apt install ntp Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libopts25 Suggested packages: ntp-doc The following NEW packages will be installed: libopts25 ntp 0 upgraded, 2 newly installed, 0 to remove and 5 not upgraded. Need to get 477 kB of archives. After this operation, 1,683 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://de.archive.ubuntu.com/ubuntu/ trusty/main libopts25 amd64 1:5.18-2ubuntu2 [55.3 kB] Get:2 http://de.archive.ubuntu.com/ubuntu/ trusty-updates/main ntp amd64 1:4.2.6.p5+dfsg-3ubuntu2.14.04.12 [421 kB] Fetched 477 kB in 0s (1,691 kB/s) Selecting previously unselected package libopts25:amd64. (Reading database ... 116450 files and directories currently installed.) Preparing to unpack .../libopts25_1%3a5.18-2ubuntu2_amd64.deb ... Unpacking libopts25:amd64 (1:5.18-2ubuntu2) ... Selecting previously unselected package ntp. Preparing to unpack .../ntp_1%3a4.2.6.p5+dfsg-3ubuntu2.14.04.12_amd64.deb ... Unpacking ntp (1:4.2.6.p5+dfsg-3ubuntu2.14.04.12) ... Processing triggers for ureadahead (0.100.0-16) ... ureadahead will be reprofiled on next reboot Processing triggers for man-db (2.6.7.1-1ubuntu1) ... Setting up libopts25:amd64 (1:5.18-2ubuntu2) ... Setting up ntp (1:4.2.6.p5+dfsg-3ubuntu2.14.04.12) ... * Starting NTP server ntpd [ OK ] Processing triggers for libc-bin (2.19-0ubuntu6.13) ... Processing triggers for ureadahead (0.100.0-16) ...
Am verificat configurația:
root@server:~# nano /etc/ntp.conf
Apoi am repornit serviciul și am verificat starea:
root@server:~# service ntp reload root@server:~# service ntp status * NTP server is running
Am verificat și statusul NTP:
root@server:~# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== re.uni-paderbor .DCF. 1 u 16 64 3 16.512 -2833.1 0.341 ns1.customer-re 192.53.103.108 2 u 15 64 3 0.817 -2829.7 0.573 2a03:b0c0:3:d0: 144.76.197.108 3 u 11 64 3 8.064 -2831.9 0.797 muug.ca 200.98.196.212 2 u 12 64 3 117.999 -2831.1 0.661 golem.canonical 17.253.34.253 2 u 13 64 3 16.100 -2831.4 0.505
Și o ultimă verificare cu timedatectl îmi confirmă fusul orar setat corect pe București și ceasul sincronizat cu NTPD:
root@server:~# timedatectl status Local time: Tue 2017-08-22 11:12:23 EEST Universal time: Tue 2017-08-22 08:12:23 UTC RTC time: Tue 2017-08-22 08:12:20 Timezone: Europe/Bucharest (EEST, +0300) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2017-03-26 02:59:59 EET Sun 2017-03-26 04:00:00 EEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2017-10-29 03:59:59 EEST Sun 2017-10-29 03:00:00 EET