From ea49d1829ced2fa784e040d3b9e3034e69aa056b Mon Sep 17 00:00:00 2001 From: xiepaup Date: Thu, 9 Jan 2025 16:29:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(redis):=20=E9=87=8D=E5=BB=BAslave=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E9=9C=80=E5=85=B3=E9=97=ADdisk-delete-count=20#8995?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbactuator/pkg/atomjobs/atomredis/redis_backup.go | 3 +++ .../pkg/atomjobs/atomredis/tendisssd_dr_restore.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/redis_backup.go b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/redis_backup.go index b25b0cc3f2..9f39442d88 100644 --- a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/redis_backup.go +++ b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/redis_backup.go @@ -772,6 +772,9 @@ func (task *BackupTask) TendisSSDInstanceBackup() { return } + afterVerify, _ := task.Cli.TendisSSDBinlogSize() + mylog.Logger.Info("fish backup with binlogPos: %+v; afterVerify binlogPos: %+v", binlogsizeRet, afterVerify) + // 备份文件名带上 binlogPos fileWithBinlogPos := fmt.Sprintf("%s-%d", backupFullDir, binlogsizeRet.EndSeq) task.Err = os.Rename(backupFullDir, fileWithBinlogPos) diff --git a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/tendisssd_dr_restore.go b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/tendisssd_dr_restore.go index 2bec394c00..6e2fdda2d1 100644 --- a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/tendisssd_dr_restore.go +++ b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomredis/tendisssd_dr_restore.go @@ -488,6 +488,11 @@ export LD_LIBRARY_PATH=LD_LIBRARY_PATH:%s task.runtime.Logger.Info(sedCmd) util.RunBashCmd(sedCmd, "", nil, 1*time.Minute) + // 先注释掉slaveof命令, 拉起后不要 清理过期数据 + sedCmd = fmt.Sprintf("sed -i -e 's/^disk-delete-count [0-9]*/disk-delete-count 0/g' %s", slaveConfFile) + task.runtime.Logger.Info(sedCmd) + util.RunBashCmd(sedCmd, "", nil, 1*time.Minute) + startScript := filepath.Join("/usr/local/redis/bin", "start-redis.sh") _, task.Err = util.RunLocalCmd("su", []string{consts.MysqlAaccount, "-c", startScript + " " + strconv.Itoa( task.SlavePort)}, "", nil, 10*time.Second) @@ -549,6 +554,9 @@ export LD_LIBRARY_PATH=LD_LIBRARY_PATH:%s return } + slaveBinlogRange2, _ := task.SlaveCli.TendisSSDBinlogSize() + task.runtime.Logger.Info("binlogPos AtStart:%+v, AfterSetSnapShot:%+v", slaveBinlogRange, slaveBinlogRange2) + // slaveof _, task.Err = task.SlaveCli.SlaveOf(task.MasterIP, strconv.Itoa(task.MasterPort)) if task.Err != nil { @@ -556,6 +564,8 @@ export LD_LIBRARY_PATH=LD_LIBRARY_PATH:%s } task.runtime.Logger.Info("slave(%s) 'slaveof %s %d'", task.SlaveAddr(), task.MasterIP, task.MasterPort) + // waiting server change inner stats. + time.Sleep(time.Second * 2) // slave 'confxx set disk-delete-count 50' _, task.Err = task.SlaveCli.ConfigSet("disk-delete-count", "50") if task.Err != nil {