红联Linux门户
Linux帮助
当前位置: 红联Linux门户 > SuSE

NTP升级为4.2.8版本后的问题

发布时间:2015-12-07 10:15:12来源:红联作者:hanyongc
问题:ntp编译了新版本后在使用过程中无法用ntp账号来启动ntpd服务,必须使用root账号。哪位能帮忙分析一下啊,谢谢!!

系统版本为SUSE11 PS3,NTP版本为4.2.4p8,现需要将此版本升级为4.2.8p4。网上升级的步骤如下:

一、首先将NTP升级包ntp-4.2.8p4.tar.gz拷贝至/tmp,再在/tmp目录中创建一个补丁文件ntp_syscall.h.patch并将下面的内容写入。否则在后续“make”的过程中会报错。
--- include/ntp_syscall.h
+++ include/ntp_syscall.h
@@ -14,5 +14,13 @@
# include
#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
+
#ifndef NTP_SYSCALLS_LIBC
#ifdef NTP_SYSCALLS_STD

二、备份原有NTP文件
cd /tmp
mkdir ntp
mv /usr/sbin/ntp* /tmp/ntp

三、编译新版NTP
cd /tmp
tar -zxvf ntp-4.2.8p4.tar.gz
cp ntp_syscall.h.patch /tmp/ntp-4.2.8p4/include
cd /tmp/ntp-4.2.8p4/include
patch -p1 < ntp_syscall.h.patch

cd /tmp/ntp-4.2.8p4
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks --enable-clockctl
make
make install
cp /usr/local/ntp/bin/ntp* /usr/sbin/

四、编辑/etc/ntp.conf,增加ntp服务器源,添加一行NTP Server:
server xxx.xxx.xxx.xxx

五、启动NTP服务并查看版本
chkconfig ntp on
service ntp start
service ntp status
ntpd --version


按照上述操作完成后,NTP服务可以正常的启停,但是无法和NTP服务器同步时间,查看/var/log/ntp,报错信息如下:
30 Nov 16:50:10 ntpd[31145]: Listen and drop on 0 v4wildcard 0.0.0.0:123
30 Nov 16:50:10 ntpd[31145]: Listen normally on 1 lo 127.0.0.1:123
30 Nov 16:50:10 ntpd[31145]: Listen normally on 2 lo 127.0.0.2:123
30 Nov 16:50:10 ntpd[31145]: Listen normally on 3 eth0 192.100.100.200:123
30 Nov 16:50:10 ntpd[31145]: Listening on routing socket on fd #20 for interface updates
30 Nov 16:50:10 ntpd[31145]: running as non-root disables dynamic interface tracking
30 Nov 16:50:11 ntpd[31145]: step-systime: Operation not permitted
30 Nov 16:55:53 ntpd[31145]: set_freq: ntp_loopfilter.c line 1088: ntp_adjtime: Operation not permitted
30 Nov 16:55:53 ntpd[31145]: step-systime: Operation not permitted
30 Nov 16:55:53 ntpd[31145]: frequency error 554416050 PPM exceeds tolerance 500 PPM
30 Nov 17:01:29 ntpd[31145]: step-systime: Operation not permitted

进一步分析/etc/sysconfig/ntp配置文件发现NTPD_OPTIONS="-g -u ntp:ntp";即ntpd其实是运作在ntp账号下。如果将此选项修改为NTPD_OPTIONS="-g -u root:root",那么可以和NTP服务器同步时间了。

NTP服务被设置为在NTP账号下运行,本意是为了确保系统的安全。有关ntpd的参数说明中有提及:
-u user[:group]
Specify a user, and optionally a group, to switch to. This option is only available if the OS supports running the server without full root privileges. Currently, this option is supported under NetBSD (configure with --enable-clockctl) and Linux (configure with --enable-linuxcaps).

根据上述的提示将./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks --enable-clockctl修改为./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks --enable-linuxcaps进行测试,但是在编译过程中会有报错。


综上所述,目前的问题就是ntp编译了新版本后在使用过程中无法用ntp账号来启动ntpd服务,必须使用root账号。哪位能帮忙分析一下啊,谢谢!!
文章评论

共有 0 条评论