Skip to content

Commit 0921752

Browse files
committed
新增阿里云rds判断
1 parent 917c00e commit 0921752

File tree

1 file changed

+17
-9
lines changed
  • goinsight/internal/orders/api/mysql

1 file changed

+17
-9
lines changed

goinsight/internal/orders/api/mysql/ddl.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,23 @@ func (e *ExecuteMySQLDDL) ExecuteDDLWithGhost(sql string) (data base.ReturnData,
151151

152152
// 生成ghost命令
153153
logAndPublish("生成gh-ost执行命令")
154-
ghostCMD := strings.Join(
155-
[]string{
156-
global.App.Config.Ghost.Path,
157-
strings.Join(global.App.Config.Ghost.Args, " "),
158-
fmt.Sprintf("--user=\"%s\" --password=\"%s\"", global.App.Config.RemoteDB.UserName, global.App.Config.RemoteDB.Password),
159-
fmt.Sprintf("--host=\"%s\" --port=%d", e.Hostname, e.Port),
160-
fmt.Sprintf("--database=%s --table=%s", e.Schema, tableName),
161-
fmt.Sprintf("--alter=\"%s\" --execute", vv),
162-
}, " ")
154+
155+
ghostCMDParts := []string{
156+
global.App.Config.Ghost.Path,
157+
strings.Join(global.App.Config.Ghost.Args, " "),
158+
fmt.Sprintf("--user=\"%s\" --password=\"%s\"", global.App.Config.RemoteDB.UserName, global.App.Config.RemoteDB.Password),
159+
fmt.Sprintf("--host=\"%s\" --port=%d", e.Hostname, e.Port),
160+
fmt.Sprintf("--database=%s --table=%s", e.Schema, tableName),
161+
fmt.Sprintf("--alter=\"%s\" --execute", vv),
162+
}
163+
164+
if strings.Contains(e.Hostname, "rds.aliyuncs.com") {
165+
ghostCMDParts = append(ghostCMDParts, "--aliyun-rds=true")
166+
ghostCMDParts = append(ghostCMDParts, fmt.Sprintf("--assume-master-host=%s", e.Hostname))
167+
}
168+
169+
ghostCMD := strings.Join(ghostCMDParts, " ")
170+
163171
startTime := time.Now()
164172
// 打印命令,已掩码password
165173
re = regexp.MustCompile(`--password="([^"]*)"`)

0 commit comments

Comments
 (0)