@@ -151,15 +151,23 @@ func (e *ExecuteMySQLDDL) ExecuteDDLWithGhost(sql string) (data base.ReturnData,
151
151
152
152
// 生成ghost命令
153
153
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
+
163
171
startTime := time .Now ()
164
172
// 打印命令,已掩码password
165
173
re = regexp .MustCompile (`--password="([^"]*)"` )
0 commit comments