Problema

O horário do servidor não respeita o timezone configurado via timedatectl:

[root@lab01 ~]# date
Sat Aug 21 09:49:06 -03 2021
[root@lab01 ~]# timedatectl 
      Local time: Sat 2021-08-21 09:49:10 -03
  Universal time: Sat 2021-08-21 12:49:10 UTC
        RTC time: Sat 2021-08-21 12:49:10
       Time zone: America/Sao_Paulo (-03, -0300)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Mesmo habilitando a atualização do horário via NTP:

[root@lab01 ~]# timedatectl set-ntp true
[root@lab01 ~]# 
[root@lab01 ~]# date
Sat Aug 21 09:49:23 -03 2021

Tentativa de consultar o serviço NTP, falha com erro “Connection Refused”:

[root@lab01 ~]# ntpq -p
ntpq: read: Connection refused

O serviço ntpd está configurado corretamente e o servidor NTP responde o teste com ping:

[root@lab01 ~]# cat /etc/ntp.conf
server ntp.dibiei.com iburst
[root@lab01 ~]#  
[root@lab01 ~]# ping ntp.dibiei.com
PING ntp.dibiei.com (192.168.1.99) 56(84) bytes of data.
64 bytes from 192.168.1.99 (192.168.1.99): icmp_seq=1 ttl=64 time=0.066 ms
64 bytes from 192.168.1.99 (192.168.1.99): icmp_seq=2 ttl=64 time=0.106 ms
64 bytes from 192.168.1.99 (192.168.1.99): icmp_seq=3 ttl=64 time=0.086 ms
64 bytes from 192.168.1.99 (192.168.1.99): icmp_seq=4 ttl=64 time=0.098 ms
64 bytes from 192.168.1.99 (192.168.1.99): icmp_seq=5 ttl=64 time=0.182 ms

O firewall está desabilitado no servidor NTP:

[root@srvdns ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Causa

O serviço chronyd está ativo no servidor de banco de dados, esse serviço gera conflito com o ntpd:

[root@lab01 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-08-21 09:49:21 -03; 3h 1min ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 4635 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 4631 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 4633 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─4633 /usr/sbin/chronyd

Aug 21 09:49:21 lab01 systemd[1]: Starting NTP client/server...
Aug 21 09:49:21 lab01 chronyd[4633]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Aug 21 09:49:21 lab01 chronyd[4633]: Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift
Aug 21 09:49:21 lab01 systemd[1]: Started NTP client/server.
Aug 21 09:49:30 lab01 chronyd[4633]: Selected source 146.164.48.66
Aug 21 09:49:30 lab01 chronyd[4633]: System clock wrong by 10828.431662 seconds, adjustment started
Aug 21 12:49:58 lab01 chronyd[4633]: System clock was stepped by 10828.431662 seconds

Solução

Ao desabilitar o serviço do chrony e reiniciar o serviço ntpd, o horário foi ajustado corretamente:

[root@lab01 ~]# systemctl stop chronyd
[root@lab01 ~]# 
[root@lab01 ~]# ntpq -p
ntpq: read: Connection refused
[root@lab01 ~]# 
[root@lab01 ~]# systemctl restart ntpd
[root@lab01 ~]# 
[root@lab01 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 192.168.1.99    .INIT.          16 u    -   64    0    0.000    0.000   0.000
[root@lab01 ~]# 
[root@lab01 ~]# date
Sat Aug 21 12:51:25 -03 2021

Desabilitando serviço o serviço chronyd para não iniciar automaticamente com o sistema operacional:

[root@lab01 ~]# systemctl disable chronyd
Removed symlink /etc/systemd/system/multi-user.target.wants/chronyd.service.

Leave a Reply

Discover more from Blog do Dibiei

Subscribe now to keep reading and get access to the full archive.

Continue reading