Blog-Seite

Jeder Beitrag auf dieser Blogseite soll den Umgang mit dem Network Time Protocol vereinfachen.

alle Artikel
8 min Lesezeit

Im ersten Schritt ist die Datei ntp.conf im Verzeichnis /etc/ntpd/ unter CentOS zu erstellen. Im Anschluss muss jetzt der für das Meinberg Empfangsmodul zu verwendende Reference-clock-driver für ntpd hinterlegt werden. Dies ist der PARSE driver mit der Reference ID: PARSE, Driver-ID: GENERIC und wird über die IP Adresse 127.127.8.0 angesprochen. Der PARSE Driver erwartet grundsätzlich die Schnittstelle /dev/refclock-0. Sollte diese nicht vorhanden sein, ist ein symbolischer Link zwischen dem tatsächlichen seriellen Interface ( z.B. /dev/ttyS0) und der PARSE Driver Schnittstelle herzustellen. Dies kann unter CentOS via einer udev-rule umgesetzt werden.

Damit der ntpd Daemon den PARSE Driver korrekt ansprechen kann, sind die folgenden Konfigurationsoptionen in der ntpd.conf Datei einzutragen:

# The PARSE reference clock driver to handle MEINBERG DCF77 receiver
server 127.127.8.0 mode 2

Die Parameter server 127.127.8.0 mode 2 veranlasst den ntp Daemon, den PARSE Driver im Mode 2 (Serielle Schnittstelle /dev/refclock-0 mit 9600 7E2) anzusprechen und das DCF77 Signal korrekt auszuwerten. Zusätzlich empfiehlt es sich bei einem Totalausfall der Meinberg-Uhr auf die Server eigene Uhr im Fehlerfall auszuweichen. Dies kann wie folgt konfiguriert werden.

# Now the local clock which is fall-back, if DCF77 is offline...
server 127.127.1.0
fudge 127.127.1.0 stratum 10

Die im Beispiel aufgeführten Zeilen sorgen dafür, dass bei Totalausfall des Meinberg Empfangsmoduls der ntp Daemon seinen Dienst nicht quittiert, sondern auf die Systemuhr umschwenkt und als Stratum 10 Server seinen Dienst fortsetzt.


Eine Beispielkonfiguration für einen Stratum-1-Server

#/bin/sh
#
# @(#)make 1.2 (maj) 2009/11/16
# Main configuration file for Stratum 1 ntp daemon
#
# Author: Jens Mahnke, ()
# Copyright (c) 2009 All rights reserved.
#


# --- GENERAL CONFIGURATION ---

# First, the GENERIC clock referecne driver.
# It supports the Meinberg DCF77-C51 in their defaults, which are
# serial line connected, 9600 bits, 7E2.
# The settings are 'server 127.127.8.0 mode 2'
server 127.127.8.0 mode 2

# --- Fallback Configuration if DCF77 signal offline ---
# the local clock as Stratum 10 which is fall-back, if DCF77 is offline...
server 127.127.1.0
fudge 127.127.1.0 stratum 10

# --- Online Server as Backup Configuration ---

# server ptbtime2.ptb.de iburst minpoll 6 maxpoll 8
# server 192.53.103.108 prefer minpoll 4 maxpoll 5 iburst
# ptbtime2.ptb.de has been inserted as a fallback server, if local DCF77
# antenna or reciver has a malfunction, meanwhile all test-environments
# in the wild will synchronize its systems with this server

# --- Drift file Configuration ---

# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /var/lib/ntpd/drift


# --- Log file Configuration ---
# The log configuration.
# Here is configured what you want to log or not
# The logfile has to be provided at startup as a parameter for ntpd
#
logconfig =clockevents +syncevents +sysevents +clockstatus +syncstatus +sysstatus +clockinfo +syncinfo +sysinfo +clockall +syncall +sysall

#
# Enabling and configuration for ntp statistics
#
enable stats
# statistics loopstats peerstats clockstats timingstats
# statsdir /var/lib/ntpd/stats/
statistics loopstats peerstats clockstats timingstats sysstats
statsdir /var/log/ntpd-stats/
filegen loopstats file loopstats type none enable
filegen peerstats file peerstats type none enable
filegen clockstats file clockstats type none enable
filegen timingstats file timingstats type none enable
filegen sysstats file sysstats type none enable

# End of configuration section
## EOF


Eine Beispielkonfiguration für einen Stratum-2-Server

#/bin/sh
#
#
# @(#)make 1.2 (maj) 2009/11/16
# Main configuration file for Stratum 2 ntp daemon
#
# Author: Jens Mahnke, ()
# Copyright (c) 2009 All rights reserved.
#

