KLAPEK pisze:Wywalam ten szajsowy ntp
Wracam do crona i ntpdate.
U mnie ntpd działa poprawnie i jest w moim przekonaniu znacznie lepszym rozwiązaniem ustawiania/serwera czasu dla sieci. Dla komputera lokalnego, gdzie czas aż tak nie jest krytyczny można zostać przy cyklicznym pytaniu ntpdate z crona. U mnie w sieci lokalnej rejestrator przemysłowego monitoringu video pobiera sobie czas z lokalnego serwera ntp, a wiadomo, że dla takiego zastosowania naniesienie na nagranie video poprawnego czasu w postaci tzw. stempla czasowego jest krytyczne.
Uwaga. NTP w wersji 4.2.4 miał błąd polegający na tym, iż jeśli jego demon był ładowany podczas startu systemu, a jest to normalna sytuacja, to nie wiedzieć czemu proces ntpd ładował się dwa razy (temat był opisywany na mailliście ntp.org)
Ja przeszedłem na ntp 4.2.6, który na dzień dzisiejszy ma status stabilny i na wersji 4.2.6 problem z podwójnym ładowaniem się procesu na starcie nie występuje. Co prawda w syslogu pojawia się informacja, że w systemie nie ma interfejsu broadcastowego (
nie wiem, co może być powodem tego komunikatu), ale to zupełnie nie przeszkadza w działaniu ntpd oraz synchronizacji czasu na klientach sieci.
Kawałek /var/log/messages:
Kod: Zaznacz cały
ntpd[1494]: ntpd 4.2.6@1.2089-o Mon Dec 28 08:03:02 UTC 2009 (1)
ntpd[1495]: proto: precision = 1.080 usec
ntpd[1495]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
ntpd[1495]: Listen normally on 1 lo 127.0.0.1 UDP 123
ntpd[1495]: Listen normally on 2 eth0 192.168.1.1 UDP 123
ntpd[1495]: Listen normally on 3 eth1 10.0.0.1 UDP 123
ntpd[1495]: Listen normally on 4 ppp0 77.253.44.200 UDP 123
ntpd[1495]: Listening on routing socket on fd #21 for interface updates
/var/log/syslog
Kod: Zaznacz cały
ntpd[1495]: Unable to listen for broadcasts, no broadcast interfaces available
Ponadto jakby, ktoś chciał wklejam mój /etc/ntp.conf
Kod: Zaznacz cały
# Sample /etc/ntp.conf: Configuration file for ntpd.
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
server vega.cbk.poznan.pl prefer
server ntp.certum.pl
server ntp1.net.icm.edu.pl
#
# 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/db/ntp/ntpd.drift
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.1.255
#broadcastdelay 0.008
#broadcastclient
#multicastclient
#
# Keys file. If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key number to be
# used for making requests.
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote
# systems might be able to reset your clock at will.
#
#keys /etc/ntp/keys
#trustedkey 65535
#requestkey 65535
#controlkey 65535
# Don't serve time or stats to anyone else by default (more secure)
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1 nomodify
oraz zmodyfikowany /etc/rc.d/rc.ntpd
Kod: Zaznacz cały
#!/bin/sh
# Start/stop/restart ntpd.
CMDLINE="/usr/sbin/ntpd"
CONFIG="/etc/ntp.conf"
PID="/var/run/ntpd.pid"
DRIFT="/var/db/ntp/ntpd.drift"
ntpd_start() {
if [ $(ps -Nf | grep $CMDLINE -c) -eq 0 ]; then
if [ -r $PID ]; then
rm -f $PID
fi
echo -n "Starting NTP service: "
$CMDLINE -4 -b -c $CONFIG -p $PID -f $DRIFT -g
sleep 1
echo $CMDLINE
else
echo "NTP service already running."
fi
}
ntpd_stop() {
if [ $(ps -Nf | grep $CMDLINE -c) -eq 0 ]; then
echo "NTP service already stopped."
else
echo -n "Stopping NTP service... "
if [ -r $PID ]; then
kill -s 15 $(pidof ${CMDLINE})
rm -f $PID
else
killall -s 15 $(echo $CMDLINE | cut -d "/" -f 4)
fi
sleep 1
echo "OK"
fi
}
ntpd_status() {
if [ $(ps -Nf | grep $CMDLINE -c) -eq 0 ]; then
echo "NTP service already stopped."
else
echo "NTP service is running."
fi
}
case "$1" in
'start')
ntpd_start
;;
'stop')
ntpd_stop
;;
'restart')
ntpd_stop
ntpd_start
;;
'status')
ntpd_status
;;
*)
echo "Usage $0 start|stop|restart|status"
esac
Jakby ktoś chciał skompilować sobie ntp 4.2.6.ze źródeł, to na plikach nagłówkowych kernela wersji 2.6.29.6 wraz z gcc 4.4.2 lub wyższych ntp się nie skompiluje.
Po naniesieniu poniższego patcha na źródła, kompilacja odbywa się poprawnie
Kod: Zaznacz cały
diff -Naur ntp-4.2.6.orig/include/ntp_syscall.h ntp-4.2.6/include/ntp_syscall.h
--- ntp-4.2.6.orig/include/ntp_syscall.h 2009-12-09 08:36:37.000000000 +0100
+++ ntp-4.2.6/include/ntp_syscall.h 2009-12-26 07:08:56.289042888 +0100
@@ -11,7 +11,11 @@
#endif
#ifdef HAVE_SYS_TIMEX_H
-# include <sys/timex.h>
+#include <sys/timex.h>
+#if defined(ADJ_NANO) && !defined(MOD_NANO)
+/* bug in Linux header files */
+# define MOD_NANO ADJ_NANO
+#endif
#endif
#ifndef NTP_SYSCALLS_LIBC