首批通过分布式安全可靠测评,为关键业务系统打造
如何绕过 obd 对于时钟偏差的限制
更新时间:2026-03-11 07:56
适用版本
obd 所有版本,OceanBase 数据库 V4.x 版本。
问题描述
部署 OceanBase 数据库 V4.x 集群要求所有节点的时钟偏差在 2s 以内,使用 obd 部署时已确认节点间的时钟偏差小于 2s,但是启动时提示时钟服务的偏差超过 2s,具体日志内容如下:
[2025-02-26 12:45:40.225] [84bd2642-f3fc-11ef-a914-10517229b76e] [DEBUG] -- xx.xx.xx.xx time delta -1094.303955078125
[2025-02-26 12:45:40.225] [84bd2642-f3fc-11ef-a914-10517229b76e] [ERROR] OBD-2008: Cluster clocks are out of sync, Please enable clock synchronization service
问题原因
考虑到如果集群节点之间的时钟偏差相对较大,后续在集群运行期间可能出现超过要求阈值的情况,会造成集群/服务不可用,所以 obd 会以更严格的阈值进行检查,给系统留有跑偏的缓冲区,便于及时发现问题。
解决方法
如果已经调整了 ntp/chrony 时钟同步服务,通过 obd 启动 OceanBase 集群时仍然报错 Cluster clocks are out of sync。查看 obd 日志显示已经满足小于 2 秒,但是大于 500ms,此时可执行如下命令搜索 obd 中相关配置:
cd ~/.obd/plugins/oceanbase-ce
grep -ri "if times and max(times) - min(times)" *
cd /usr/obd/plugins/oceanbase-ce
grep -ri "if times and max(times) - min(times)" *
当 obd 版本小于 V3.0.0 时,配置内容存在于 start_check.py 文件中;当 obd 版本为 V3.0.0 或之后版本时,配置内容存在于 resource_check.py 文件中。输出示例如下:
3.1.0/resource_check.py: if times and max(times) - min(times) > 200:
4.0.0.0/resource_check.py: if times and max(times) - min(times) > 500:
4.2.1.5/resource_check.py: if times and max(times) - min(times) > 500:
分别修改上面两个目录下,距当前部署的 OceanBase 数据库版本最近版本中的 if times and max(times) - min(times)。举个例子,若当前部署的 OceanBase 数据库版本为 V4.3.5,需修改 4.2.1.5 目录下的文件内容,修改后内容如下:
if times and max(times) - min(times) > 1500
注意
示例中的 1500 单位为毫秒,您需设置一个满足小于 2s,且大于实际查看到的节点间时钟偏差的值,obd 侧才可通过时钟偏差检查。