Skip to content

Commit

Permalink
feat: 增加导入Tbinlogdumper实例的方法 #4554
Browse files Browse the repository at this point in the history
  • Loading branch information
yksitu authored and iSecloud committed May 24, 2024
1 parent 39fb587 commit c802f5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit c802f5d

Please sign in to comment.