feat: gh-ost 完整策略引擎 — 13项配置+环境差异+云数据库适配+DDL智能分析

配置项(13项):
- ghost_enabled: 全局开关(默认关闭)
- ghost_default_mode: 默认执行模式(dry_run/execute)
- ghost_osc_priority: OSC优先级(native_first/ghost_first/ghost_only)
- ghost_env_mode: 环境模式(development/production)
- ghost_cloud_type: 云数据库类型(self_hosted/aliyun_rds/polardb/aws_aurora)
- ghost_auto_trigger_rows: 自动触发行数阈值(万)
- ghost_auto_trigger_ddl: 自动触发DDL类型
- ghost_path/chunk_size/max_load/critical_load/max_lag_millis/allow_on_master

新增API:
- GET /ghost/config: 查看全部gh-ost配置
- POST /ghost/analyze: DDL智能分析(解析DDL类型+行数检查+策略推荐)
- 云数据库: --aliyun-rds / --aws 自动适配

策略逻辑:
- native_first + development → 推荐Native DDL
- native_first + production + DDL匹配 → 推荐gh-ost
- ghost_first/ghost_only → 强制gh-ost
- 行数超阈值 → 额外推荐gh-ost
This commit is contained in:
logan committed 2026-05-27 00:22:33 +08:00
1 parent 5d59ca427e
commit b2b13661fd
3 files changed
+253 -35

No files matched your search

+16
View File
@@ -28,6 +28,8 @@ type GhOstTask struct {
Execute bool `json:"execute"`
ExactRowCount bool `json:"exact_row_count"`
PostponeCutOver bool `json:"postpone_cut_over"`
AliyunRDS bool `json:"aliyun_rds,omitempty"` // --aliyun-rds
AWSAurora bool `json:"aws_aurora,omitempty"` // --aws
}
// GhOstResult holds the execution result
@@ -96,6 +98,13 @@ func RunGhOst(ctx context.Context, task GhOstTask, ghOstPath string) (*GhOstResu
if task.PostponeCutOver {
args = append(args, "--postpone-cut-over-flag-file=/tmp/gh-ost-cutover.flag")
}
// Cloud-specific flags
if task.AliyunRDS {
args = append(args, "--aliyun-rds")
}
if task.AWSAurora {
args = append(args, "--aws")
}
// Dry-Run vs Execute
// gh-ost defaults to noop (dry-run), only --execute actually applies changes
@@ -235,6 +244,13 @@ func buildArgs(task GhOstTask, ghOstPath string) []string {
if task.PostponeCutOver {
args = append(args, "--postpone-cut-over-flag-file=/tmp/gh-ost-cutover.flag")
}
// Cloud-specific flags
if task.AliyunRDS {
args = append(args, "--aliyun-rds")
}
if task.AWSAurora {
args = append(args, "--aws")
}
// gh-ost defaults to noop, only --execute actually applies changes
if task.Execute {