大家是如何解决 Linux 下的时间问题的?

2014-07-25 10:28:05 +08:00
 itsjoke
Linux下面有二个时间,一个系统时间,一个Bios时间
随着系统运行的时间越长,系统时间与"真实"时间相差越来越大
由于业务的原因,不能进行同步等操作,大家有没有遇到这样的问题?
请教大家是如何解决这样的呢?
[root@113 ~]# date
Fri Jul 25 10:12:14 CST 2014
[root@113 ~]# clock
Fri 25 Jul 2014 10:17:52 AM CST -0.031876 seconds
6557 次点击
所在节点    Linux
33 条回复
tjmao
2014-07-25 13:34:45 +08:00
无补偿的晶振,误差在几十到几百ppm。计算机的钟不够准,我都不敢不开ntp服务。这项服务,在Debian和Ubuntu发行版里默认处于开启状态。默认不安装ntp的发行版,都是极其不靠谱的发行版。

内网时间同步,用ptp协议。与全世界同步,用ntp协议。

另外就是好多人校正时间采用ntpdate(8)的方式,不知道是从哪里看到这么用的。难道是RH的培训材料?

@dorentus 刚启动服务时,ntpd也会产生一次时钟跳变。启动后,不会出现高至10s的偏差,除非晶振坏了。
itsjoke
2014-07-25 13:37:53 +08:00
@sumu
@yangqi
@dorentus
@tititake
@rrfeng
感谢各位,现在还无法判断用ntpd是否可行,只有新建集群的时候测试了
wzxjohn
2014-07-25 13:48:34 +08:00
@itsjoke 还有从架构上无法同步时间的集群???这么牛逼。。。
itsjoke
2014-07-25 14:36:18 +08:00
@wzxjohn
是的,集群中有控制器,依赖于时间
刚才测试修改时间,直接导致控制器认为主机脱离集群
itsjoke
2014-07-25 14:45:32 +08:00
@tjmao
求科普...
itsjoke
2014-07-25 15:10:04 +08:00
@dorentus
翻了一下man
貌似只有一个同步的时间超过1000S的告警
不知道说的小粒度是如何实现的
wzxjohn
2014-07-25 15:28:44 +08:00
@itsjoke 所以说你整个集群的时间都是错的?!Orz给跪了。。。集群中居然不放时间同步服务器。。。
dorentus
2014-07-25 15:42:18 +08:00
@itsjoke 小粒度更新是 ntpd 的默认行为啊。
itsjoke
2014-07-25 16:47:15 +08:00
@dorentus
感谢
-x Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold. This option sets the threshold to 600 s, which is well
within the accuracy window to set the clock manually. Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
Thus, an adjustment as much as 600 s will take almost 14 days to complete. This option can be used with the -g and -q options. See the tinker command for other options. Note: The kernel time disci-
pline is disabled with this option.
panzhc
2014-07-25 22:23:01 +08:00
ntpd,关键是平滑的。
pfitseng
2014-07-25 22:34:43 +08:00
上时间同步设备,暂停集群,同步。和运营确定好方案先。
likuku
2014-07-26 01:21:51 +08:00
推荐阅读:

RTC 与 NTP - delphij's Chaos : https://blog.delphij.net/2010/08/rtc-ntp.html

AsiaBSDCon上说OpenBSD的sensor framework的时候的一个观点 [为什么不用ntpdate,而要用ntpd] - delphij's Chaos : https://blog.delphij.net/2007/03/asiabsdconopenb.html
Owenjia
2014-07-26 02:10:22 +08:00
是不是编译内核的时候 rtc 没选啊~~~一般不会相差特别大吧~~~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/124413

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX