运维 Runbook
本文档基于 Enterprise New 离线应用。
- 在部署包根目录运行以下命令:
Terminal window ./bin/verify.sh --site config/site.conf./bin/smoke-business-emqx.sh --site config/site.conf - 确认以下项目:
- 3 台 Swarm 节点均为
Ready。 APP VIP /healthz和/readyz返回200。DB VIP:5432可访问。- PostgreSQL primary、standby 和 witness 拓扑正常。
backend、redis、emqx、sourceflow、eventflow、marimo和opcua-server都运行在活动应用节点上。
- 3 台 Swarm 节点均为
-
在活动应用节点上运行以下命令:
Terminal window cd /opt/tier0-enterprise/tier0-deploybash bin/compose.sh psbash bin/compose.sh logs --tail=200 backendcurl -fsS http://127.0.0.1:8088/healthzcurl -fsS http://127.0.0.1:8088/readyz -
健康检查解读:
healthz失败:先检查 backend 进程、镜像和容器日志。readyz失败:同时检查 DB VIP、Redis 和数据库迁移日志。- 首页可访问但无法登录:确认
.env中的ADMIN_INITIAL_PASSWORD,然后检查 backend IAM migration 日志和用户表。不要只根据 HTTP 端口判断部署成功。
协议入口检查
Section titled “协议入口检查”nc -vz <APP_VIP> 1883nc -vz <APP_VIP> 8883nc -vz <APP_VIP> 8083nc -vz <APP_VIP> 8084nc -vz <APP_VIP> 4840在数据库节点上运行:
systemctl status tier0-postgresqlsystemctl status tier0-repmgrdsudo -iu postgres psql -Atqc 'select pg_is_in_recovery();'sudo -iu postgres /usr/local/bin/repmgr -f /etc/repmgr.conf cluster showpg_is_in_recovery=false表示 primary。pg_is_in_recovery=true表示 standby。- DB VIP 只能位于当前 primary 上。
- 如果 standby 复制中断,或 witness 报告上游错误,先保护现场。不要直接重新运行完整部署。
APP VIP 故障切换
Section titled “APP VIP 故障切换”-
测试前,记录当前持有 VIP 的节点并验证:
Terminal window curl -fsS http://<APP_VIP>/healthzcurl -fsS http://<APP_VIP>/readyz -
停止当前 VIP 节点上的
keepalived后,确认 VIP 被其他应用节点接管,然后重新测试两个 URL。HAProxy backend 指向活动应用节点的8088/TCP,因此三台应用节点都必须能访问活动节点的 8088 端口。 -
恢复
keepalived后,再次运行verify.sh和 smoke checks。演练期间不要停止活动应用容器。
DB Primary 故障切换
Section titled “DB Primary 故障切换”故障演练前,创建备份并确认复制健康:
./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
./full-cleanup.sh --env install.env --yes./install.sh --auto --yesBackend 启动失败
Section titled “Backend 启动失败”cd /opt/tier0-enterprise/tier0-deploybash bin/compose.sh logs --tail=300 backendbash bin/compose.sh psEMQX 启动失败
Section titled “EMQX 启动失败”cd /opt/tier0-enterprise/tier0-deploybash bin/compose.sh logs --tail=200 emqxrepmgrd 反复重启
Section titled “repmgrd 反复重启”systemctl status tier0-repmgrdtail -100 /var/log/repmgr/repmgr.logsudo -iu postgres psql -Atqc 'show shared_preload_libraries;'物料校验失败
Section titled “物料校验失败”./bin/verify-materials.sh