Skip to content

Commit

Permalink
feat(redis): redis备份优化上报时间 #2522
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemakeit committed Dec 15, 2023
1 parent 825d03b commit 7e53a17
Show file tree
Hide file tree
Showing 18 changed files with 791 additions and 670 deletions.
2 changes: 1 addition & 1 deletion dbm-services/common/go-pubpkg/backupclient/backupclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (b *BackupClient) Query2(backupTaskId string) (status int, statusMsg string
}
resp := []NewResp{}
if err := json.Unmarshal(stdout, &resp); err != nil {
return 0, "", errors.Wrapf(err, "BackupClient parse query response %s fail", string(stdout))
return 0, "", errors.Wrapf(err, "BackupClient parse query response %s fail,queryArgs:%v", string(stdout), queryArgs)
}
return resp[0].Status, resp[0].Message, err
}
48 changes: 48 additions & 0 deletions dbm-services/redis/db-tools/dbactuator/models/mysqlite/mysqlite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Package mysqlite TODO
package mysqlite

import (
"fmt"
"path/filepath"

"github.com/glebarez/sqlite"
"gorm.io/gorm"

"dbm-services/redis/db-tools/dbactuator/mylog"
"dbm-services/redis/db-tools/dbactuator/pkg/consts"
"dbm-services/redis/db-tools/dbactuator/pkg/util"
)

func getLocalDbName() (dbname string, err error) {
dbname = filepath.Join(consts.BkDbmonPath, "db", "lucky_boy.db")
return
}

// GetLocalSqDB TODO
func GetLocalSqDB() (sqDB *gorm.DB, err error) {
dbName, err := getLocalDbName()
if err != nil {
return
}
dbDir := filepath.Dir(dbName)
err = util.MkDirsIfNotExists([]string{dbDir})
if err != nil {
return
}
util.LocalDirChownMysql(dbDir)
sqDB, err = gorm.Open(sqlite.Open(dbName), &gorm.Config{})
if err != nil {
err = fmt.Errorf("gorm.Open failed,err:%v,dbname:%s", err, dbName)
mylog.Logger.Info(err.Error())
return
}
return
}

// CloseDB TODO
func CloseDB(sqDB *gorm.DB) {
if sqDB != nil {
dbInstance, _ := sqDB.DB()
_ = dbInstance.Close()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ func (job *BkDbmonInstall) UntarMedia() (err error) {
var remoteVersion, localVersion string
err = job.params.BkDbmonPkg.Check()
if err != nil {
job.runtime.Logger.Error("UntarMedia failed,err:%v", err)
return
job.runtime.Logger.Error("UntarMedia check failed,err:%v,skip...", err)
// return
}
defer util.LocalDirChownMysql(consts.BkDbmonPath + "/")
verReg := regexp.MustCompile(`bk-dbmon-(v\d+.\d+).tar.gz`)
Expand Down Expand Up @@ -346,9 +346,6 @@ func (job *BkDbmonInstall) GenerateConfigFile() (err error) {
var yamlData []byte
var confMd5, tempMd5 string
var notUpdateConf bool = false
if job.params.BackupClientStrorageType == "" {
job.params.BackupClientStrorageType = consts.BackupClientStrorageTypeCOS
}
confData := &bkDbmonConf{
ReportSaveDir: consts.DbaReportSaveDir,
ReportLeftDay: consts.RedisReportLeftDay,
Expand Down
Loading

0 comments on commit 7e53a17

Please sign in to comment.