Configurar NTP en Red Hat 7

Estoy empezando a montar servidores con Red Hat 7 y hay muchas cosas nuevas. Una de ellas ha sido el servicio de NTP, que deja e ser controlado por el demonio ntpd. Ahora el servicio es Chrony. Si no lo sabes es posible que estés un rato intentando configurando el ntpd y tras reiniciar el servidor lo encuentres parado.

[root@jupiter ~]# systemctl status ntp

ntpd.service - Network Time Service

Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)

Active: inactive (dead)

Viendo como esta definido el servicio chronyd vemos que es incompatible con el servicio ntpd. Por tanto deberemos elegir entre uno u otro:

[root@jupiter ~]# more /usr/lib/systemd/system/chronyd.service [Unit] Description=NTP client/server After=ntpdate.service sntp.service ntpd.service Conflicts=ntpd.service

[Service]
Type=forking
EnvironmentFile=-/etc/sysconfig/chronyd
ExecStart=/usr/sbin/chronyd -u chrony $OPTIONS
ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers

[Install]
WantedBy=multi-user.target

Tras reiniciar el servidor este servicio arranca al estar habilitado y no tener incompatibilidades con otros servicios :

[root@jupiter ~]# systemctl status chronyd
chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled)
Active: active (running) since jue 2015-04-23 14:29:00 CEST; 1min 52s ago
Process: 2257 ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers (code=exited, status=0/SUCCESS)
Process: 2250 ExecStart=/usr/sbin/chronyd -u chrony $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2254 (chronyd)
CGroup: /system.slice/chronyd.service
└─2254 /usr/sbin/chronyd -u chrony

El fichero de configuración es el siguiente:

[root@jupiter ~]# more /etc/chrony.conf
# These servers were defined in the installation:
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

stratumweight 0

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Enable kernel RTC synchronization.
rtcsync

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
makestep 10 3

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

keyfile /etc/chrony.keys

# Specify the key used as password for chronyc.
commandkey 1

# Generate command key if missing.
generatecommandkey

# Disable logging of client accesses.
noclientlog

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5


logdir /var/log/chrony

En la documentación de Red Hat nos recomiendan en que casos usar un demonio u otro:
– En sistemas que se reinicien a menudo o que entren en hibernación recomiendan utilizar Chronyd.
– En sistemas que estén permanentemente encendidos recomiendan utilizar Ntpd.
Según cada caso instalaremos uno u otro, pero no los dos.

Para más información:

1. Documentación oficial de Red Hat
2. http://www.certdepot.net/rhel7-set-ntp-service/

Publicado por Julián García-Sotoca

Ingeniero de Telecomunicación y administrador de sistemas (GNU/Linux - UNIX). Entusiasta del Software libre y Open Source. Working behind the scenes

Deja un comentario