
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
镜像概述和主要用途
zk-exporter是一款用于将ZooKeeper的mntr统计信息转换为Prometheus格式的导出工具。它能够采集ZooKeeper的关键指标,方便通过Prometheus进行监控和告警。其中,zk_followers、zk_synced_followers和zk_pending_syncs指标仅在集群领导者节点上可用。
核心功能和特性
mntr命令输出转换为Prometheus可识别的指标格式使用场景和适用范围
使用方法和配置说明
1. ZooKeeper配置
从ZooKeeper v3.4.10开始,需要将mntr命令加入白名单。修改ZooKeeper配置文件zoo.cfg:
bashecho "4lw.commands.whitelist=mntr" >> /path/to/zoo.cfg # 重启ZooKeeper使配置生效 /path/to/zookeeper/bin/stop_zookeeper.sh /path/to/zookeeper/bin/start_zookeeper.sh
2. 命令行参数
警告:自v0.1.10版本起,指定目标ZooKeeper主机的参数已变更,使用时请注意。
Usage of zookeeper-exporter: -listen string 监听地址 (默认 "0.0.0.0:9141") -location string 指标路径 (默认 "/metrics") -timeout int 连接ZooKeeper的超时时间(秒)(默认 30) -zk-hosts string ZooKeeper服务器列表,逗号分隔,例如 '10.0.0.1:2181,10.0.0.2:2181' -zk-tls-auth bool 是否启用ZooKeeper TLS客户端认证 (默认 false) -zk-tls-auth-cert string TLS客户端认证证书路径(当-zk-tls-auth为true时必填) -zk-tls-auth-key string TLS客户端认证密钥路径(当-zk-tls-auth为true时必填)
3. 环境变量
| 变量名 | 默认值 | 描述 |
|---|---|---|
| ZK_CONN | - | (必填,否则指标服务器不启动)ZooKeeper节点连接字符串 |
| FLUENTD_ENABLE | - | 是否启用Fluentd日志流 |
| FLUENTD_CONF | - | (启用Fluentd时必填)Fluentd配置文件路径,需挂载到/fluentd/etc/fluent.conf |
| ELASTICSEARCH_HOST | - | (启用日志流到Elasticsearch时必填)Elasticsearch主机 |
| ELASTICSEARCH_PORT | 9200 | Elasticsearch端口 |
| PUSH_MODE | false | 是否启用推送模式,设为true启用 |
| PUSHGATEWAY_URI | - | Prometheus Pushgateway端点(如 http://pushgateway:9091) |
| PUSH_METRICS_CRON | * * * * * | 推送指标的CRON表达式 |
| JOB_NAME | fid-targets | 推送时设置的抓取任务名称 |
| INSTANCE_NAME | $HOSTNAME | 推送时设置的实例名称 |
指标默认在9095端口的
/metrics路径提供 ZKExporter容器需要访问ZooKeeper日志文件:/opt/radiantone/rli-zookeeper-external/zookeeper/logs/zookeeper.log
4. Docker Compose示例
仅指标采集
yamlzkexp-0: image: radiantone/zk-exporter hostname: "zkexp-0" privileged: true environment: ZK_CONN: "zk-0:2181" # ZooKeeper连接字符串 ports: - 9095:9095 # 指标端口 volumes: - zk-0:/opt/radiantone # 挂载ZooKeeper数据目录 networks: zk-net: aliases: - zkexp-0
指标采集+Fluentd(默认Elasticsearch配置)
yamlzkexp-0: image: radiantone/zk-exporter hostname: "zkexp-0" privileged: true environment: ZK_CONN: "zk-0:2181" FLUENTD_ENABLE: "true" # 启用Fluentd FLUENTD_CONF: "/fluentd/etc/fluent.conf" ELASTICSEARCH_HOST: "elasticsearch" # Elasticsearch主机 ELASTICSEARCH_PORT: "9200" # Elasticsearch端口 ports: - 9095:9095 volumes: - zk-0:/opt/radiantone networks: zk-net: aliases: - zkexp-0
指标采集+Fluentd(自定义配置)
yamlzkexp-0: image: radiantone/zk-exporter hostname: "zkexp-0" privileged: true environment: ZK_CONN: "zk-0:2181" FLUENTD_ENABLE: "true" FLUENTD_CONF: "/fluentd/etc/fluent.conf" # 自定义配置路径 ports: - 9095:9095 volumes: - zk-0:/opt/radiantone - ./fluent.conf:/fluentd/etc/fluent.conf # 挂载自定义Fluentd配置 networks: zk-net: aliases: - zkexp-0
推送模式+Fluentd(默认Elasticsearch配置)
yamlzkexp-0: container_name: "zkexp-0" build: . hostname: "zkexp-0" privileged: true environment: PUSH_MODE: "true" # 启用推送模式 PUSHGATEWAY_URI: "http://pushgateway:9091" # Pushgateway地址 ZK_CONN: "zk-0:2181" FLUENTD_ENABLE: "true" FLUENTD_CONF: "/fluentd/etc/fluent.conf" ELASTICSEARCH_HOST: "elasticsearch" ELASTICSEARCH_PORT: "9200"
5. 启动与停止
使用docker-compose管理ZooKeeper集群和exporter:
bash# 启动集群和exporter docker-compose up -d # 停止并清除容器 docker-compose down -v
6. Grafana仪表盘
推荐使用Grafana仪表盘监控指标:ZooKeeper Exporter Dashboard
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务