系统学习 DevOps 学习路径:从版本控制到可观测与供应链

consul

HashiCorp Consul 服务发现与配置

补充说明

consul 提供服务注册、健康检查、KV 存储、服务网格和 ACL。它通常以 agent 形式运行,生产环境需要集群、加密和 ACL。

常用示例

consul agent -dev
consul members
consul catalog services
consul kv put app/config '{"debug":false}'
consul kv get app/config
consul services register service.hcl
consul snapshot save backup.snap
consul snapshot restore backup.snap
consul acl bootstrap
consul connect envoy -sidecar-for web

易错点与排错

相关命令

参考链接

读完自测

合上页面,先回答,再展开对照。

  1. 为什么不能用 consul agent -dev 跑生产?
  2. Consul server 节点数量为什么建议 3 或 5 个?
  3. KV 中的重要配置为什么需要外部备份?
答案
  1. -dev 只适合本地实验,数据不持久,不能用于生产。
  2. 需要保持 quorum;3 或 5 个节点能满足多数派,偶数没有额外收益。
  3. KV 没有版本历史,误改或丢失后无法回滚,重要配置要外部备份。
微信小程序码:扫码打开命令速查小程序

小程序版

微信扫码,随时查命令