NTP升级,升级REDHAT时很顺利,升级完成后会默认覆盖掉原有文件,重启服务后,使用ntpd --version查看验证上即可,可在升级SUSE Linux时却发现错误频频,以下是我再升级时遇到的一些问题,小结之后希望有和我遇到同样错误的亲们可以作为参考:
一. 由于NTP包有漏洞,需下载4.2.7之后版本,网络下ntp-dev-4.2.7p26.tar.gz
1.解压
# tar –zxf ntp-dev-4.2.7p26.tar.gz –C /usr/src
2.编译
# cd/usr/src/ntp-dev-4.2.7p26
#./configure --prefix=/usr/local/ntp-dev-4.2.7p26--enable-all-clocks --enable-parse-clocks
如果生成Makefile文件时报错,提示信息为usge –-host skip在./configure 参数后添加--host=x86_64,这个参数(x86_64)来源于uname –m后得出的结果
3. #make 如果make报错,信息如下
ntp_loopfilter.c: In function ‘local_clock’:
ntp_loopfilter.c:516: error: ‘MOD_NANO’ undeclared (first use in this function)
ntp_loopfilter.c:516: error: (Each undeclaredidentifier is reported only once
ntp_loopfilter.c:516: error: for each function itappears in.)
make[3]: *** [ntp_loopfilter.o] Error 1
make[3]: Leaving directory`/usr/src/ntp-dev-4.2.7p26/ntpd‘
make[2]: *** [all] Error 2
make[2]: Leaving directory`/usr/src/ntp-dev-4.2.7p26/ntpd‘
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/ntp-dev-4.2.7p26‘
make: *** [all] Error 2
解决方法如下:
vim include/ntp_syscall.h.patch
--- ntp-4.2.4p7/include/ntp_syscall.h
+++ ntp-4.2.4p7/include/ntp_syscall.h
@@ -14,5+14,13 @@
#include<sys/timex.h>
#endif
+#if defined(ADJ_NANO) && !defined(MOD_NANO)
+#define MOD_NANO ADJ_NANO
+#endif
+
+#if defined(ADJ_TAI) && !defined(MOD_TAI)
+#define MOD_TAI ADJ_TAI
+#endif
+
#ifndefNTP_SYSCALLS_LIBC
#ifdefNTP_SYSCALLS_STD
# cd include
# patch -p0 < ntp_syscall.h.patch
patch file to:ntp_syscall.h
# cd ..
# make && make install
编译安装OK
4.生成环境变量
# echo ‘#ntp seting‘ >> /etc/profile.local
# echo ‘export PATH=$PATH:/usr/local/ntp/bin‘>> /etc/profile.local
#echo /usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p/tmp/ntpd.pid >> /etc/profile.local
# source /etc/profile.local
5 验证
# ntpd –version
版本已升级为4.2.7p26
ps:
vim include/ntp_syscall.h.patch ,里的内容有的需要缩进,以#开关内容须缩进