diff --git a/go/base/context.go b/go/base/context.go index 8d988ea..d6a931d 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -109,6 +109,7 @@ type MigrationContext struct { CutOverType CutOver Hostname string + OverrideApplierHostname string TableEngine string RowsEstimate int64 RowsDeltaEstimate int64 diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 115829a..38c8466 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -44,6 +44,7 @@ func main() { migrationContext := base.GetMigrationContext() flag.StringVar(&migrationContext.InspectorConnectionConfig.Key.Hostname, "host", "127.0.0.1", "MySQL hostname (preferably a replica, not the master)") + flag.StringVar(&migrationContext.OverrideApplierHostname, "override-applier-host", "", "(with -allow-master-master), optionally specify which host should have changes applied to it") flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)") flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user") flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password") @@ -161,6 +162,9 @@ func main() { } 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.") } + if migrationContext.OverrideApplierHostname != "" && !migrationContext.AllowedMasterMaster { + log.Fatalf("--override-applier-host is only for use with --allow-master-amster") + } switch *cutOver { case "atomic", "default", "": diff --git a/go/logic/migrator.go b/go/logic/migrator.go index e9c1426..8bf7641 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -759,6 +759,9 @@ func (this *Migrator) initiateInspector() (err error) { if this.migrationContext.ApplierConnectionConfig, err = this.inspector.getMasterConnectionConfig(); err != nil { return err } + if this.migrationContext.OverrideApplierHostname != "" { + this.migrationContext.ApplierConnectionConfig.Key.Hostname = this.migrationContext.OverrideApplierHostname + } if this.migrationContext.TestOnReplica || this.migrationContext.MigrateOnReplica { if this.migrationContext.InspectorIsAlsoApplier() { return fmt.Errorf("Instructed to --test-on-replica or --migrate-on-replica, but the server we connect to doesn't seem to be a replica")