Skip to content

Commit

Permalink
fix(dbm-services): 修复追加部署中控对临时运维的节点的授权确实的问题 TencentBlueKing#7776
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and iSecloud committed Nov 6, 2024
1 parent c9653db commit 17a68b2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,18 @@ func (c *ImportSchemaFromBackendComp) migrateUseMysqlDump() (err error) {
DumpEvent: false,
}

dumpCommandBinPath := "/home/mysql/dbbackup/mysqldump"
if !cmutil.FileExists(dumpCommandBinPath) {
dumpCommandBinPath = path.Join(cst.MysqldInstallPath, "bin", "mysqldump")
}
dumper := mysqlutil.MySQLDumper{
DumpDir: c.tmpDumpDir,
Ip: c.Params.BackendHost,
Port: c.Params.BackendPort,
DbBackupUser: c.Params.TdbctlUser,
DbBackupPwd: c.Params.TdbctlPass,
DbNames: buildBackendDbNames(c.dumpDbs),
DumpCmdFile: path.Join(cst.MysqldInstallPath, "bin", "mysqldump"),
DumpCmdFile: dumpCommandBinPath,
Charset: c.charset,
MySQLDumpOption: dumpOption,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def run(self):
slave_spiders = cluster_obj.proxyinstance_set.filter(
tendbclusterspiderext__spider_role=TenDBClusterSpiderRole.SPIDER_SLAVE.value
)
mnt_spiders = cluster_obj.proxyinstance_set.filter(
tendbclusterspiderext__spider_role=TenDBClusterSpiderRole.SPIDER_MNT.value
)
mnt_slave_spiders = cluster_obj.proxyinstance_set.filter(
tendbclusterspiderext__spider_role=TenDBClusterSpiderRole.SPIDER_SLAVE_MNT.value
)
shard0 = cluster_obj.tendbclusterstorageset_set.get(
shard_id=0, storage_instance_tuple__ejector__instance_inner_role=InstanceInnerRole.MASTER
)
Expand All @@ -240,6 +246,16 @@ def run(self):
sub_flow_context["spider_ip_list"] = [
{"ip": value} for value in list(set([c.machine.ip for c in master_spiders]))
]
if len(mnt_spiders) > 0:
sub_flow_context["mnt_spider_ip_list"] = [
{"ip": value} for value in list(set([c.machine.ip for c in mnt_spiders]))
]
sub_flow_context["mnt_spider_port"] = mnt_spiders[0].port
if len(mnt_slave_spiders) > 0:
sub_flow_context["mnt_slave_spider_ip_list"] = [
{"ip": value} for value in list(set([c.machine.ip for c in mnt_slave_spiders]))
]
sub_flow_context["mnt_slave_spider_port"] = mnt_slave_spiders[0].port
# 处理slave spider
if len(slave_spiders) > 0:
sub_flow_context["slave_spider_ip_list"] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ def _execute(self, data, parent_data) -> bool:
params["role"] = PrivRole.SPIDER.value
if not self.__add_priv(params=params):
return False
# 新集群部署,对所有的新的运维 spider节点授权, 迁移的集群可能端口不一致
if global_data.get("mnt_spider_ip_list"):
for spider_ip in global_data["mnt_spider_ip_list"]:
params["address"] = f'{spider_ip["ip"]}{IP_PORT_DIVIDER}{global_data["mnt_spider_port"]}'
params["role"] = PrivRole.SPIDER.value
if not self.__add_priv(params=params):
return False
if global_data.get("mnt_slave_spider_ip_list"):
for spider_ip in global_data["mnt_slave_spider_ip_list"]:
params["address"] = f'{spider_ip["ip"]}{IP_PORT_DIVIDER}{global_data["mnt_slave_spider_port"]}'
params["role"] = PrivRole.SPIDER.value
if not self.__add_priv(params=params):
return False
# 新集群部署,对所有的新的ctl节点授权
if is_append_deploy:
for ctl_ip in global_data["tdbctl_ip_list"]:
Expand Down

0 comments on commit 17a68b2

Please sign in to comment.