Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(other): 增加对Tbinlogdumper实例迁移的逻辑 #4554 #4580

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading