在没有互联网连接的情况下保持服务器之间的时间同步
我在 LAN 上有 5 台服务器,没有 Internet 连接。我需要他们保持时钟同步。
我可以将它们配置为 NTP 对等体,并为其中一个的本地时钟设置较高的层数。这样,其他四个就会与那个时钟同步。
我真正想要的是,出于鲁棒性和精确性的原因,他们同意使用所有 5 个本地时钟的时间(即进行某种平均)。可以用NTP吗?
PS:我不想想要使用外部时钟源。
编辑:并且没有 NTP 功能之外的脚本,这只会使精度变得更差:)
I have 5 servers on a LAN without Internet connection. I need them to keep the clock in sync among them.
I could configure them as NTP peers, and set a high stratum for the local clock of one of them. In this way, the other four would sync with that clock.
What I actually want, is them to agree on a time using all of the 5 local clocks (i.e. doing some kind of average), for reasons of robustness and precision. Is it possible with NTP?
PS: I do not want to use an external clock source.
EDIT: and no scripting outside NTP features, that could only make precision worse :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果平均 5 个漂移时钟,您得到的唯一结果就是另一个更难校正的漂移时钟。不会更精确。 NTP 使用多个服务器来提高精度,因为它考虑了网络延迟。由于您的所有系统都位于快速本地网络上,因此您只需要一台服务器。
设置两个系统作为 NTP 服务器,一个作为主服务器,如果您觉得需要,还可以将一个作为备份服务器。让所有其他系统与它们同步。这比时钟平均解决方案更容易设置,并且您不必开发任何疯狂的脚本。
If you average 5 drifting clocks, the only thing you get is another drifting clock that's harder to correct. It won't be more precise. NTP uses multiple servers to increase precision because it takes network latency into account. Since all your systems are on a fast local network, you just need one server.
Set up two systems to be NTP server, one a primary, and if you feel the need, one a backup. Have all other systems synchronize to them. This will be significantly easier to set up than the clock-averaging solution, and you won't have to develop any crazy scripts.
您可以让其中一台监听每台计算机的时间,执行平均值,将平均值设置为它自己的时间,然后向所有其他计算机广播该时间。不过,这似乎有点过分。
You might be able to have one of them listen for the times from each computer, perform an average, set the average as it's own time, and broadcast that time for all the other computers. It seems a little excessive, though.
您可以将其中一个设置为 ntp 服务器,它将在本地网络上广播其时间,并将其他服务器设置为从属服务器以侦听本地网络
编辑:
我错过了平均部分。好吧,在这种情况下,您可能可以在本地服务器上编写一个脚本来收集所有从属服务器的时间,获取平均值并用该值更新自己的时间。
在这种情况下,您甚至可能想摆脱 ntp,只使用脚本来更新所有服务器上的时间
you can set up one of them as ntp server which will broadcast its time on the local network and the others as slaves to listen on the local network
edit:
I missed the average part. well, in that case, you can probably write a script on the local server to collect times from all the slaves get the average and update own time with that value.
You may even want to get rid of ntp in that case and just use the script to update time on all the servers
我希望我能给出一个明确的建议,但我对你的环境还不够了解。无论做什么,你都可能会做某种脚本功夫。
如果是 unix/linux,我会为每个人设置 SSH 授权密钥,以轮询彼此的
date +%s
命令(以获取纪元),用 awk 或其他东西平均这些时间,然后设置机器自己的本地日期。或者,也许让一台权威机器检查同一庄园中每个人的时间,对其进行平均,然后将其自身和所有其他主机配置为该平均值,可能会更安全(且可靠)。
在 Windows 上,您可能会研究 VBScript 和 WMI。
编辑:
如果有人的时钟偏离平均水平,你可能会遇到一些奇怪的问题,我猜大约有一半的人会;)。未来的时间戳可能会相当奇怪。您可以决定需要多长时间进行一次同步。
I wish I could give a definitive proposal, but I don't know enough about your environment. No matter what you'll likely be doing some sort of script kung fu.
If it's unix/linux I would set everyone up with SSH authorized keys to poll each others'
date +%s
command (to get the epoch), average those times with awk or something, and then set the machine's own local date.Or perhaps it would be more secure (and reliable) to have one authoritative machine check everyone's time in the same manor, average it, and then provision itself and every other host to that average.
On Windows you'll probably be looking into VBScript and WMI.
EDIT:
You may run into some weird problems if anyone's clock drifts forward from the average and my guess is about half of them will ;). Future timestamps can be rather strange. It will be up to you to determine how frequently this synchronization will need to occur.