Skip to content

Commit d13049b

Browse files
author
Shlomi Noach
authored
Merge pull request #339 from github/explicit-master-user-password
support for --master-user and --master-password
2 parents 863f508 + eac990b commit d13049b

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

go/base/context.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ type MigrationContext struct {
8282
IsTungsten bool
8383
DiscardForeignKeys bool
8484

85-
config ContextConfig
86-
configMutex *sync.Mutex
87-
ConfigFile string
88-
CliUser string
89-
CliPassword string
85+
config ContextConfig
86+
configMutex *sync.Mutex
87+
ConfigFile string
88+
CliUser string
89+
CliPassword string
90+
CliMasterUser string
91+
CliMasterPassword string
9092

9193
HeartbeatIntervalMilliseconds int64
9294
defaultNumRetries int64

go/cmd/gh-ost/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func main() {
5050
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
5151
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
5252
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
53+
flag.StringVar(&migrationContext.CliMasterUser, "master-user", "", "MySQL user on master, if different from that on replica. Requires --assume-master-host")
54+
flag.StringVar(&migrationContext.CliMasterPassword, "master-password", "", "MySQL password on master, if different from that on replica. Requires --assume-master-host")
5355
flag.StringVar(&migrationContext.ConfigFile, "conf", "", "Config file")
5456
askPass := flag.Bool("ask-pass", false, "prompt for MySQL password")
5557

@@ -170,8 +172,11 @@ func main() {
170172
}
171173
log.Warning("--test-on-replica-skip-replica-stop enabled. We will not stop replication before cut-over. Ensure you have a plugin that does this.")
172174
}
173-
if migrationContext.AssumeMasterHostname != "" && !migrationContext.AllowedMasterMaster && !migrationContext.IsTungsten {
174-
log.Fatalf("--assume-master-host requires either --allow-master-master or --tungsten")
175+
if migrationContext.CliMasterUser != "" && migrationContext.AssumeMasterHostname == "" {
176+
log.Fatalf("--master-user requires --assume-master-host")
177+
}
178+
if migrationContext.CliMasterPassword != "" && migrationContext.AssumeMasterHostname == "" {
179+
log.Fatalf("--master-password requires --assume-master-host")
175180
}
176181

177182
switch *cutOver {

go/logic/migrator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,12 @@ func (this *Migrator) initiateInspector() (err error) {
653653
return err
654654
}
655655
this.migrationContext.ApplierConnectionConfig = this.migrationContext.InspectorConnectionConfig.DuplicateCredentials(*key)
656+
if this.migrationContext.CliMasterUser != "" {
657+
this.migrationContext.ApplierConnectionConfig.User = this.migrationContext.CliMasterUser
658+
}
659+
if this.migrationContext.CliMasterPassword != "" {
660+
this.migrationContext.ApplierConnectionConfig.Password = this.migrationContext.CliMasterPassword
661+
}
656662
log.Infof("Master forced to be %+v", *this.migrationContext.ApplierConnectionConfig.ImpliedKey)
657663
}
658664
// validate configs

0 commit comments

Comments
 (0)