Skip to content

Commit

Permalink
feat(mysql): dbbackup 增加lock-timeout #8380
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlook authored and iSecloud committed Dec 4, 2024
1 parent e6dc412 commit 87423dc
Show file tree
Hide file tree
Showing 24 changed files with 265 additions and 146 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16389,'tendbsingle','backup','dbbackup.ini','LogicalBackup.DefaultsFile','STRING','','','STRING',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2023-05-25 09:50:12',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16400,'tendbsingle','backup','dbbackup.ini','LogicalBackup.DisableCompress','STRING','false','false | true','BOOL',2,0,0,0,0,NULL,'','',-1,NULL,'','2023-05-24 21:45:24','2023-05-24 21:45:24',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (23734,'tendbsingle','backup','dbbackup.ini','LogicalBackup.ExcludeDatabases','STRING','mysql,sys,test,information_schema,performance_schema,db_infobase','','',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2024-11-06 12:40:11',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16388,'tendbsingle','backup','dbbackup.ini','LogicalBackup.ExtraOpt','STRING','--skip-definer','','STRING',2,0,0,0,0,NULL,'','',-1,NULL,'','2023-05-24 21:45:24','2023-05-25 09:59:19',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16388,'tendbsingle','backup','dbbackup.ini','LogicalBackup.ExtraOpt','STRING','','','STRING',2,0,0,0,0,NULL,'','',-1,NULL,'','2023-05-24 21:45:24','2024-12-03 15:49:24',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (13051,'tendbsingle','backup','dbbackup.ini','LogicalBackup.FlushRetryCount','INT','3','','INT',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2023-03-22 12:23:33',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (13055,'tendbsingle','backup','dbbackup.ini','LogicalBackup.Regex','STRING','{{.LogicalBackup.Regex}}','','STRING',2,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (25534,'tendbsingle','backup','dbbackup.ini','LogicalBackup.Tables','STRING','*','','',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2024-11-06 12:42:11',0);
Expand All @@ -109,7 +109,7 @@ INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (23732,'tendbsingle','backup','dbbackup.ini','LogicalBackupMysqldump.ExtraOpt','STRING','','','',2,0,0,0,0,NULL,'','',-1,NULL,'','2023-05-24 21:45:24','2024-11-11 10:22:39',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16385,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.DefaultsFile','STRING','{{.PhysicalBackup.DefaultsFile}}','','',2,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2023-05-25 10:24:10',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (23702,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.DisableSlaveMultiThread','STRING','true','true | false','BOOL',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2024-07-04 14:36:04',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16396,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.ExtraOpt','STRING','--safe-slave-backup-timeout=60','','',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2023-05-24 21:46:16',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16396,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.ExtraOpt','STRING','','','',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2024-12-03 15:49:24',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (23718,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.MaxMyisamTables','INT','10','[0, 9999999]','RANGE',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2024-07-04 14:35:52',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16405,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.Threads','INT','2','[0, 8]','RANGE',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2023-05-10 15:21:23',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (16390,'tendbsingle','backup','dbbackup.ini','PhysicalBackup.Throttle','INT','200','[0, 500]','RANGE',1,0,0,0,0,NULL,'','',-1,NULL,'','2022-05-26 20:11:23','2024-04-23 12:28:34',0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24449,'doris','dbconf','2.1.5','fe.tablet_rebalancer_type','STRING','BeLoad','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','tablet_rebalancer_type','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24450,'doris','dbconf','2.1.5','fe.tablet_repair_delay_factor_second','STRING','60','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','tablet_repair_delay_factor_second','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24451,'doris','dbconf','2.1.5','fe.tablet_stat_update_interval_second','STRING','300','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','tablet_stat_update_interval_second','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24452,'doris','dbconf','2.1.5','fe.table_name_length_limit','STRING','64','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','table_name_length_limit','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24452,'doris','dbconf','2.1.5','fe.table_name_length_limit','STRING','128','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','table_name_length_limit','2023-01-13 11:26:00','2024-12-02 15:12:20',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24453,'doris','dbconf','2.1.5','fe.thrift_backlog_num','STRING','1024','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','thrift_backlog_num','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24454,'doris','dbconf','2.1.5','fe.thrift_client_timeout_ms','STRING','0','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','thrift_client_timeout_ms','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
INSERT INTO `tb_config_name_def` (`id`, `namespace`, `conf_type`, `conf_file`, `conf_name`, `value_type`, `value_default`, `value_allowed`, `value_type_sub`, `flag_status`, `flag_disable`, `flag_locked`, `flag_encrypt`, `need_restart`, `value_formula`, `extra_info`, `conf_name_lc`, `order_index`, `since_version`, `description`, `created_at`, `updated_at`, `stage`) VALUES (24455,'doris','dbconf','2.1.5','fe.thrift_server_max_worker_threads','STRING','4096','NULL','',2,0,0,0,1,'NULL','NULL','NULL',-1,'NULL','thrift_server_max_worker_threads','2023-01-13 11:26:00','2023-04-17 17:10:41',0);
Expand Down
16 changes: 16 additions & 0 deletions dbm-services/common/go-pubpkg/cmutil/osinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmutil

import (
"path/filepath"
"regexp"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -155,3 +156,18 @@ func IsSameTopLevelDir(dir1, dir2 string) (bool, error) {
}
return topDir1 == topDir2, nil
}

// GetGlibcVersion get os glibc version using ExeCommand("ldd --version |grep libc")
func GetGlibcVersion() (string, error) {
outStr, errStr, err := ExecCommand(false, "",
"/usr/bin/ldd", "--version", "|", "grep", "libc")
if err != nil {
return "", errors.WithMessage(err, errStr)
}
verMatch := regexp.MustCompile(`ldd \(.*\) (\d+\.\d+)`)
ms := verMatch.FindStringSubmatch(outStr)
if len(ms) == 2 {
return ms[1], nil
}
return "", errors.New("ldd --version | grep glibc fail to get glibc version")
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func (i *InstallMySQLComp) InitDefaultParam() (err error) {
i.Checkfunc = append(i.Checkfunc, i.precheckMysqlDir)
i.Checkfunc = append(i.Checkfunc, i.precheckMysqlProcess)
i.Checkfunc = append(i.Checkfunc, i.precheckMysqlPackageBitOS)
i.Checkfunc = append(i.Checkfunc, i.precheckGlibcVersion)
i.Checkfunc = append(i.Checkfunc, i.Params.Medium.Check)
i.Params.PartitionYWAccount.AccessHosts = []string{
i.Params.Host,
Expand Down Expand Up @@ -361,6 +362,19 @@ func (i *InstallMySQLComp) precheckMysqlPackageBitOS() error {
return nil
}

func (i *InstallMySQLComp) precheckGlibcVersion() error {
glibcVer, err := cmutil.GetGlibcVersion()
if err != nil {
logger.Error("failed to glibc version, err:%s", err.Error())
return err
}
// mysql 8.0 不安装在 tlinux1.2上 (mysqld能运行,但周边 xtrabackup 8.0 依赖 glibc>=2.14)
if cmutil.MySQLVersionParse(i.Params.MysqlVersion) >= cmutil.MySQLVersionParse("8.0.0") && glibcVer < "2.14" {
return errors.Errorf("glibc version %s it not allowed to install %s", glibcVer, i.Params.MysqlVersion)
}
return nil
}

// initMySQLInstanceMem TODO
// GetInstMemByIP 返回的内存单位是 MB
func (i *InstallMySQLComp) initMySQLInstanceMem() (err error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (m *DBLoader) chooseDBBackupLoader() error {
QpressTool: m.Tools.MustGet(tools.ToolQPress),
LoaderDir: m.targetDir,
StorageType: strings.ToLower(m.indexObj.StorageEngine),
MySQLVersion: m.BackupInfo.indexObj.MysqlVersion,
},
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type Xtrabackup struct {
// 在 PreRun 时初始化,本地实例的配置文件
myCnf *util.CnfFile

StorageType string `json:"-"`
StorageType string `json:"-"`
MySQLVersion string `json:"-"`
}

// PreRun 以下所有步骤必须可重试
Expand Down Expand Up @@ -79,7 +80,7 @@ func (x *Xtrabackup) PostRun() (err error) {
return err
}

logger.Info("start local mysqld with skip-grant-tables")
logger.Info("start local mysqld with --skip-grant-tables --skip-slave-start")
// 启动mysql-修复权限
startParam := computil.StartMySQLParam{
MediaDir: cst.MysqldInstallPath,
Expand All @@ -88,6 +89,7 @@ func (x *Xtrabackup) PostRun() (err error) {
MySQLPwd: x.TgtInstance.Pwd,
Socket: x.TgtInstance.Socket,
SkipGrantTables: true, // 以 skip-grant-tables 启动来修复 ADMIN
SkipSlaveFlag: true,
}
if _, err = startParam.StartMysqlInstance(); err != nil {
return errors.WithMessage(err, "start mysqld after xtrabackup")
Expand All @@ -106,6 +108,11 @@ func (x *Xtrabackup) PostRun() (err error) {
serverVersion = "5.7.20" // fake
}
}
if _, err = x.dbWorker.Exec("reset slave all"); err != nil {
logger.Warn("failed to reset slave all, err", err.Error())
}

//return nil
logger.Info("repair user 'ADMIN' host and password")
// 物理备份,ADMIN密码与 backup instance(cluster?) 相同,修复成
// 修复ADMIN用户,而不是 x.TgtInstance.User,主要是修复 host,密码修复成临时用户 DBM_JOB_xxx 的密码
Expand All @@ -130,10 +137,12 @@ func (x *Xtrabackup) PostRun() (err error) {
logger.Info("restart local mysqld %d", x.TgtInstance.Port)
// 重启mysql(去掉 skip-grant-tables)
startParam.SkipGrantTables = false
startParam.SkipSlaveFlag = false
startParam.MySQLUser = native.DBUserAdmin
if _, err := startParam.RestartMysqlInstance(); err != nil {
return errors.WithMessage(err, "RestartMysqlInstance")
}

logger.Info("reconnect use ADMIN and temp_job_user pwd(already repaired) %d", x.TgtInstance.Port)
tmpAdminPassInst := deepcopy.Copy(x.TgtInstance).(native.InsObject)
tmpAdminPassInst.User = native.DBUserAdmin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ func (x *Xtrabackup) RepairPrivileges() error {

var batchSQLs []string
// delete src host's ADMIN/sync user
sql1 := fmt.Sprintf("DELETE FROM mysql.user WHERE `user` IN (%s) AND `host` = %s;", myUsersUnsafe, srcHostUnsafe)
batchSQLs = append(batchSQLs, sql1)
batchSQLs = append(batchSQLs,
fmt.Sprintf("DELETE FROM mysql.user WHERE `user` IN (%s) AND `host` = %s;", myUsersUnsafe, srcHostUnsafe))

// update src host to new, but not ADMIN/sync/repl
sql2s := []string{
Expand All @@ -203,16 +203,15 @@ func (x *Xtrabackup) RepairPrivileges() error {
tgtHostUnsafe, srcHostUnsafe, myUsersUnsafe,
),
}
batchSQLs = append(batchSQLs, sql2s...)

/*
// delete src host users, but not localhost
sql3 := fmt.Sprintf(
"DELETE FROM mysql.user WHERE `host` IN(%s);", srcHostUnsafe,
)
batchSQLs = append(batchSQLs, sql3)
*/
if cmutil.MySQLVersionParse(x.MySQLVersion) >= cmutil.MySQLVersionParse("8.0.0") {
// mysql 8.0 的 BACKUP_ADMIN 权限记录在 mysql.global_grants 中
sql2s = append(sql2s, fmt.Sprintf(
"UPDATE mysql.global_grants SET `HOST`=%s WHERE `HOST`=%s AND User NOT IN (%s);",
tgtHostUnsafe, srcHostUnsafe, myUsersUnsafe,
))
}

batchSQLs = append(batchSQLs, sql2s...)
// flush
sql4 := fmt.Sprintf("flush privileges;")
batchSQLs = append(batchSQLs, sql4)
Expand Down
4 changes: 3 additions & 1 deletion dbm-services/mysql/db-tools/mysql-dbbackup/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ IOLimitMBPerSec = 300
### 常见备份失败处理

1. log copying being too slow
it looks like InnoDB log has wrapped around before xtrabackup could process all records due to either log copying being too slow, or log files being too small.
it looks like InnoDB log has wrapped around before xtrabackup could process all records due to either log copying being too slow, or log files being too small.
实例写入速度比备份速度快,可能是刚刚备份时间段有大批量 DML 操作,修改备份开始时间,或者加快备份速度:
- 调大 PhysicalBackup.Throttle, 调大 PhysicalBackup.Threads
Loading

0 comments on commit 87423dc

Please sign in to comment.