diff --git a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_add_modules_cmds.go b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_add_modules_cmds.go index 5f6ac3aa4b..bbc0fb30c1 100644 --- a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_add_modules_cmds.go +++ b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_add_modules_cmds.go @@ -10,10 +10,10 @@ import ( "github.com/go-playground/validator/v10" - "dbm-services/mongodb/db-tools/dbmon/util" "dbm-services/redis/db-tools/dbactuator/models/myredis" "dbm-services/redis/db-tools/dbactuator/pkg/consts" "dbm-services/redis/db-tools/dbactuator/pkg/jobruntime" + "dbm-services/redis/db-tools/dbactuator/pkg/util" ) // PredixyAddModulesCmdsParams 参数 @@ -68,7 +68,7 @@ func (job *PredixyAddModulesCmds) Init(m *jobruntime.JobGenericRuntime) error { // Name 原子任务名 func (job *PredixyAddModulesCmds) Name() string { - return "predixy_add_modules_cmds" + return "redis_predixy_add_modules_cmds" } // Run 执行 @@ -98,11 +98,19 @@ func (job *PredixyAddModulesCmds) Run() (err error) { job.params.LoadModules) return nil } + // 备份配置文件 + bakConfFile := job.configFile + "_old_" + time.Now().Format(consts.FilenameTimeLayout) + cpCmd := fmt.Sprintf(`cp %s %s`, job.configFile, bakConfFile) + job.runtime.Logger.Info(cpCmd) + _, err = util.RunBashCmd(cpCmd, "", nil, 10*time.Second) + if err != nil { + return err + } // 删除配置文件中 CustomCommand 配置中的内容 // sed命令意思是删除 CustomCommand 到 ###### 所有行 sedCmd := fmt.Sprintf(`sed -i '/CustomCommand/,/######/d' %s`, job.configFile) job.runtime.Logger.Info(sedCmd) - _, err = util.RunBashCmd(sedCmd, job.configFile, nil, 10*time.Second) + _, err = util.RunBashCmd(sedCmd, "", nil, 10*time.Second) if err != nil { return err } @@ -114,7 +122,7 @@ cat >>%s<> %s", item, value, confFile) mylog.Logger.Info(echoCmd) _, err = RunBashCmd(echoCmd, "", nil, 10*time.Second) - } else { - // 直接添加 - echoCmd := fmt.Sprintf("echo '%s %s' >> %s", item, value, confFile) - mylog.Logger.Info(echoCmd) - _, err = RunBashCmd(echoCmd, "", nil, 10*time.Second) - } + return err + } + // 如果存在,但值不对 + // 先删除 + sedCmd := fmt.Sprintf("sed -i -e '/^%s/d' %s", item, confFile) + mylog.Logger.Info(sedCmd) + _, err = RunBashCmd(sedCmd, "", nil, 10*time.Second) + // 再添加 + echoCmd := fmt.Sprintf("echo '%s %s' >> %s", item, value, confFile) + mylog.Logger.Info(echoCmd) + _, err = RunBashCmd(echoCmd, "", nil, 10*time.Second) return err } diff --git a/dbm-services/redis/redis-dts/pkg/dtsJob/base.go b/dbm-services/redis/redis-dts/pkg/dtsJob/base.go index 6465a08e94..785ab12713 100644 --- a/dbm-services/redis/redis-dts/pkg/dtsJob/base.go +++ b/dbm-services/redis/redis-dts/pkg/dtsJob/base.go @@ -191,9 +191,9 @@ func (job *DtsJobBase) BgDtsTaskRunnerWithoutLimit(taskType, dbType string) { // BgOldRunningSyncTaskWatcher 目的: // 很多时候 redis-sync 已经拉起,状态为runnig(taskrow.status==1 taskrow.taskType="makeSync") -// 而此时我们需要暂停 dbm-services/redis/redis-dts 升级 dbm-services/redis/redis-dts的介质 -// 再次拉起后, 以前(taskrow.status==1 taskrow.taskType="makeSync")的task其相关状态依然需要我们不断watch -// 注意: 该函数只在 dbm-services/redis/redis-dts 被拉起时执行,启动goroutine监听属于当前dts_server的属于running状态的tasks +// 而此时我们需要关闭 redis_dts_server进程,进行 redis_dts_server 的介质升级 +// 再次拉起redis_dts_server进程后, 以前处于增量同步的(taskrow.status==1 taskrow.taskType="makeSync")的task其相关状态依然需要我们不断watch +// 注意: 该函数只在 redis_dts_server 被拉起时执行一次,启动goroutine监听处于 增量同步的(taskrow.status==1 taskrow.taskType="makeSync")的task // 对于后续新增的 (taskrow.status==1 taskrow.taskType="makeSync")的task,不归该函数处理 func (job *DtsJobBase) BgOldRunningSyncTaskWatcher(taskType, dbType string, status int) { limit := 100000 @@ -243,7 +243,7 @@ func (job *DtsJobBase) IsMyselfInBlacklist() bool { } // CheckSrcSlaveServerConcurrency 检查源slave机器是否还能新增迁移task -// 如源slave机器上有20个redis,同时启动迁移是危险的,需做并发控制 +// 如源slave机器上有20个redis,同时启动迁移所有redis是危险的,需做并发控制 func (job *DtsJobBase) CheckSrcSlaveServerConcurrency(taskRow *tendisdb.TbTendisDTSTask, taskTypes []string) (ok bool, err error) { diff --git a/dbm-ui/backend/db_services/redis/redis_modules/migrations/0003_alter_tbredismodulesupport_so_file.py b/dbm-ui/backend/db_services/redis/redis_modules/migrations/0003_alter_tbredismodulesupport_so_file.py new file mode 100644 index 0000000000..2d4070d86a --- /dev/null +++ b/dbm-ui/backend/db_services/redis/redis_modules/migrations/0003_alter_tbredismodulesupport_so_file.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2024-09-04 15:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("redis_modules", "0002_auto_20240827_1912"), + ] + + operations = [ + migrations.AlterField( + model_name="tbredismodulesupport", + name="so_file", + field=models.CharField(default="", max_length=64, verbose_name="so文件名"), + ), + ] diff --git a/dbm-ui/backend/db_services/redis/redis_modules/models/redis_module_support.py b/dbm-ui/backend/db_services/redis/redis_modules/models/redis_module_support.py index 81c587975b..ad6932d7cd 100644 --- a/dbm-ui/backend/db_services/redis/redis_modules/models/redis_module_support.py +++ b/dbm-ui/backend/db_services/redis/redis_modules/models/redis_module_support.py @@ -12,7 +12,7 @@ class TbRedisModuleSupport(models.Model): major_version = models.CharField(_("主版本号"), max_length=32, default="") module_name = models.CharField(_("module名"), max_length=32, default="") - so_file = models.CharField(_("so文件名"), max_length=32, default="") + so_file = models.CharField(_("so文件名"), max_length=64, default="") class Meta: verbose_name = _("Redis module支持") diff --git a/dbm-ui/backend/flow/utils/redis/redis_act_playload.py b/dbm-ui/backend/flow/utils/redis/redis_act_playload.py index a4f75ec50c..b660d01af3 100644 --- a/dbm-ui/backend/flow/utils/redis/redis_act_playload.py +++ b/dbm-ui/backend/flow/utils/redis/redis_act_playload.py @@ -2312,6 +2312,9 @@ def redis_cluster_add_modules_update_dbconfig(self, cluster_map: dict) -> dict: dst_conf_upsert_items = [ {"conf_name": "loadmodule", "conf_value": ",".join(load_modules), "op_type": "update"} ] + # 如果 load_modules中包含 jlsy-b2,则 appendonly 为no + if "jlsy-b2" in load_modules: + dst_conf_upsert_items.append({"conf_name": "appendonly", "conf_value": "no", "op_type": "update"}) upsert_param = { "conf_file_info": {