Skip to content

Commit

Permalink
fix(backend): 处理升级时候,不同介质版本MySQL参数的差异 #6613
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and zhangzhw8 committed Sep 4, 2024
1 parent 363b58d commit d6a4c02
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ def install_mysql_in_cluster_sub_flow(
@param new_mysql_list: 新机器列表,每个元素是ip
@param install_ports: 每台机器按照的实例端口列表
@param bk_host_ids: 新机器列表,每个元素是bk_host_id
@param pkg_id: 指定安装包
@param db_module_id: 指定的db_module_id
@param db_config: 数据库配置信息 {3306:{"key":val},3307:{"key":val}}
"""

# 目前先根据cluster对应,请求bk-config服务去获取对应的
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def migrate_cluster_flow(self, use_for_upgrade=False):
tendb_migrate_pipeline = SubBuilder(root_id=self.root_id, data=copy.deepcopy(self.data))
# 整机安装数据库
master = cluster_class.storageinstance_set.get(instance_inner_role=InstanceInnerRole.MASTER.value)
# db_config example {3306:{"key":val},3307:{"key":val}}
db_config = get_instance_config(cluster_class.bk_cloud_id, master.machine.ip, self.data["ports"])
install_sub_pipeline_list = []
install_sub_pipeline = SubBuilder(root_id=self.root_id, data=copy.deepcopy(self.data))
Expand Down
39 changes: 38 additions & 1 deletion dbm-ui/backend/flow/utils/mysql/mysql_act_playload.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,41 @@ def get_sys_init_payload(self, **kwargs) -> dict:
"payload": {"user": self.account["os_mysql_user"], "pwd": self.account["os_mysql_pwd"]},
}

def deal_mysql_config(self, db_version: str, origin_configs: dict, init_configs: dict) -> dict:
"""
处理不同介质的之间的mysql配置
"""
cfg = copy.deepcopy(init_configs)
cfg["mysqld"].update(origin_configs)

if db_version >= "8.0.0":
if "log_warnings" in cfg["mysqld"]:
value = cfg["mysqld"]["log_warnings"]
if value == "0":
cfg["mysqld"]["log_error_verbosity"] = 1
elif value == "1":
cfg["mysqld"]["log_error_verbosity"] = 2
else:
cfg["mysqld"]["log_error_verbosity"] = 3
del cfg["mysqld"]["log_warnings"]
# 这里应该是社区版本等非Tendb数据库的版本需要处理的参数
# 介质管理暂未记录介质来源属性
if db_version >= "8.0.30":
for key in [
"log_bin_compress",
"relay_log_uncompress",
"blob_compressed",
"innodb_min_blob_compress_length",
"innodb_table_drop_mode",
"read_binlog_speed_limit",
"datetime_precision_use_v1",
]:
if key in cfg["mysqld"]:
loose_key = "loose_" + key
cfg["mysqld"][loose_key] = cfg["mysqld"][key]
del cfg["mysqld"][key]
return cfg

def get_install_mysql_payload(self, **kwargs) -> dict:
"""
拼接安装MySQL的payload参数, 分别兼容集群申请、集群实例重建、集群实例添加单据的获取方式
Expand Down Expand Up @@ -158,7 +193,9 @@ def get_install_mysql_payload(self, **kwargs) -> dict:
mysql_config[port] = copy.deepcopy(init_mysql_config[port])
port_str = str(port)
if port_str in old_configs.keys():
mysql_config[port]["mysqld"].update(old_configs[port_str])
mysql_config[port] = self.deal_mysql_config(
db_version=version_no, init_configs=mysql_config[port], origin_configs=old_configs[port_str]
)
logger.debug("install config:", mysql_config)

drs_account, dbha_account = self.get_super_account()
Expand Down

0 comments on commit d6a4c02

Please sign in to comment.