当前位置: 首页 > news >正文

121. 排查 etcd 时间同步问题

Situation 地理位置

etcd is a critical component in Kubernetes environments, serving as the distributed reliable key-value store that holds the cluster's state. Its proper functioning is highly dependent on accurate time synchronisation across all etcd nodes. Even a small clock drift can lead to significant issues, impacting cluster stability and performance.
etcd 是 Kubernetes 环境中的关键组件,作为分布式且可靠的键值存储,保存集群的状态。 其正常工作高度依赖于所有 etcd 节点间的时间同步准确。即使是小的时钟漂移也可能引发重大问题,影响集群的稳定性和性能。

Time synchronisation issues in etcd can manifest in various ways, often leading to a cascade of errors throughout your cluster. Common symptoms include:
etcd 中的时间同步问题可能以多种方式表现出来,常常导致整个集群中出现连锁错误。常见症状包括:

  • High Clock Drift errors in etcd logs:You'll see warnings like"prober found high clock drift".
    etcd 日志中的高时钟漂移错误:你会看到类似"prober found high clock drift"的警告。
  • Slow etcd requests:Messages such as"apply request took too long"or"waiting for ReadIndex response took too long"indicate that etcd operations are being delayed, often due to inconsistencies between nodes. While these kinds of messages can also indicate other etcd issues, they will commonly be included when a time synchronisation error is present.
    慢速 etcd 请求:诸如“应用请求耗时过长”等消息,或"waiting for ReadIndex response took too long"表明 etcd 操作被延迟,通常是由于节点间的不一致。虽然这类消息也可能提示其他 etcd 问题,但当存在时间同步错误时,通常会包含这些消息。
  • Kubernetes API Server timeouts:Thekube-apiservermight struggle to connect to etcd, resulting inhttp: Handler timeouterrors.
    Kubernetes API 服务器超时:kube-apiserver可能难以连接 etcd,导致http: Handler 超时错误。
  • Unhealthy etcd nodes:You'll see your etcd nodes as unhealthy or flapping (losing and regaining connection).
    不健康的 etcd 节点:你会看到你的 etcd 节点不健康或颤动(连接断开和恢复)。
  • Raft misalignment:Inconsistent Raft indexes among etcd members.
    筏子错位:ETCHD 成员间的筏子指数不一致。
Resolution 结局
In order to solve a time synchronisation issue, you can follow these steps:
为了解决时间同步问题,你可以按照以下步骤操作:
Check the current time and synchronisation status on all your etcd nodes:
检查所有 etcd 节点当前的时间和同步状态:
  • Check current time: 查看当前时间:

    date +"%T.%N"

    Execute this command simultaneously on all etcd nodes to quickly spot any significant differences. Even differences of a few seconds can be critical for etcd.
    同时对所有 etcd 节点执行此命令,以快速发现任何显著差异。即使是几秒钟的差异,对 ETC 来说也可能至关重要。

  • Check the status of your NTP client.E.g., forchrony:
    检查你的 NTP 客户状态。例如,对于时间性

    timedatectl chronyc sources list chronyc tracking

Based on your verification, identify potential clock misalignments, and fix the issue:
根据你的验证,识别潜在的时钟错位,并解决问题:

  • Review your NTP configuration:Examine/etc/chrony.conf(for chrony) or/etc/ntp.conf(for ntpd) on each etcd node. Ensure that the configured NTP servers are correct and reachable. It's recommended to use reliable and accessible NTP sources.
    检查你的 NTP 配置:在每个 etcd 节点上检查/etc/chrony.conf(chrony)或/etc/ntp.conf(用于 ntpd)。确保配置好的 NTP 服务器正确且可访问。建议使用可靠且可访问的 NTP 资源。
  • Check Firewall Rules:Verify that UDP port 123 is open in your firewall configuration on all etcd nodes to allow NTP traffic to and from your configured time servers.
    检查防火墙规则:确认所有 ETC 节点的防火墙配置中 UDP 123 端口是否开放,以便允许 NTP 流量往返你配置的时服务器。

Once you've corrected the configuration, force the NTP client to resynchronize the time.
一旦你纠正了配置,强制 NTP 客户端重新同步时间。

sudo systemctl restart chronyd

Important:When restarting the time synchronisation service, it's generally safer to do itone etcd node at a time. While a temporary clock adjustment might occur, restarting the service on all nodes simultaneously could introduce further instability if a significant time jump occurs across the entire etcd cluster at once.
重要提示:重启时间同步服务时,通常一次处理一个 etcd 节点更安全。虽然可能会进行临时时钟调整,但如果整个 ETCHD 集群同时发生显著时间跳跃,所有节点同时重启服务可能会带来进一步的不稳定性。

