Zookeeper如何同步集群中的时钟 [英] How does Zookeeper synchronize the clock in the cluster

查看:69
本文介绍了Zookeeper如何同步集群中的时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 Zookeeper 文档:

ctime从 epoch 开始,这个 znode 被创建的时间(以毫秒为单位).

ctime The time in milliseconds from epoch when this znode was created.

mtime上次修改此 znode 时距 epoch 的时间(以毫秒为单位).

mtime The time in milliseconds from epoch when this znode was last modified.

我认为 Zookeeper 以某种方式同步了 ZK 集群中所有节点的(内部)真实时钟,以使时间戳保持一致,无论客户端连接到哪个节点.是这样吗?如果是,它是如何工作的?

I presume that Zookeeper somehow syncs the (internal) real clock of all the nodes in the ZK cluster in order the time stamps to be consistent regardless of the node where the client connects. Is that so? If yes, how does it work?

我发现的是:

实时

ZooKeeper 根本不使用实时时间或时钟时间,除了在 znode 创建和 znode 修改时将时间戳放入 stat 结构中.

ZooKeeper doesn't use real time, or clock time, at all except to put timestamps into the stat structure on znode creation and znode modification.

也就是说,只要有可能,它就会使用逻辑时间,但它不会说明实际时钟是否同步.

That is, it uses logical time whenever it's possible, but it doesn't say if real clock is synced or not.

谢谢!

推荐答案

没有,真正的时钟只在 ctime 和 mtime 中使用.当前leader使用真实时钟在请求中设置了一个TxnHeader,然后作为zNode的ctime和mtime.

No, the real clock is only used in ctime and mtime. The current leader used the real clock to set a TxnHeader in the request, and then used as the ctime and mtime of zNode.

这篇关于Zookeeper如何同步集群中的时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