Files
Distributed-Prometheus/edge-agent/run-edge-local.sh
Super User 95a09fd9d8 完善中央与边缘部署、远程写入与监控文档
- 增加中央与边缘完整配置和部署脚本
- 引入 VictoriaMetrics 数据源与 remote_write 故障排查说明
- 新增 edge-agent 配置脚本、ONVIF 自建 exporter 与 ping 监控示例

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-25 04:24:40 -05:00

39 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 本机同机部署边缘:中央与边缘在同一台机器时,一键配置并启动边缘
# 用法: ./run-edge-local.sh
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "=== 本机同机部署边缘(中央与边缘在同一台机器)==="
echo ""
# 确保有 .env
if [ ! -f ".env" ]; then
[ -f "env.example" ] && cp env.example .env || { echo "❌ 缺少 env.example"; exit 1; }
fi
# 指向本机中央 VictoriaMetrics容器内用 host.docker.internal 访问宿主机)
if ! grep -q 'CENTRAL_SERVER_HOST=host.docker.internal' .env 2>/dev/null; then
echo "📝 设置中央服务器为本机 (host.docker.internal:8428)..."
sed -i 's/^CENTRAL_SERVER_HOST=.*/CENTRAL_SERVER_HOST=host.docker.internal/' .env 2>/dev/null || \
echo 'CENTRAL_SERVER_HOST=host.docker.internal' >> .env
grep -q '^CENTRAL_SERVER_PORT=' .env || echo 'CENTRAL_SERVER_PORT=8428' >> .env
sed -i 's/^CENTRAL_SERVER_PORT=.*/CENTRAL_SERVER_PORT=8428/' .env 2>/dev/null || true
echo "✅ 已写入 CENTRAL_SERVER_HOST=host.docker.internal, CENTRAL_SERVER_PORT=8428"
fi
echo ""
echo "请确保中央服务器已在本机运行central-server 已 deploy且 VictoriaMetrics 监听 8428。"
echo "按回车继续启动边缘,或 Ctrl+C 取消..."
read -r
bash deploy.sh
echo ""
echo "💡 本机部署完成后:"
echo " - 边缘 Prometheus UI: http://localhost:9092"
echo " - 在 Grafana 中选择数据源「VictoriaMetrics」可查看边缘上报的数据"