From 930c834ab037e4795aed4db1c0d27722b667b0d1 Mon Sep 17 00:00:00 2001 From: ymakedaq <996156275@qq.com> Date: Mon, 23 Oct 2023 15:10:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(dbm-services):=20=E6=9B=B4=E6=94=B9mysql?= =?UTF-8?q?=20dbha=E7=89=88=E6=9C=AC=E5=88=87=E6=8D=A2=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=85=A5=E5=8F=82=20close=20#1504?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pkg/components/mysql/cutover/cutover.go | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/cutover/cutover.go b/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/cutover/cutover.go index 7fad97f841..820213d662 100644 --- a/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/cutover/cutover.go +++ b/dbm-services/mysql/db-tools/dbactuator/pkg/components/mysql/cutover/cutover.go @@ -27,7 +27,12 @@ import ( type CutOverParam struct { Host string `json:"host" validate:"required,ip"` Cluster *MySQLClusterDetail `json:"cluster"` - IsSafe bool `json:"is_safe"` + // 客户端连接检查 + ClientConnCheck bool `json:"client_conn_check"` + // 主从延迟检查 + SlaveDelayCheck bool `json:"slave_delay_check"` + // 数据校验结果检查 + VerifyChecksum bool `json:"verify_checksum"` // Master 是否已经dead IsDeadMaster bool `json:"is_dead_master"` // 切换完成,是都需要为源Master,获取其他Slave增加复制账户 @@ -163,9 +168,11 @@ func (m *CutOverToSlaveComp) Example() interface{} { }, }, }, - IsSafe: true, - IsDeadMaster: false, - LockedSwitch: true, + ClientConnCheck: true, + SlaveDelayCheck: true, + VerifyChecksum: true, + IsDeadMaster: false, + LockedSwitch: true, }, } return comp @@ -183,11 +190,19 @@ func (m *CutOverToSlaveComp) PreCheck() (err error) { return err } - // 安全模式下,检查下CheckSum,检查业务连接 - if m.Params.IsSafe { + // table checksum 结果校验 + if m.Params.VerifyChecksum { if err = m.cluster.AltSlaveIns.CheckCheckSum(); err != nil { return err } + if m.isCutOverPair { + if err = m.cluster.AltSlaveIns.Slave.CheckCheckSum(); err != nil { + return err + } + } + } + // 客户端连接检查 + if m.Params.ClientConnCheck { prcsls, err := m.cluster.AltSlaveIns.dbConn.ShowApplicationProcesslist(m.sysUsers) if err != nil { logger.Error("show processlist failed %s", err.Error()) @@ -196,11 +211,6 @@ func (m *CutOverToSlaveComp) PreCheck() (err error) { if len(prcsls) > 0 { return fmt.Errorf("there is a connection for non system users %v", prcsls) } - if m.isCutOverPair { - if err = m.cluster.AltSlaveIns.Slave.CheckCheckSum(); err != nil { - return err - } - } } // 如果源Master已经故障,以下检查跳过 @@ -299,7 +309,7 @@ func (m *CutOverToSlaveComp) CutOver() (binPos string, err error) { // record cutover bin pos if binPos, err = m.cluster.AltSlaveIns.RecordBinPos(); err != nil { logger.Error("获取切换时候的位点信息失败: %s", err.Error()) - return + return "{}", err } // proxy switch 待切换slave logger.Info("proxy backend switch to %s", m.cluster.AltSlaveIns.Addr())