#
# --- GENERAL CONFIGURATION ---
#
# to detect falsespeaker and falseticker ntp server
server 192.168.0.10 prefer minpoll 4 maxpoll 5
server 192.168.0.11 prefer minpoll 4 maxpoll 5
server 192.168.0.12 prefer minpoll 4 maxpoll 5
server 192.168.0.13 prefer minpoll 4 maxpoll 5

#
# --- Fallback Configuration ---
#
# the local clock as Stratum 12 which is fall-back, if local Stratum 1 server offline ...
server 127.127.1.0
fudge 127.127.1.0 stratum 12

#
# --- Online Server as Backup Configuration ---
#

# ptbtime2.ptb.de has been inserted as a fallback server, if local Stratum 1 server
# has a malfunction, meanwhile all test-environments
# in the wild will synchronize its systems with this server
# server ptbtime2.ptb.de iburst minpoll 6 maxpoll 8
# server 192.53.103.108 prefer minpoll 4 maxpoll 5 iburst

#
# --- Drift file Configuration ---
#

# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntpd/drift

#
# --- Log file Configuration ---
#
# Here is configured what you want to log or not
# The logfile has to be provided at startup as a parameter for ntpd
#
logconfig =clockevents +syncevents +sysevents +clockstatus +syncstatus +sysstatus +clockinfo +syncinfo +sysinfo +clockall +syncall +sysall

#
# Enabling and configuration for ntp statistics
# The 'filegen' directive changes the default settings for the
# statistics generation. Especially 'type none enable' ensures
# that only one flat text file for each statistics type will be
# generated as of in default for each day an ntpd internal 'log rotate'
# will genearte a statistic file named e.g. loopstats.20071030.
# gematik will enforce the standardized log-rotate mechanism to
# backup these statistic files on its own also for the possivility
# of compressing the statistic files with 'gzip -9' ;-)
enable stats
statistics loopstats peerstats clockstats timingstats sysstats
statsdir /var/log/ntpd-stats/
filegen loopstats file loopstats type none enable
filegen peerstats file peerstats type none enable
filegen clockstats file clockstats type none enable
filegen timingstats file timingstats type none enable
filegen sysstats file sysstats type none enable

# End of configuration section
## EOF


Eine Beispielkonfiguration für einen Stratum-3-Server

#/bin/sh
#
# @(#)make 1.2 (maj) 2009/11/20
# Main configuration file for Stratum 3 ntp daemon
#
# Author: Jens Mahnke, ()
# Copyright (c) 2009 All rights reserved.
#

#
# --- GENERAL CONFIGURATION ---
#
# to detect falsespeaker and falseticker ntp server
server 192.168.0.14 prefer minpoll 4 maxpoll 5
server 192.168.0.15 prefer minpoll 4 maxpoll 5
server 192.168.0.16 prefer minpoll 4 maxpoll 5
server 192.168.0.17 prefer minpoll 4 maxpoll 5

#
# --- Fallback Configuration ---
#
# the local clock as Stratum 14 which is fall-back, if local Stratum 1 server offline ...
server 127.127.1.0
fudge 127.127.1.0 stratum 14

#
# --- Online Server as Backup Configuration ---
#

# ptbtime2.ptb.de has been inserted as a fallback server, if local Stratum 2 server
# has a malfunction, meanwhile all test-environments
# in the wild will synchronize its systems with this server
# server ptbtime2.ptb.de iburst minpoll 6 maxpoll 8
# server 192.53.103.108 prefer minpoll 4 maxpoll 5 iburst

#
# --- Drift file Configuration ---
#

# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntpd/drift

#
# --- Log file Configuration ---
#
# Here is configured what you want to log or not
# The logfile has to be provided at startup as a parameter for ntpd
#
logconfig =clockevents +syncevents +sysevents +clockstatus +syncstatus +sysstatus +clockinfo +syncinfo +sysinfo +clockall +syncall +sysall

#
# Enabling and configuration for ntp statistics
# The 'filegen' directive changes the default settings for the
# statistics generation. Especially 'type none enable' ensures
# that only one flat text file for each statistics type will be
# generated as of in default for each day an ntpd internal 'log rotate'
# will genearte a statistic file named e.g. loopstats.20071030.
# gematik will enforce the standardized log-rotate mechanism to
# backup these statistic files on its own also for the possivility
# of compressing the statistic files with 'gzip -9' ;-)
enable stats
statistics loopstats peerstats clockstats timingstats sysstats
statsdir /var/log/ntpd-stats/
filegen loopstats file loopstats type none enable
filegen peerstats file peerstats type none enable
filegen clockstats file clockstats type none enable
filegen timingstats file timingstats type none enable
filegen sysstats file sysstats type none enable

# End of configuration section
## EOF