跳转到内容

运维 Runbook

本文档基于 Enterprise New 离线应用。

  1. 在部署包根目录运行以下命令:
    Terminal window
    ./bin/verify.sh --site config/site.conf
    ./bin/smoke-business-emqx.sh --site config/site.conf
  2. 确认以下项目:
    • 3 台 Swarm 节点均为 Ready
    • APP VIP /healthz/readyz 返回 200
    • DB VIP:5432 可访问。
    • PostgreSQL primary、standby 和 witness 拓扑正常。
    • backendredisemqxsourcefloweventflowmarimoopcua-server 都运行在活动应用节点上。
  1. 在活动应用节点上运行以下命令:

    Terminal window
    cd /opt/tier0-enterprise/tier0-deploy
    bash bin/compose.sh ps
    bash bin/compose.sh logs --tail=200 backend
    curl -fsS http://127.0.0.1:8088/healthz
    curl -fsS http://127.0.0.1:8088/readyz
  2. 健康检查解读:

    • healthz 失败:先检查 backend 进程、镜像和容器日志。
    • readyz 失败:同时检查 DB VIP、Redis 和数据库迁移日志。
    • 首页可访问但无法登录:确认 .env 中的 ADMIN_INITIAL_PASSWORD,然后检查 backend IAM migration 日志和用户表。不要只根据 HTTP 端口判断部署成功。
Terminal window
nc -vz <APP_VIP> 1883
nc -vz <APP_VIP> 8883
nc -vz <APP_VIP> 8083
nc -vz <APP_VIP> 8084
nc -vz <APP_VIP> 4840

在数据库节点上运行:

Terminal window
systemctl status tier0-postgresql
systemctl status tier0-repmgrd
sudo -iu postgres psql -Atqc 'select pg_is_in_recovery();'
sudo -iu postgres /usr/local/bin/repmgr -f /etc/repmgr.conf cluster show
  • pg_is_in_recovery=false 表示 primary。
  • pg_is_in_recovery=true 表示 standby。
  • DB VIP 只能位于当前 primary 上。
  • 如果 standby 复制中断,或 witness 报告上游错误,先保护现场。不要直接重新运行完整部署。
  1. 测试前,记录当前持有 VIP 的节点并验证:

    Terminal window
    curl -fsS http://<APP_VIP>/healthz
    curl -fsS http://<APP_VIP>/readyz
  2. 停止当前 VIP 节点上的 keepalived 后,确认 VIP 被其他应用节点接管,然后重新测试两个 URL。HAProxy backend 指向活动应用节点的 8088/TCP,因此三台应用节点都必须能访问活动节点的 8088 端口。

  3. 恢复 keepalived 后,再次运行 verify.sh 和 smoke checks。演练期间不要停止活动应用容器。

故障演练前,创建备份并确认复制健康:

Terminal window
./bin/backup-db.sh --site config/site.conf

停止当前 primary 上的 tier0-postgresql 后,观察 repmgr 提升 standby,并确认 DB VIP 接管。目标 RTO 为 2 分钟内。同架构历史测试约为 59-64 秒。

  • 备份:

    Terminal window
    ./bin/backup-db.sh --site config/site.conf
  • 恢复:

    Terminal window
    ./bin/restore-db.sh --site config/site.conf --restore-file /backup/tier0-db/postgres-YYYYmmddTHHMMSS.dump
Terminal window
./full-cleanup.sh --env install.env --yes
./install.sh --auto --yes
Terminal window
cd /opt/tier0-enterprise/tier0-deploy
bash bin/compose.sh logs --tail=300 backend
bash bin/compose.sh ps
Terminal window
cd /opt/tier0-enterprise/tier0-deploy
bash bin/compose.sh logs --tail=200 emqx
Terminal window
systemctl status tier0-repmgrd
tail -100 /var/log/repmgr/repmgr.log
sudo -iu postgres psql -Atqc 'show shared_preload_libraries;'
Terminal window
./bin/verify-materials.sh