Time Setup

Warning: no need for that on XEN guests

Requirements

Check with

cat /sys/devices/system/clocksource/clocksource0/available_clocksource
cat /sys/devices/system/clocksource/clocksource0/current_clocksource

and only proceed if you have tsc, hpet or whatever else than a virtualized clock e.g. xen

ubuntu,

apt install nmap netcat ntpdate ntp ntpstat

slackware,

slackpkg search ntp-

Timezone

ubuntu,

tzselect
dpkg-reconfigure tzdata

#timedatectl set-timezone Europe/Paris
timedatectl set-timezone Europe/Moscow

cat /etc/timezone
#echo 'Europe/Paris' > /etc/timezone
#echo 'Europe/Moscow' > /etc/timezone

#ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime
ls -lhF /etc/localtime*

slackware,

ls -lF /etc/localtime*
rm -f /etc/localtime*
#ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime

Preliminary shot

#ntpsrv=ntp.obspm.fr
ntpsrv=0.ru.pool.ntp.org
ping -c1 $ntpsrv
nmap -sU -p123 $ntpsrv

#ubuntu
systemctl stop ntp

#slackware
/etc/rc.d/rc.ntpd stop

ntpdate -u $ntpsrv
hwclock --utc --systohc

Continuous time sync

mv -i /etc/ntp.conf /etc/ntp.conf.dist
egrep -v '^[[:space:]]*(#|$)' /etc/ntp.conf.dist > /etc/ntp.conf
vi /etc/ntp.conf

server 0.ru.pool.ntp.org iburst
server 1.ru.pool.ntp.org iburst
server 2.ru.pool.ntp.org iburst
server 3.ru.pool.ntp.org iburst

is this a cluster?

peer storage1

restrict default limited kod nomodify notrap noquery
restrict -6 default limited kod nomodify notrap noquery
#nopeer

ubuntu,

cp -pi /etc/default/ntp /etc/default/ntp.dist
vi /etc/default/ntp

#happy pacemaker and dovecot with -x: slew up to 600 seconds
NTPD_OPTS='-g -x'

#cat /etc/systemd/timesyncd.conf
systemctl start ntp
systemctl enable ntp

note. dhclient settings my override those.

slackware,

cp -pi /etc/rc.d/rc.ntpd /etc/rc.d/rc.ntpd.dist
chmod -x /etc/rc.d/rc.ntpd.dist
vi /etc/rc.d/rc.ntpd 

  CMDLINE="/usr/sbin/ntpd -g -x"

chmod +x /etc/rc.d/rc.ntpd 
/etc/rc.d/rc.ntpd start

Ready to go

ubuntu,

timedatectl status
ntpstat

common,

ps auxww | grep ntp
ntpq -p
#ntpq -pn

The jitter should be low, otherwise check the driftfile.

Resources

“ntpq -p” output http://nlug.ml1.co.uk/2012/01/ntpq-p-output/831

3.3. Clock Quality http://www.ntp.org/ntpfaq/NTP-s-sw-clocks-quality.htm

Xen domU VM time drifts out of sync with dom0 and other domU - IBM System x https://www.ibm.com/support/pages/xen-domu-vm-time-drifts-out-sync-dom0-and-other-domu-ibm-system-x


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml