5.5 KiB
		
	
	
	
	
	
			
		
		
	
	
			5.5 KiB
		
	
	
	
	
	
Nomad 集群 Telegraf 监控部署移交文档
📋 项目概述
任务: 为 Nomad 集群部署基于 Telegraf 的硬盘监控系统 目标: 监控集群所有节点的硬盘使用率、系统性能等指标 监控栈: Telegraf + InfluxDB 2.x + Grafana
🎯 当前完成状态
✅ 已完成的工作
1. 容器运行时迁移
- ch3 节点: ✅ 成功清理 Docker,安装 Podman 4.9.3 + Compose 1.0.6
- ash2e 节点: ✅ 完成 Docker 移除和 Podman 安装
2. Telegraf 监控部署
- 成功运行节点: ash3c, semaphore, master, hcp1, hcp2, hcs (共6个节点)
- 监控数据: 已开始向 InfluxDB 发送数据
- 配置模式: 使用远程配置 URL
3. 监控配置
- InfluxDB URL: http://influxdb1.tailnet-68f9.ts.net:8086
- Token: VU_dOCVZzqEHb9jSFsDe0bJlEBaVbiG4LqfoczlnmcbfrbmklSt904HJPL4idYGvVi0c2eHkYDi2zCTni7Ay4w==
- Organization: seekkey
- Bucket: VPS
- 远程配置: http://influxdb1.tailnet-68f9.ts.net:8086/api/v2/telegrafs/0f8a73496790c000
🔄 待完成的工作
1. 剩余节点的 Telegraf 安装
状态: 部分节点仍需处理 问题节点: ch3, ch2, ash1d, syd
问题描述:
- 这些节点在下载 InfluxData 仓库密钥时失败
- 错误信息: HTTPSConnection.__init__() got an unexpected keyword argument 'cert_file'
- 原因: Python urllib3 版本兼容性问题
解决方案:
已创建简化安装脚本 /root/mgmt/configuration/fix-telegraf-simple.sh,包含以下步骤:
- 直接下载 Telegraf 1.36.1 二进制文件
- 创建简化的启动脚本
- 部署为 telegraf-simple.service
2. 集群角色配置
当前配置:
[nomad_servers]
semaphore, ash2e, ash1d, ch2, ch3 (5个server)
[nomad_clients] 
master, ash3c (2个client)
待处理:
- ash2e, ash1d, ch2 节点需要安装 Nomad 二进制文件
- 这些节点目前缺少 Nomad 安装
📁 重要文件位置
配置文件
- Inventory: /root/mgmt/configuration/inventories/production/nomad-cluster.ini
- 全局配置: /root/mgmt/configuration/inventories/production/group_vars/all.yml
Playbooks
- Telegraf 部署: /root/mgmt/configuration/playbooks/setup-disk-monitoring.yml
- Docker 移除: /root/mgmt/configuration/playbooks/remove-docker-install-podman.yml
- Nomad 配置: /root/mgmt/configuration/playbooks/configure-nomad-tailscale.yml
模板文件
- Telegraf 主配置: /root/mgmt/configuration/templates/telegraf.conf.j2
- 硬盘监控: /root/mgmt/configuration/templates/disk-monitoring.conf.j2
- 系统监控: /root/mgmt/configuration/templates/system-monitoring.conf.j2
- 环境变量: /root/mgmt/configuration/templates/telegraf-env.j2
修复脚本
- 简化安装: /root/mgmt/configuration/fix-telegraf-simple.sh
- 远程部署: /root/mgmt/configuration/deploy-telegraf-remote.sh
🔧 技术细节
Telegraf 服务配置
[Unit]
Description=Telegraf
After=network.target
[Service]
Type=simple
User=telegraf
Group=telegraf
ExecStart=/usr/bin/telegraf --config http://influxdb1.tailnet-68f9.ts.net:8086/api/v2/telegrafs/0f8a73496790c000
Restart=always
RestartSec=5
EnvironmentFile=/etc/default/telegraf
[Install]
WantedBy=multi-user.target
环境变量文件 (/etc/default/telegraf)
INFLUX_TOKEN=VU_dOCVZzqEHb9jSFsDe0bJlEBaVbiG4LqfoczlnmcbfrbmklSt904HJPL4idYGvVi0c2eHkYDi2zCTni7Ay4w==
INFLUX_ORG=seekkey
INFLUX_BUCKET=VPS
INFLUX_URL=http://influxdb1.tailnet-68f9.ts.net:8086
监控指标类型
- 硬盘使用率 (所有挂载点: /, /var, /tmp, /opt, /home)
- 硬盘 I/O 性能 (读写速度、IOPS)
- inode 使用率
- CPU 使用率 (总体 + 每核心)
- 内存使用率
- 网络接口统计
- 系统负载和内核统计
- 服务状态 (Nomad, Podman, Tailscale, Docker)
- 进程监控
- 日志文件大小监控
🚀 下一步操作建议
立即任务
- 
完成剩余节点 Telegraf 安装: cd /root/mgmt/configuration ./fix-telegraf-simple.sh
- 
验证监控数据: # 检查所有节点 Telegraf 状态 ansible all -i inventories/production/nomad-cluster.ini -m shell -a "systemctl is-active telegraf" --limit '!mac-laptop,!win-laptop'
- 
在 Grafana 中验证数据: - 确认 InfluxDB 中有来自所有节点的数据
- 创建硬盘监控仪表板
 
后续优化
- 
设置告警规则: - 硬盘使用率 > 80% 警告
- 硬盘使用率 > 90% 严重告警
 
- 
优化监控配置: - 根据实际需求调整收集间隔
- 添加更多自定义监控指标
 
- 
完成 Nomad 安装: - 在 ash2e, ash1d, ch2 节点安装 Nomad 二进制文件
- 配置集群连接
 
❗ 已知问题
- 
仓库密钥下载失败: - 影响节点: ch3, ch2, ash1d, ash2e, ash3c, syd
- 解决方案: 使用简化安装脚本
 
- 
包管理器锁定冲突: - 多个节点同时执行 apt 操作导致锁定
- 解决方案: 使用 serial: 1 逐个处理
 
- 
telegraf 用户缺失: - 部分节点需要手动创建 telegraf 系统用户
- 解决方案: useradd --system --no-create-home --shell /bin/false telegraf
 
📞 联系信息
移交日期: 2025-09-24 当前状态: Telegraf 已在 6/11 个节点成功运行 关键成果: 硬盘监控数据已开始流入 InfluxDB 优先级: 完成剩余 5 个节点的 Telegraf 安装
备注: 所有脚本和配置文件都已经过测试,可以直接使用。建议按照上述步骤顺序执行,确保每个步骤完成后再进行下一步。