ntp时间服务器本机的时间如何校准

发布于 2021-11-24 19:32:25 字数 415 浏览 786 评论 12

一般我们的服务器都需要通过网络与网络上的时间服务器进行时间同步,但是当服务器的量变大了以后。我们不可能每台服务器都通过外网去同步时间,这时候我觉得线上也需要一台自己的时间服务器。现在我线上配置了一台时间服务器供其他服务器同步时间,但是当这台服务器时间不准确了,他就不会自动校准时间了,导致内网其他服务器时间都错误。我已经在/etc/ntp.conf做了如下配置:

server ntp.sjtu.edu.cn prefer



这个配置段就是指定你的时间服务器的上游时间服务器,按道理来说我本地的时间服务器也会不间断的和上游时间服务器同步?问题出在哪里了。时间出错是个很可怕的问题。。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

风透绣罗衣 2021-11-30 15:04:14

NTP时统默认用UDP协议的123端口通信,问题可能出在这一默认端口上。这样试试看,你内网那台时间服务器仍旧采用123端口与外网的上游时间服务器对时,在内网中的其它设备采用另一端口与内网时间服务器对时,看能否成功。

梦中楼上月下 2021-11-30 15:03:29

将ntpdate添加到cron任务中吧

青萝楚歌 2021-11-30 13:07:28

将ntpdate添加到cron任务中吧

眉黛浅 2021-11-30 13:02:32

以Ubuntu为例,Ubuntu在开机时会调用/etc/network/if-up.d/ntpdate连接Ubuntu NTP服务器进行时间同步.

手动时间同步:

sudo service ntp stop

sudo ntpdate ntp.ubuntu.com

sudo service ntp start

Ubuntu在运行过程中由守护进程ntpd不断调整,连接配置/etc/ntp.conf里的时间服务器进行时间同步: sudo service ntp status

The ntp daemon ntpd calculates the drift of your system clock and continuously adjusts it, so there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern server this is negligible.

https://help.ubuntu.com/12.04/serverguide/NTP.html

流心雨 2021-11-30 10:24:31

以Ubuntu为例,Ubuntu在开机时会调用/etc/network/if-up.d/ntpdate连接Ubuntu NTP服务器进行时间同步.

手动时间同步:

sudo service ntp stop

sudo ntpdate ntp.ubuntu.com

sudo service ntp start

Ubuntu在运行过程中由守护进程ntpd不断调整,连接配置/etc/ntp.conf里的时间服务器进行时间同步: sudo service ntp status

The ntp daemon ntpd calculates the drift of your system clock and continuously adjusts it, so there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern server this is negligible.

https://help.ubuntu.com/12.04/serverguide/NTP.html

空城仅有旧梦在 2021-11-30 08:22:49

1 对你的服务器来说 ntp.sjtu.edu.cn是否网络可达?

2 网络可达的话手工用ntpdate试试能不能同步~

背叛残局 2021-11-30 01:39:34

1 对你的服务器来说 ntp.sjtu.edu.cn是否网络可达?

2 网络可达的话手工用ntpdate试试能不能同步~

冷默言语 2021-11-28 21:14:07

1 对你的服务器来说 ntp.sjtu.edu.cn是否网络可达?

2 网络可达的话手工用ntpdate试试能不能同步~

为你鎻心 2021-11-28 14:44:58

1 对你的服务器来说 ntp.sjtu.edu.cn是否网络可达?

2 网络可达的话手工用ntpdate试试能不能同步~

无边思念无边月 2021-11-28 12:08:46

按你这样配置,如果系统无法同步上游NTP时间服务器,是否会造成系统无法启动或启动出错?

够钟 2021-11-27 17:32:14

回复
不会的。。

孤檠 2021-11-27 09:03:32

执行ntpstat能够看到当前ntp伺服务器的状态,如下

[root@localhost]# ntpstat 
synchronised to NTP server (202.120.2.100) at stratum 4 
   time correct to within 64 ms
   polling server every 128 s

说明当前ntp伺服务器与上游的伺服器相差在64ms内,每隔128会去校验时间。

但是比方说我们的NTP服务器哪天一不小心重新启动,这个时候伺服务器的时间可能会因为某种问题,时间变的比当前时间快很多或者快很慢,而你的服务器又是开机自动开启ntpd的话,这个时候如果你的/etc/ntpd.conf如果没有注释掉下面2行的话,他刚开始可能由于种种问题会同步本地的时间,而不是直接同步上游的ntp服务器,这样的话就会导致其他客户端时间出错

#server 127.127.1.0     # local clock
#fudge  127.127.1.0 stratum 10

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文