Addition/NTP

From iRedMail
Jump to: navigation, search

Dovecot and OpenLDAP may react very ugly when your computer-time is not correct.

OpenLDAP needs correct time-values if you want to implement replication. And dovecot simply stops with an Error "time moved backwards"

This problem may be seen especially on virtualized Hosts (like ESX/ESXi/Xen/KVM/...). But also "real server" may benefit of correct time-settings


Contents

current time

if you want to know the current time on your server just type in

Terminal:
# date

compare the result with your own watch :)

installation

The NTP-daemon is not installed by default on every system.

on debian you can install it using

Terminal:
# apt-get install ntp

on CentOS install the package using

Terminal:
# yum install ntp

configuration

afterwards you need to check the config-file for multiple lines starting with

File: /etc/ntp.conf
...
server HOSTNAME-OF-NTP-SERVER ...
...

extend these lines to read like that

File: /etc/ntp.conf
...
server HOSTNAME-OF-NTP-SERVER  ....  minpoll 4 maxpoll 10
...

the "maxpoll" interval is quite important: it tells ntp how often to talk to the ntp-server

the last number 10 (= every 1024 sec) is quite reasonable on real hardware
maybe you want to set it to 8 in virtual environments
please do not set it below 6 (= every 64 sec) as this might be seen as abusive
if you really want to have a very good time sync just use more server as reference

start/restart the service

afterwards remember to restart your ntp-daemon debian

Terminal:
# /etc/init.d/ntp restart

CentOS

Terminal:
# /etc/init.d/ntpd restart


date still stays seconds/minutes wrong

don't worry - this is a feature to keep applications like dovecot alive. The time will be synced in the background and "slowly" adjusted.

Terminal:
# ntpq -n -p


     remote           refid        st   t   when poll reach   delay   offset  jitter
==============================================================================
+XX.XX.XX.XX          .ATOM.           1 u    2   64  377   27.695   -0.217   0.518
*XXX.XXX.XXX.XXX      .ATOM.           1 u   44   64  377   27.985    0.117   0.381
+X.X.X.X              .ATOM.           1 u   32   64  377   27.346    0.046   0.273



the row "offset" gives you the difference that needs to be catched up. Just leave it and recheck after a cup of coffee :)

add to default runlevels

remember to add ntp to default runlevels

on debian this is done automaticaly
for CenOS type

Terminal:
# chkconfig --level 345 ntpd on


want to know more

http://en.wikipedia.org/wiki/Network_Time_Protocol
http://wiki1.dovecot.org/TimeMovedBackwards
http://wiki2.dovecot.org/TimeMovedBackwards

Personal tools