生产环境上线检查清单
将 coomia-dip 从开发环境迁移到生产环境,不仅仅是"换个配置"那么简单。生产环境需要考虑高可用、安全加固、性能调优、监控告警、备份恢复等方方面面。本教程提供一份全面的上线检查清单,帮助你系统性地完成生产部署准备。
Coomia发布于 2026年1月29日8 分钟阅读
分享本文Twitter / X
“系列:S12 开发者教程 · 第 19 篇 | 难度:中级 | 阅读时间:15 分钟
生产环境上线检查清单
#引言
将 coomia-dip 从开发环境迁移到生产环境,不仅仅是"换个配置"那么简单。生产环境需要考虑高可用、安全加固、性能调优、监控告警、备份恢复等方方面面。本教程提供一份全面的上线检查清单,帮助你系统性地完成生产部署准备。
#1. 基础设施检查
#1.1 硬件与资源
| 组件 | 最低配置 | 推荐配置 | 高可用配置 |
|---|---|---|---|
| Control Layer | 4C/8G/50G | 8C/16G/100G | 3 节点 |
| Data Layer | 8C/32G/200G | 16C/64G/500G | 3 节点 |
| Intelligence Layer | 4C/16G/50G | 8C/32G/100G | 2 节点 |
| Doris FE | 4C/8G/50G | 8C/16G/100G | 3 节点 |
| Doris BE | 8C/32G/500G | 16C/64G/1T | 3+ 节点 |
| Kafka | 4C/8G/200G | 8C/16G/500G | 3 节点 |
| Temporal | 4C/8G/50G | 8C/16G/100G | 3 节点 |
#1.2 网络
- 内部服务间网络延迟 < 1ms(同数据中心)
- gRPC 端口(50051-50059)在服务间可达
- 外部 API 通过负载均衡器暴露(Nginx/Kong)
- TLS 证书已配置(Let's Encrypt 或企业 CA)
- DNS 记录已配置
#2. 安全加固
#2.1 认证与授权
- OAuth2/OIDC Provider 已集成(Keycloak/Auth0/企业 AD)
- JWT Token 签名密钥已生成并安全存储
- API Token 轮换策略已制定(建议 90 天)
- RBAC 角色定义完成(SuperAdmin/TenantAdmin/Developer/Viewer)
- 最小权限原则验证
#2.2 网络安全
- 所有外部通信启用 TLS 1.3
- 内部 gRPC 通信启用 mTLS
- 数据库端口不对外暴露
- API Rate Limiting 已配置
- CORS 策略已设置
- 安全 Headers 已添加(HSTS、CSP、X-Frame-Options)
#2.3 数据安全
- 数据库密码使用密钥管理服务(Vault/KMS)
- 敏感数据字段加密存储
- 审计日志启用(所有数据访问和修改操作)
- 数据分类标签已定义(公开/内部/机密/绝密)
Python
# 示例:安全配置检查脚本
from ontology_sdk import OntoPlatform
platform = OntoPlatform(base_url="https://coomia-dip.company.com", token="admin-token")
security_check = platform.admin.security_audit()
for item in security_check.items:
status = "PASS" if item.passed else "FAIL"
print(f"[{status}] {item.category}: {item.description}")
if not item.passed:
print(f" Recommendation: {item.recommendation}")
#3. 高可用配置
#3.1 Control Layer HA
YAML
# Control Layer 高可用部署
control-Layer:
replicas: 3
resources:
requests: { cpu: "4", memory: "8Gi" }
limits: { cpu: "8", memory: "16Gi" }
readinessProbe:
grpc:
port: 50051
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
grpc:
port: 50051
initialDelaySeconds: 30
periodSeconds: 10
#3.2 数据库高可用
- Doris FE 部署 3 节点(1 Leader + 2 Follower)
- Doris BE 部署 3+ 节点
- 数据副本数设置为 3
- PostgreSQL(Temporal 元数据)配置主从复制
#3.3 消息队列高可用
- Kafka 部署 3+ Broker
- Topic 副本因子 = 3
- 最小 ISR = 2
-
acks=all用于关键 Topic
#4. 监控与告警
#4.1 基础指标
YAML
# Prometheus 告警规则示例
groups:
- name: coomia-dip-alerts
rules:
- alert: HighErrorRate
expr: rate(grpc_server_handled_total{grpc_code!="OK"}[5m]) > 0.01
for: 5m
labels:
severity: warning
annotations:
summary: "gRPC error rate > 1%"
- alert: HighLatency
expr: histogram_quantile(0.99, rate(grpc_server_handling_seconds_bucket[5m])) > 2
for: 5m
labels:
severity: warning
annotations:
summary: "P99 latency > 2s"
- alert: DiskSpaceWarning
expr: (node_filesystem_avail_bytes / node_filesystem_size_bytes) < 0.2
for: 10m
labels:
severity: critical
annotations:
summary: "Disk space < 20%"
#4.2 业务指标
- 活跃用户数 dashboard
- API 调用量趋势
- Ontology 对象增长率
- 查询性能分布(P50/P95/P99)
- Action 执行成功率
- Workflow 完成率和平均耗时
#4.3 日志管理
- 结构化日志(JSON 格式)
- 日志聚合(ELK/Loki)
- 日志保留策略(建议 30 天热存储 + 1 年冷存储)
- 敏感信息脱敏
#5. 备份与恢复
#5.1 备份策略
| 数据 | 频率 | 保留时间 | 方式 |
|---|---|---|---|
| Doris 数据 | 每日全量 + 实时增量 | 30 天 | Doris Backup |
| Ontology Schema | 每次变更 | 永久 | Git 版本控制 |
| Kafka 数据 | 实时(Topic 副本) | 7 天 | Kafka 内建 |
| Temporal 历史 | 每日 | 90 天 | PostgreSQL pg_dump |
| 配置文件 | 每次变更 | 永久 | Git/ConfigMap |
#5.2 恢复演练
Python
# 备份验证脚本
async def verify_backup():
# 1. 检查最新备份时间
backup = platform.admin.get_latest_backup()
hours_ago = (datetime.now() - backup.timestamp).total_seconds() / 3600
assert hours_ago < 24, f"Latest backup is {hours_ago:.1f}h old"
# 2. 验证备份完整性
integrity = platform.admin.verify_backup_integrity(backup.backup_id)
assert integrity.valid, f"Backup integrity check failed: {integrity.errors}"
# 3. 恢复到测试环境
restore = platform.admin.restore_to_test(backup.backup_id)
assert restore.status == "SUCCESS"
print("Backup verification passed")
#6. 性能基线
#6.1 基准测试
上线前必须建立性能基线:
Python
# 执行性能基准测试
results = platform.admin.run_benchmark(
scenarios=[
{"name": "object_read", "concurrency": 100, "duration_s": 60},
{"name": "object_write", "concurrency": 50, "duration_s": 60},
{"name": "oql_simple", "concurrency": 100, "duration_s": 60},
{"name": "oql_join", "concurrency": 50, "duration_s": 60},
{"name": "action_execute", "concurrency": 20, "duration_s": 60},
],
)
for r in results:
print(f"{r.scenario}: P50={r.p50_ms}ms P95={r.p95_ms}ms P99={r.p99_ms}ms TPS={r.tps}")
#6.2 性能目标
| 操作 | P50 | P95 | P99 | TPS |
|---|---|---|---|---|
| 单对象读取 | < 5ms | < 20ms | < 50ms | > 5000 |
| 单对象写入 | < 10ms | < 50ms | < 100ms | > 2000 |
| 简单 OQL 查询 | < 20ms | < 100ms | < 200ms | > 1000 |
| 复杂 JOIN 查询 | < 100ms | < 500ms | < 1s | > 200 |
| Action 执行 | < 50ms | < 200ms | < 500ms | > 500 |
#7. 上线 Runbook
#7.1 部署流程
- 代码通过所有测试(单元 + 集成 + E2E)
- 安全扫描通过(依赖漏洞 + 容器镜像)
- 配置审查完成(双人 review)
- 备份策略已验证
- 监控告警已配置并测试
- 灰度发布计划已制定
- 回滚方案已准备
- 联系方式清单已更新(on-call 人员)
#7.2 灰度发布
Python
# 配置灰度发布
platform.admin.set_canary(
version="2.0.0",
traffic_percentage=10, # 先导入 10% 流量
monitor_duration_min=30, # 监控 30 分钟
auto_rollback_conditions={
"error_rate_threshold": 0.05, # 错误率 > 5% 自动回滚
"latency_p99_threshold_ms": 2000, # P99 > 2s 自动回滚
},
)
#7.3 上线后验证
- 核心功能 Smoke Test 通过
- 性能指标在基线范围内
- 无异常错误日志
- 监控 Dashboard 数据正常
- 外部系统集成验证
#总结
本检查清单覆盖了 coomia-dip 生产部署的六大关键领域:基础设施、安全加固、高可用、监控告警、备份恢复、性能基线。在上线前逐项检查并确认,可以显著降低生产事故风险。记住:上线不是终点,而是运维的起点。
下一篇:[S12-20] 性能调优实战手册 上一篇:[S12-18] 多租户隔离与配置指南