如何监听键值变化
etcd 键监听指南
先决条件
监听键
watch 以接收后续变更的通知:
etcdctl watch $KEY [$END_KEY]选项
-i, --interactive[=false]: interactive mode
--prefix[=false]: watch on a prefix if prefix is set
--rev=0: Revision to start watching
--prev-kv[=false]: get the previous key-value pair before the event happens
--progress-notify[=false]: get periodic watch progress notification from server继承自父命令的选项
--endpoints="127.0.0.1:2379": gRPC endpoints示例

etcdctl --endpoints=$ENDPOINTS watch stock1
etcdctl --endpoints=$ENDPOINTS put stock1 1000
etcdctl --endpoints=$ENDPOINTS watch stock --prefix
etcdctl --endpoints=$ENDPOINTS put stock1 10
etcdctl --endpoints=$ENDPOINTS put stock2 20
最后修改 2026年9月8日 · refactor(docs): move component documentation under /docs (f643529)
本页改编自 etcd v3.7 documentation (v3.7, commit 8245979),Copyright 2013-present etcd Authors,依 CC BY 4.0 授权,详见归属声明与修改历史。
本页为译文,如有出入以原文为准。