Add -override-applier-host for use with -allow-master-master

for configurations where writes are meant to go to one master, but gh-ost can't automatically determine which
This commit is contained in:
randall 2016-09-01 20:29:26 -07:00
parent dfde634cf6
commit 82110fcfcf
3 changed files with 8 additions and 0 deletions

View File

@ -109,6 +109,7 @@ type MigrationContext struct {
CutOverType CutOver
Hostname string
OverrideApplierHostname string
TableEngine string
RowsEstimate int64
RowsDeltaEstimate int64

View File

@ -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", "":

View File

@ -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")