Skip to content

Commit

Permalink
fix: 修复tbinlogdumper流程一些问题 #7616
Browse files Browse the repository at this point in the history
  • Loading branch information
yksitu authored and zhangzhw8 committed Oct 29, 2024
1 parent 00ce08e commit 907aca0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ func (i *InstallTbinlogDumperComp) DumperInstall() (err error) {

// mysql5.7.18以下版本初始化命令
initialMysql = fmt.Sprintf(
"su - mysql -c \"cd %s && ./scripts/mysql_install_db --defaults-file=%s --user=mysql --force &>%s\"",
i.MysqlInstallDir, myCnf, initialLogFile)
"su - mysql -c \"LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH cd %s && ./scripts/mysql_install_db --defaults-file=%s --user=mysql --force &>%s\"",
i.MysqlInstallDir, i.MysqlInstallDir, myCnf, initialLogFile)

// mysql5.7.18以上的版本
if cmutil.MySQLVersionParse(i.Params.MysqlVersion) >= cmutil.MySQLVersionParse("5.7.18") {
initialMysql = fmt.Sprintf(
"su - mysql -c \"cd %s && ./bin/mysqld --defaults-file=%s --initialize-insecure --user=mysql &>%s\"",
i.MysqlInstallDir, myCnf, initialLogFile)
"su - mysql -c \"LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH cd %s && ./bin/mysqld --defaults-file=%s --initialize-insecure --user=mysql &>%s\"",
i.MysqlInstallDir, i.MysqlInstallDir, myCnf, initialLogFile)
}
if output, err = osutil.ExecShellCommand(isSudo, initialMysql); err != nil {
logger.Error("%s execute failed, %s", initialMysql, output)
Expand Down
3 changes: 1 addition & 2 deletions dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from backend.db_package.models import Package
from backend.flow.consts import MediumEnum
from backend.flow.engine.bamboo.scene.common.get_real_version import get_mysql_real_version, get_proxy_real_version
from backend.flow.utils.base.cc_topo_operate import CCTopoOperator
from backend.flow.utils.cc_manage import CcManage
from backend.flow.utils.mysql.mysql_module_operate import MysqlCCTopoOperator
from backend.flow.utils.tbinlogdumper.tbinlogdumper_module_operate import TBinlogDumperCCTopoOperator
Expand Down Expand Up @@ -243,7 +242,7 @@ def switch_tbinlogdumper_for_cluster(self, switch_ids: list):
inst.save()

# 创建新的服务实例
CCTopoOperator(cluster=self.cluster).create_tbinlogdumper_instances(inst)
TBinlogDumperCCTopoOperator(cluster=self.cluster).create_tbinlogdumper_instances(inst)

@classmethod
@transaction.atomic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

from backend.configuration.constants import DBType
from backend.db_meta.enums import InstanceRole
from backend.db_meta.models import Cluster, Machine
from backend.db_meta.models import Cluster
from backend.db_meta.models.extra_process import ExtraProcessInstance
from backend.flow.consts import DBA_SYSTEM_USER
from backend.flow.engine.bamboo.scene.common.atom_jobs.set_dns_sub_job import set_dns_atom_job
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.common.get_file_list import GetFileList
from backend.flow.engine.bamboo.scene.mysql.common.common_sub_flow import build_repl_by_manual_input_sub_flow
Expand All @@ -35,7 +34,6 @@
from backend.flow.plugins.components.collections.tbinlogdumper.trans_backup_file import TBinlogDumperTransFileComponent
from backend.flow.utils.mysql.mysql_act_dataclass import DownloadMediaKwargs, ExecActuatorKwargs, P2PFileKwargs
from backend.flow.utils.mysql.mysql_act_playload import MysqlActPayload
from backend.flow.utils.redis.redis_context_dataclass import ActKwargs
from backend.flow.utils.tbinlogdumper.context_dataclass import StopSlaveKwargs, TBinlogDumperFullSyncDataKwargs
from backend.flow.utils.tbinlogdumper.tbinlogdumper_act_payload import TBinlogDumperActPayload

Expand Down Expand Up @@ -82,15 +80,16 @@ def add_tbinlogdumper_sub_flow(
# 声明子流程
sub_pipeline = SubBuilder(root_id=root_id, data=parent_global_data)

# 初始化机器,为了安装tbinlogdumper
sub_pipeline.add_sub_pipeline(
sub_flow=init_machine_sub_flow(
root_id=root_id,
uid=uid,
init_machine=master.machine,
is_install_l5_agent=is_install_l5_agent,
# 初始化机器,判断是否需要安装L5 agent
if is_install_l5_agent:
sub_pipeline.add_act(
act_name=_("安装L5agent"),
act_component_code=L5AgentInstallComponent.code,
kwargs={
"ip": master.machine.ip,
"bk_host_id": master.machine.bk_host_id,
},
)
)

# 阶段1 并行分发安装文件
sub_pipeline.add_act(
Expand Down Expand Up @@ -478,53 +477,3 @@ def full_sync_sub_flow(
return sub_pipeline.build_sub_process(
sub_name=_("实例TBinlogDumper[{}:{}]做全量同步".format(master.machine.ip, add_tbinlogdumper_conf["port"]))
)


def init_machine_sub_flow(
uid: str,
root_id: str,
init_machine: Machine,
is_install_l5_agent: bool,
):
"""
定义安装tbinlogdumper之前初始化内容
初始化内容:
1:安全初始化机器的dns_dbm域名解析(必选)
2:安装L5客户端(可选)
@param uid: 单据uid
@param root_id: 主流程的root_id
@param init_machine: 需要初始化的机器对象
@param is_install_l5_agent: 是否安装L5 agent
"""

# 声明子流程
parent_global_data = {"uid": uid}
sub_pipeline = SubBuilder(root_id=root_id, data=parent_global_data)

if is_install_l5_agent:
sub_pipeline.add_act(
act_name=_("安装L5agent"),
act_component_code=L5AgentInstallComponent.code,
kwargs={
"ip": init_machine.ip,
"bk_host_id": init_machine.bk_host_id,
},
)

else:
sub_pipeline.add_sub_pipeline(
set_dns_atom_job(
root_id=root_id,
ticket_data=parent_global_data,
act_kwargs=ActKwargs(),
param={
"force": False,
"ip": init_machine.ip,
"bk_biz_id": init_machine.bk_biz_id,
"bk_cloud_id": init_machine.bk_cloud_id,
"bk_city": init_machine.bk_city.logical_city.name,
},
)
)
# 返回子流程
return sub_pipeline.build_sub_process(sub_name=_("初始化tbinlogdumper机器"))

0 comments on commit 907aca0

Please sign in to comment.