After ensuring that time synchronisation is correct on all etcd nodes, verify the health of your etcd cluster and monitor the etcd logs for any recurring "high clock drift" or "took too long" errors. These should disappear once the time synchronisation is stable.
在确保所有 etcd 节点的时间同步正确后,检查你的 etcd 集群健康状况,并监控 etcd 日志中是否有反复出现的“高时钟漂移”或“耗时过长”错误。一旦时间同步稳定,这些问题应该会消失。

Cause 病因

The primary cause of time synchronisation issues on etcd nodes is often a misconfigured or non-functional NTP (Network Time Protocol) client, such aschronyorntpd. Specific problems can include:
etcd 节点时间同步问题的主要原因通常是配置错误或无法正常工作的 NTP(网络时间协议)客户端,如chronyntpd。具体问题可能包括:

  • Incorrect NTP Server Configuration:Thechrony.conforntp.conffile might point to incorrect or unreachable NTP servers.
    NTP 服务器配置错误:chrony.confntp.conf文件可能指向错误或无法访问的 NTP 服务器。
  • Firewall Rules:Necessary firewall rules (e.g., UDP port 123 for NTP) might be missing, preventing the nodes from reaching the configured time servers.
    防火墙规则:必要的防火墙规则(例如 NTP 的 UDP 端口 123)可能缺失,导致节点无法到达配置的时服务器。
  • Network Connectivity Issues:General network problems can also prevent NTP synchronisation.
    网络连接问题:一般网络问题也可能阻碍 NTP 同步。
Additional Information 附加信息
Environment 环境

An RKE or RKE2 cluster with multiple etcd nodes.
一个带有多个 etcd 节点的 RKE 或 RKE2 集群。

访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

http://www.jsqmd.com/news/609798/

相关文章:

  • 如何使用Google Search Console提高SEO排名
  • Codex 和 OpenClaw,到底差在哪?
  • 精密模具配件的工艺标准与交付体系:技术实践分析 - 品牌企业推荐师(官方)
  • 别再手动抄表了!手把手教你用昆仑通态MCGS实现历史报警数据自动导出CSV
  • 上下文工程的学术前沿:最新研究成果与未来发展方向
  • 基于STM32LXXX的数字电位器(TPL0102-100RUCR)驱动应用程序设计
  • 智能资源下载工具:突破平台限制的全方位资源获取解决方案
  • 紧急预警:.NET 9 RC2已移除旧版LowCodeProvider——所有基于.NET 8低代码框架的项目须在2024年11月30日前完成迁移,否则将触发运行时降级熔断
  • 远红外发热纱线哪家技术强?4项核心指标帮你筛选靠谱厂家 - 品牌企业推荐师(官方)
  • 洁净车间PLC数据采集远程监控系统方案
  • YOLOv8在智慧零售场景的应用:顾客与商品检测案例
  • LangGraph 容错机制设计:节点降级+流程跳转+异常捕获
  • 2025AAAI顶会图像拼接算法实战指南(CMake+VS2019):从源码编译到Object-level几何结构保持
  • 2026年GEO技术哪家强?TOP5企业实力大揭秘! - 品牌企业推荐师(官方)
  • 瀚沺信用协办2025“匠技丰台”信用管理师职业技能竞赛,助力行业人才选拔 - 品牌企业推荐师(官方)
  • 智能匹配技术:重新定义Illustrator设计效率提升新范式
  • 告别DLL地狱:在VS2022和Qt Creator中优雅集成vcpkg管理的osgEarth库
  • 效率对比:OpenClaw原生操作vsQwen3.5-9B增强版任务执行
  • AI 编程工具 + Skills+MCP+Tools 垂直领域落地全案:从技术基建到业务跃迁
  • 博客论坛源码_个人博客_Discuz/QZONE 论坛源码
  • CefFlashBrowser:拯救Flash游戏的终极方案,你的童年记忆有救了!
  • JPG文件结构解析:从WinHex十六进制数据到实际图片属性的完整指南
  • 怕踩坑!5家国际专业光变UV变色纱线销售厂家良心推荐 - 品牌企业推荐师(官方)
  • 港口淡水罐远程监控物联网系统方案
  • 收藏!Claude Code源码泄露,12个核心Agentic设计模式助你快速上手大模型开发!
  • 你还在用GameObject写FPS游戏?:3个关键Job System重构案例,让射击手感延迟从16ms压至4.2ms
  • 实时行情系统设计:从协议选择到高可用架构,再到数据源选型馗
  • 养虾日记-OpenClaw多Agent飞书实战
  • 2026就业新风口:AI、新能源、半导体领跑高薪时代,掌握这些技能让你年薪百万!
  • 大模型入门必看:Transformer与MoE核心解析,小白也能轻松收藏学习!