diff --git a/dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py b/dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py index 215ed70878..a9b8fb768f 100644 --- a/dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py +++ b/dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py @@ -189,16 +189,16 @@ def add_tbinlogdumper(self, add_confs: list): bk_biz_id=self.cluster.bk_biz_id, cluster_id=self.cluster.id, bk_cloud_id=self.cluster.bk_cloud_id, - ip=master.machine.ip, + ip=conf.get("dumper_ip", master.machine.ip), proc_type=ExtraProcessType.TBINLOGDUMPER, version="", listen_port=conf["port"], extra_config={ "add_type": conf.get("add_type"), - "dumper_id": str(conf["area_name"]), + "dumper_id": str(conf["dumper_id"]), "area_name": str(conf["area_name"]), - "source_data_ip": master.machine.ip, - "source_data_port": master.port, + "source_data_ip": conf.get("source_ip", master.machine.ip), + "source_data_port": conf.get("source_port", master.port), "repl_tables": conf["repl_tables"], "target_address": conf["target_address"], "target_port": conf["target_port"], diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/tbinlogdumper/common/util.py b/dbm-ui/backend/flow/engine/bamboo/scene/tbinlogdumper/common/util.py index cab67b9255..4d13aec37f 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/tbinlogdumper/common/util.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/tbinlogdumper/common/util.py @@ -15,8 +15,10 @@ from backend.db_meta.exceptions import ClusterNotExistException from backend.db_meta.models import Cluster, Machine, StorageInstance from backend.db_meta.models.extra_process import ExtraProcessInstance +from backend.db_services.mysql.dumper.models import DumperSubscribeConfig from backend.flow.consts import TBINLOGDUMPER_PORT from backend.flow.engine.bamboo.scene.tbinlogdumper.common.exceptions import NormalTBinlogDumperFlowException +from backend.flow.utils.mysql.mysql_db_meta import MySQLDBMeta def get_tbinlogdumper_install_port(machine: Machine, install_num: int) -> list: @@ -106,3 +108,20 @@ def get_tbinlogdumper_server_id(master: StorageInstance, tbinlogdumper_port: int master_server_id = res[0]["cmd_results"][0]["table_data"][0]["id"] return int(master_server_id) + tbinlogdumper_port + + +def import_nodes(infos: list): + """ + 构建 tbinlogdumper节点导入dbm系统的标准化 + """ + for info in infos: + # 根据source_ip和source_port 获取到对应的集群id + cluster = StorageInstance.objects.get( + machine__ip=info["sync_ip"], port=info["sync_port"], machine__bk_cloud_id=0 + ).cluster + dumper_config = DumperSubscribeConfig.objects.get(id=info["dumper_config_id"]) + + # 导入源信息 + info["cluster_id"] = cluster.get().id + info["repl_tables"] = dumper_config.get_subscribe_info() + MySQLDBMeta(ticket_data=info, cluster={}).add_tbinlogdumper() diff --git a/dbm-ui/backend/flow/utils/tbinlogdumper/tbinlogdumper_act_payload.py b/dbm-ui/backend/flow/utils/tbinlogdumper/tbinlogdumper_act_payload.py index e88389ca8b..37772c9a6b 100644 --- a/dbm-ui/backend/flow/utils/tbinlogdumper/tbinlogdumper_act_payload.py +++ b/dbm-ui/backend/flow/utils/tbinlogdumper/tbinlogdumper_act_payload.py @@ -74,7 +74,7 @@ def install_tbinlogdumper_payload(self, **kwargs): for conf in self.ticket_data["add_conf_list"]: mycnf_configs[conf["port"]] = self.get_tbinlogdumper_config() dumper_configs[conf["port"]] = { - "dumper_id": str(conf["area_name"]), + "dumper_id": str(conf["dumper_id"]), "area_name": str(conf["area_name"]), "server_id": conf["server_id"], "protocol_type": conf["protocol_type"],