From 32e4384b044036588de6c70339b1cd28effddd64 Mon Sep 17 00:00:00 2001 From: wubx Date: Thu, 2 Apr 2020 19:57:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=BD=93Slave=5FIO=5FRunning=3DYes=20?= =?UTF-8?q?=E6=98=AF=E5=8F=AF=E4=BB=A5=E8=AE=A4=E4=B8=BAMaster=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E6=B4=BB=E7=9D=80=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=AD=89?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E5=86=8D=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mysql/api.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mysql/api.go b/src/mysql/api.go index a0b64d7..71bad36 100644 --- a/src/mysql/api.go +++ b/src/mysql/api.go @@ -51,6 +51,11 @@ func (m *Mysql) Promotable() bool { log.Error("can't.promotable.GetGTID.error:%v", err) return false } + //Slave_IO_Running = Yes, So master is alive + if (gtid.Slave_SQL_Running) { + log.Warning("Maybe Master is alive. Slave IO_thread not timeout (slave_net_timeout)") + return false + } promotable = (gtid.Slave_SQL_Running) log.Warning("mysql[%v].Promotable.sql_thread[%v]", m.getConnStr(), promotable) From 98c6f6335af835c77b84bff4f4f81bbdd2ce94e9 Mon Sep 17 00:00:00 2001 From: wubx Date: Thu, 2 Apr 2020 20:05:20 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=BD=93Slave=5FIO=5FRunning=3DYes=20?= =?UTF-8?q?=E6=98=AF=E5=8F=AF=E4=BB=A5=E8=AE=A4=E4=B8=BAMaster=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E6=B4=BB=E7=9D=80=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=AD=89?= =?UTF-8?q?=E5=BE=85io=5Fthread=3DNo=E5=86=8D=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mysql/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mysql/api.go b/src/mysql/api.go index 71bad36..6ebd1b7 100644 --- a/src/mysql/api.go +++ b/src/mysql/api.go @@ -52,7 +52,7 @@ func (m *Mysql) Promotable() bool { return false } //Slave_IO_Running = Yes, So master is alive - if (gtid.Slave_SQL_Running) { + if (gtid.Slave_IO_Running) { log.Warning("Maybe Master is alive. Slave IO_thread not timeout (slave_net_timeout)") return false } From dbf0bd02301bdc6312ed7c9025280967d8b2d01a Mon Sep 17 00:00:00 2001 From: wubx Date: Wed, 15 Apr 2020 10:40:38 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BD=BF=E7=94=A8root=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E7=9A=84xenon,=20=E5=9C=A8rebuildme=E4=B8=AD=E4=BC=9A=E5=8D=A1?= =?UTF-8?q?=E5=9C=A8S11=E8=BF=99=E4=B8=AA=E6=AD=A5=E9=AA=A4=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E4=B8=B4=E6=97=B6=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=8A=9E=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/cmd/mysql.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cli/cmd/mysql.go b/src/cli/cmd/mysql.go index 70d49c7..9e69590 100644 --- a/src/cli/cmd/mysql.go +++ b/src/cli/cmd/mysql.go @@ -276,6 +276,19 @@ func mysqlRebuildMeCommandFn(cmd *cobra.Command, args []string) { ErrorOK(err) log.Warning("S10-->apply-log.end....") } + + //Pre 11 change datadir owner ->mysql. patch by wubx + { + datadir := conf.Backup.BackupDir + cmds :="bash" + args := []string{ + "-c", + fmt.Sprintf("chown -R mysql:mysql %s", datadir) + } + _, err := common.RunCommand(cmds, args...) + ErrorOK(err) + log.Warning("Pre-S11-->chown owner to mysql[%v]", datadir) + } // 11. start mysqld { From 6428a21ec067c375329c5508671ad7e7c227859e Mon Sep 17 00:00:00 2001 From: wubx Date: Sat, 2 May 2020 16:20:40 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9wubx=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/cmd/mysql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/cmd/mysql.go b/src/cli/cmd/mysql.go index 9e69590..a2e56bb 100644 --- a/src/cli/cmd/mysql.go +++ b/src/cli/cmd/mysql.go @@ -283,7 +283,7 @@ func mysqlRebuildMeCommandFn(cmd *cobra.Command, args []string) { cmds :="bash" args := []string{ "-c", - fmt.Sprintf("chown -R mysql:mysql %s", datadir) + fmt.Sprintf("chown -R mysql:mysql %s", datadir), } _, err := common.RunCommand(cmds, args...) ErrorOK(err) From 87a6e1addcf983b1b5c5000559009ed4b960b7c5 Mon Sep 17 00:00:00 2001 From: wubx Date: Sat, 2 May 2020 16:22:02 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=80=89=E4=B8=BB?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E4=B8=80=E4=B8=AA=E9=80=BB=E8=BE=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mysql/api.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mysql/api.go b/src/mysql/api.go index 6ebd1b7..f0362fd 100644 --- a/src/mysql/api.go +++ b/src/mysql/api.go @@ -52,10 +52,10 @@ func (m *Mysql) Promotable() bool { return false } //Slave_IO_Running = Yes, So master is alive - if (gtid.Slave_IO_Running) { - log.Warning("Maybe Master is alive. Slave IO_thread not timeout (slave_net_timeout)") - return false - } + //if (gtid.Slave_IO_Running) { + // log.Warning("Maybe Master is alive. Slave IO_thread not timeout (slave_net_timeout)") + // return false + //} promotable = (gtid.Slave_SQL_Running) log.Warning("mysql[%v].Promotable.sql_thread[%v]", m.getConnStr(), promotable) From 0df46442a3c1cb31bbc1fa043f10c581c3c9456f Mon Sep 17 00:00:00 2001 From: wubx Date: Sat, 2 May 2020 16:22:33 +0800 Subject: [PATCH 6/6] replace innbackupex to xtrabackup for 8.0 --- src/mysqld/backup.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mysqld/backup.go b/src/mysqld/backup.go index 42d32b2..e9a7f85 100644 --- a/src/mysqld/backup.go +++ b/src/mysqld/backup.go @@ -23,7 +23,7 @@ import ( const ( // backupOk used to completed of xtrabackup backupOk = "completed OK!" - backupOkCheckTimes = 2 + backupOkCheckTimes = 1 ) // Backup tuple. @@ -99,7 +99,7 @@ func (b *Backup) backupCommands(iskey bool, req *model.BackupRPCRequest) []strin var ssh string if b.conf.Passwd == "" { - backup = fmt.Sprintf("%s/innobackupex --defaults-file=%s --host=%s --port=%d --user=%s --throttle=%d --parallel=%d --stream=xbstream ./", + backup = fmt.Sprintf("%s/xtrabackup --defaults-file=%s --host=%s --port=%d --user=%s --backup --throttle=%d --parallel=%d --stream=xbstream --target-dir=./", b.conf.XtrabackupBinDir, b.conf.DefaultsFile, b.conf.Host, @@ -108,7 +108,7 @@ func (b *Backup) backupCommands(iskey bool, req *model.BackupRPCRequest) []strin req.IOPSLimits, b.conf.Parallel) } else { - backup = fmt.Sprintf("%s/innobackupex --defaults-file=%s --host=%s --port=%d --user=%s --password=%s --throttle=%d --parallel=%d --stream=xbstream ./", + backup = fmt.Sprintf("%s/xtrabackup --defaults-file=%s --host=%s --port=%d --user=%s --password=%s --backup --throttle=%d --parallel=%d --stream=xbstream --target-dir=./", b.conf.XtrabackupBinDir, b.conf.DefaultsFile, b.conf.Host, @@ -136,6 +136,7 @@ func (b *Backup) backupCommands(iskey bool, req *model.BackupRPCRequest) []strin req.BackupDir) } arg = fmt.Sprintf("%s | %s", backup, ssh) + b.log.Warning(arg) return []string{ "-c", arg, @@ -204,7 +205,7 @@ func (b *Backup) Cancel() error { } func (b *Backup) applylogCommands(req *model.BackupRPCRequest) []string { - arg := fmt.Sprintf("%s/innobackupex --defaults-file=%s --use-memory=%s --apply-log %s", b.conf.XtrabackupBinDir, b.conf.DefaultsFile, b.conf.UseMemory, req.BackupDir) + arg := fmt.Sprintf("%s/xtrabackup --defaults-file=%s --use-memory=%s --prepare --target-dir=%s", b.conf.XtrabackupBinDir, b.conf.DefaultsFile, b.conf.UseMemory, req.BackupDir) return []string{ "-c", arg,