一段时间以来,我一直在努力解决公司网络中的一些NTP问题,我很难理解这些命令是如何与服务结合的。例如:在服务器的/etc/ntp.conf中有一行:
server IP_of_internal_ntp_server但是,当我输入ntpq -p时,它会显示出另一个服务器的IP。此外,通过时间,我了解到重新同步服务器与NTP服务器的时间的方法如下:
service ntpd stop && ntpdate ntp_server && service ntpd start我的问题是:
ntpd守护进程和ntpdate命令一起工作吗?如果是这样的话,为什么我必须停止ntpd守护进程来同步ntp?ntpq -p命令,它是否受到/etc/ntp.conf文件的影响?NTP OK: Offset unknown,而在所有其他服务器中,我得到了正确的响应,所有其他服务器的配置都是相同的,为什么呢?谢谢你,伊泰
编辑#1:/etc/ntp.conf:
driftfile /var/lib/ntp/drift
fudge 127.127.1.0 stratum 10
keys /etc/ntp/keys
restrict 0.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 127.0.0.1
restrict 1.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 2.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict -6 ::1
restrict default kod nomodify notrap nopeer noquery
server 127.127.1.0
server 130.117.52.203 ntpq -p的输出:
[root@nyproxy15 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
38.74.128.71 .INIT. 16 u - 64 0 0.000 0.000 0.000
*LOCAL(0) .LOCL. 10 l 45 64 377 0.000 0.000 0.001
[root@nyproxy15 ~]#请不要理会16层,我知道它需要修复。
编辑2:我编辑了/etc/ntp.conf并注释掉了您提到的行。
[root@nyproxy15 ~]# service ntpd stop ; ntpdate 130.117.52.203 ; service ntpd start
Shutting down ntpd: [ OK ]
30 Sep 08:16:30 ntpdate[31192]: adjust time server 130.117.52.203 offset -0.078324 sec
ntpd: Synchronizing with time server: [ OK ]
Starting ntpd: [ OK ]
[root@nyproxy15 ~]# ntpq -p
localhost.localdomain: timed out, nothing received
***Request timed out
root@nyproxy15 ~]# ps -ef |grep ntp
root 31210 1 0 08:16 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid编辑#3:
现在看来,几分钟后,ntpq -p返回正确的响应:
[root@nyproxy15 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*130.117.52.203 46.4.54.78 3 u 9 64 377 80.633 -9.950 1.420
[root@nyproxy15 ~]#发布于 2014-09-30 08:53:18
如果您想让NTP服务器可靠地执行任何事情,您就不需要向它隐瞒它自己时钟的可靠性;
server 127.127.1.0和
fudge 127.127.1.0 stratum 10这样做,看起来就像把它们处理掉有固定的东西。
至于在强制使用ntpd之前停止ntpdate,我的理解是内核中有一个用于玩时钟的单一结构,而ntpd则坐在它上(以便在需要的情况下扭曲时间)。只要它在那里,ntpdate就无法查看;因此,有必要将其从图片中拿出来,以便ntpdate能够工作。
但我的理解完全来自于运行池服务器;我不是内核程序员,在这一点上可能是错的。
https://serverfault.com/questions/632344
复制相似问题