Skip to content

Commit

Permalink
fix(redis): 重建slave时,需关闭disk-delete-count TencentBlueKing#8995
Browse files Browse the repository at this point in the history
  • Loading branch information
xiepaup committed Jan 9, 2025
1 parent 003e55d commit ea49d18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -549,13 +554,18 @@ 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 {
return
}
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 {
Expand Down

0 comments on commit ea49d18

Please sign in to comment.