我试图在我的机器上configurationNTP,但似乎我设置的参数没有被系统读取。 下面是我的/etc/ntp.conf文件。 (我应用了最基本的configuration来消除其他问题)
server 10.45.68.47 server 127.0.0.1
设置完上述configuration之后,我通过执行以下操作重新启动ntpd进程:
service ntpd restart
然后我得到以下输出:
Shutting down ntpd: [ OK ] ntpd: Synchronizing with time server: [FAILED] Starting ntpd: [ OK ]
而且,我可以在/var/etc/messages看到以下内容:
Apr 2 10:54:07 hsystem1a ntpd[21067]: ntpd exiting on signal 15 Apr 2 10:54:07 hsystem1a ntpdate[21537]: can't find host ntpServer1 Apr 2 10:54:07 hsystem1a ntpdate[21537]: can't find host ntpServer2 Apr 2 10:54:07 hsystem1a ntpdate[21537]: no servers can be used, exiting
所以看起来ntpServer1和ntpServer2是从某处读取的,而不是在/etc/ntp.confconfiguration的IP。
注 :我在机器上完成init 6以防万一。
更新似乎目标服务器是可达的,但它不同步。 我知道,如果同步成功,那么“*”应该出现在服务器名称附近:
remote refid st t when poll reach delay offset jitter ============================================================================== omap 127.0.0.1 7 u 50 64 377 0.269 -21536. 4.813
在Red Hat上,当您执行service ntpd restart时,会发生一些事情。
ntpd停止 ntpdate来设置初始时间。 这是因为默认情况下, ntpd不会将系统时间调整超过某个阈值。 ntpdate会使用指定的时间服务器设置一次性的时间。 只要ntpd未运行,您可以使用ntpdate 10.45.68.47手动执行此操作。 ntpd再次启动 ntpd的服务器在/etc/ntp.conf中指定,但ntpdate从一个名为/etc/ntp/step-tickers的文件中取得它们。 如果你在/etc/init.d查看ntpd脚本,你会注意到ntpdate使用这个文件(如果它是空的,跳过ntpdate步骤)。 你可以把你的时间服务器放在这里:
server 10.45.68.47
ntpdate将使用它们来设置初始时间。
顺便说一句,你不应该有本地主机作为时间服务器。 使用本地服务器,也许从ntp池项目的一些服务器。 确保它们在地理位置上靠近您以获得最佳效果。 此外,我会重新设置默认的红帽configuration,因为它有一些合理的默认设置,即不允许其他服务器在您的服务器上设置时间。
你显然正在使用Debian。
默认configuration选项在/etc/default/<daemon-name> 。
编辑:好吧,不是Debian 🙂
简单的事实是,您不能在没有端口冲突的同一台计算机上运行ntpdate和ntpd – ntpd在UDP 123上侦听 ,而ntpdate在UDP 123上发送 。
如果不连接到其他时间服务器(源),则无法运行ntp服务器。