Skip to content

ZooKeeper

基本信息

属性
版本3.9.3-debian-12
Helm 目录k8s-apps/04-helm/01-zookeeper/
Namespaceyidun-infra
Release 名称zookeeper-yidun
节点标签zookeeper: "true"
客户端端口2181(NodePort)

用途

  • Kafka broker 注册与协调(Kafka 3.x 仍使用 ZooKeeper 模式)
  • 易盾业务服务的配置注册与服务发现

关键配置

yaml
replicaCount: 1     # 单机
# replicaCount: 3   # 集群(自动调整)

heapSize: 1024      # JVM 堆内存 1GB

persistence:
  storageClass: "local-path"
  size: 8Gi          # 数据存储
  dataLogDir:
    size: 8Gi        # 日志存储(建议挂载不同磁盘)

# 允许匿名连接(内网部署,安全可接受)
allowAnonymousLogin: true
auth:
  enabled: false

服务地址

集群内: zookeeper.yidun-infra.svc.cluster.local:2181

yidun-text 配置:
  zookeeper.url: "zookeeper.yidun-infra.svc:2181"

常用运维

bash
# 查看 ZooKeeper 状态
kubectl exec -it zookeeper-yidun-0 -n yidun-infra -- \
  zkServer.sh status

# 连接 ZooKeeper Shell
kubectl exec -it zookeeper-yidun-0 -n yidun-infra -- \
  zkCli.sh -server localhost:2181

# 常用 ZK 命令
ls /                    # 列出根节点
get /services           # 查看服务注册
stat /path              # 查看节点状态

故障排查

bash
# 检查选主状态(集群模式)
kubectl exec -it zookeeper-yidun-0 -n yidun-infra -- \
  echo ruok | nc localhost 2181   # 返回 imok 表示正常

# 查看集群成员
kubectl exec -it zookeeper-yidun-0 -n yidun-infra -- \
  echo mntr | nc localhost 2181 | grep zk_followers

内部使用文档,请勿外传