我应该如何pipe理和解决NTP问题?

一段时间以来,我一直在与我公司的networking中的一些NTP问题斗争,我很难理解命令与服务的结合。 例如:在服务器的/etc/ntp.conf有一行:

 server IP_of_internal_ntp_server 

但是当我inputntpq -p它会显示一个不同的服务器IP。 另外,经过一段时间,我发现重新同步服务器与NTP服务器的时间的方式是这样的:

 service ntpd stop && ntpdate ntp_server && service ntpd start 

我的问题是:

  1. ntpd守护进程和ntpdate命令是否一起工作? 如果是的话,为什么我必须停止ntpd守护进程才能同步ntp
  2. ntpq -p命令受到/etc/ntp.conf文件的影响吗?
  3. 在某些服务器上,Nagios NTP检查正在返回NTP OK: Offset unknown在所有其他服务器上的NTP OK: Offset unknown我得到正确的响应,所有其他服务器configuration完全相同,为什么?

谢谢,伊泰

编辑#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输出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并注释掉了你所提到的/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 ~]# 

如果你想让NTP服务器可靠地做任何事情,你不需要对自己的时钟的可靠性说谎; 线

 server 127.127.1.0 

 fudge 127.127.1.0 stratum 10 

做到这一点,它看起来像摆脱他们有固定的东西。

至于在使用ntpdate强制执行ntpd之前停止ntpd ,我的理解是内核中有一个用于播放时钟的结构,而ntpd坐在它上面(为了在需要的时候扭曲时间)。 只要它在那里, ntpdate无法查看; 所以有必要将它从图片中剔除,以便ntpdate正常工作。

但我的理解严格来自运行池服务器; 我不是内核程序员,可能是错误的。