停止ntp服务
代码语言:javascript复制[root@h101 sbin]# /etc/init.d/ntpd stop
Shutting down ntpd: [ OK ]
[root@h101 sbin]# /etc/init.d/ntpd status
ntpd is stopped
[root@h101 sbin]#
替换ntp服务程序
代码语言:javascript复制[root@h101 sbin]# mv ntpd ntpd.noconfig
[root@h101 sbin]# cp /usr/local/bin/ntpd .
[root@h101 sbin]# ll ntpd*
-rwxr-xr-x 1 root root 2633989 Nov 10 10:02 ntpd
-rwxr-xr-x 1 root root 110896 Oct 26 23:32 ntpdate
-rwxr-xr-x 1 root root 250312 Oct 26 23:32 ntpdc
-rwxr-xr-x 1 root root 2630962 Nov 9 21:22 ntpd.noconfig
-rwxr-xr-x 1 root root 759720 Oct 26 23:32 ntpd.old.4.2.6p5
[root@h101 sbin]#
还原配置
代码语言:javascript复制[root@h101 sbin]# vim /etc/sysconfig/ntpd
[root@h101 sbin]# cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
#OPTIONS=" -p /var/run/ntpd.pid -g"
[root@h101 sbin]#
启动服务
代码语言:javascript复制[root@h101 sbin]# /etc/init.d/ntpd start
Starting ntpd: [ OK ]
[root@h101 sbin]# ps faux | grep ntp
root 28277 0.0 0.0 103256 828 pts/0 S 10:03 0:00 _ grep ntp
ntp 28273 0.3 0.0 122812 2328 ? Ssl 10:03 0:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
[root@h101 sbin]#
[root@h101 sbin]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
-202.120.2.100 ( 202.118.1.130 3 u 1 64 377 6.135 2.924 1.802
s2a.time.edu.cn .INIT. 16 u - 512 0 0.000 0.000 0.000
202.112.0.7 .INIT. 16 u - 512 0 0.000 0.000 0.000
gus.buptnet.edu .INIT. 16 u - 512 0 0.000 0.000 0.000
mailgw.xanet.ed .INIT. 16 u - 512 0 0.000 0.000 0.000
dns1.synet.edu. 95.222.122.210 2 u 3 64 5 105.878 33.821 3.552
202.112.26.37 202.112.29.82 3 u 8 64 377 5.129 2.683 0.321
ntp.glnet.edu.c .INIT. 16 u - 512 0 0.000 0.000 0.000
-ns.pku.edu.cn 129.6.15.28 2 u 7 64 377 97.361 57.123 1.872
*news.neu.edu.cn 95.222.122.210 2 u 30 64 377 38.277 1.324 2.049
[root@h101 sbin]# ntpstat
synchronised to NTP server (202.118.1.81) at stratum 3
time correct to within 101 ms
polling server every 64 s
[root@h101 sbin]#
命令汇总
- ./configure –enable-clockctl
- ntpstat
- ntpq -p
- ntptrace 202.120.2.100
总体思路就是编译出新的NTP服务程序,然后替换掉原有的(做好备份,方便回退)
原文地址http://soft.dog/2015/11/10/ntp-upgrade/