-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tendbCluster原地重建增加路由修改节点定点回档支持从原主从节点获取binlog #6666
- Loading branch information
Showing
13 changed files
with
341 additions
and
207 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
dbm-ui/backend/flow/engine/bamboo/scene/mysql/common/get_binlog_backup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
import logging.config | ||
from datetime import datetime | ||
|
||
from django.utils.translation import ugettext as _ | ||
|
||
from backend.db_services.mysql.fixpoint_rollback.handlers import FixPointRollbackHandler | ||
|
||
logger = logging.getLogger("root") | ||
|
||
|
||
def get_backup_binlog( | ||
cluster_id: int, start_time: datetime, end_time: datetime, binlog_info: dict, minute_range=30 | ||
) -> dict: | ||
result = {} | ||
if start_time > end_time: | ||
result["query_binlog_error"] = _("备份时间点:{} 大于 回滚时间点:{}".format(start_time, end_time)) | ||
return result | ||
# 先从别分文件的主节点查询,查询不到改为从节点查询。 | ||
rollback_handler = FixPointRollbackHandler(cluster_id) | ||
backup_binlog = rollback_handler.query_binlog_from_bklog( | ||
start_time=start_time, | ||
end_time=end_time, | ||
host_ip=binlog_info["show_master_status"]["master_host"], | ||
port=binlog_info["show_master_status"]["master_port"], | ||
minute_range=minute_range, | ||
) | ||
result["binlog_start_file"] = binlog_info["show_master_status"]["binlog_file"] | ||
result["binlog_start_pos"] = binlog_info["show_master_status"]["binlog_pos"] | ||
if backup_binlog is None: | ||
if "show_slave_status" not in binlog_info.keys(): | ||
result["query_binlog_error"] = _( | ||
"获取原主节点 {} binlog失败".format(binlog_info["show_master_status"]["master_host"]) | ||
) | ||
return result | ||
backup_binlog = rollback_handler.query_binlog_from_bklog( | ||
start_time=start_time, | ||
end_time=end_time, | ||
host_ip=binlog_info["show_slave_status"]["master_host"], | ||
port=binlog_info["show_slave_status"]["master_port"], | ||
minute_range=minute_range, | ||
) | ||
result["binlog_start_file"] = binlog_info["show_slave_status"]["binlog_file"] | ||
result["binlog_start_pos"] = binlog_info["show_slave_status"]["binlog_pos"] | ||
if backup_binlog is None: | ||
result["query_binlog_error"] = _("获取原主节点{} 和 原从节点{} 的binlog失败").format( | ||
binlog_info["show_master_status"]["master_host"], binlog_info["show_slave_status"]["master_host"] | ||
) | ||
return result | ||
result["binlog_task_ids"] = [i["task_id"] for i in backup_binlog["file_list_details"]] | ||
binlog_files = [i["file_name"] for i in backup_binlog["file_list_details"]] | ||
result["binlog_files"] = ",".join(binlog_files) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.