Skip to content

Commit

Permalink
fix(dbm-services): 更新tdbctl 容器初始化 close #952
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq committed Sep 1, 2023
1 parent 1e59f4d commit 017014d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
4 changes: 3 additions & 1 deletion dbm-services/mysql/db-simulation/app/service/kubernets.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (k *DbPodSets) getCreateClusterSqls() []string {
ss = append(ss, fmt.Sprintf(
"tdbctl create node wrapper 'TDBCTL' options(user 'root', password '%s', host 'localhost', port 26000);",
k.BaseInfo.RootPwd))
ss = append(ss, "tdbctl enable primary;")
ss = append(ss, "tdbctl flush routing;")
return ss
}
Expand Down Expand Up @@ -167,7 +168,8 @@ func (k *DbPodSets) CreateClusterPod() (err error) {
}},
ImagePullPolicy: v1.PullIfNotPresent,
Image: k.TdbCtlImage,
Args: []string{"mysqld", "--defaults-file=/etc/my.cnf", "--port=26000", "--tc-is-primary=1",
Args: []string{"mysqld", "--defaults-file=/etc/my.cnf", "--port=26000", "--tc-admin=1",
"--dbm-allow-standalone-primary",
fmt.Sprintf("--character-set-server=%s",
k.BaseInfo.Charset),
"--user=mysql"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,27 @@ func (c *SemanticDumpSchemaComp) Precheck() (err error) {
// @return err
func (c *SemanticDumpSchemaComp) DumpSchema() (err error) {
var dumper mysqlutil.Dumper
dumpOption := mysqlutil.MySQLDumpOption{
NoData: true,
AddDropTable: true,
NeedUseDb: true,
DumpRoutine: true,
DumpTrigger: false,
}
if c.isSpider {
dumpOption.GtidPurgedOff = true
}
dumper = &mysqlutil.MySQLDumperTogether{
MySQLDumper: mysqlutil.MySQLDumper{
DumpDir: c.Params.BackupDir,
Ip: c.Params.Host,
Port: c.Params.Port,
DbBackupUser: c.GeneralParam.RuntimeAccountParam.AdminUser,
DbBackupPwd: c.GeneralParam.RuntimeAccountParam.AdminPwd,
DbNames: c.dbs,
DumpCmdFile: c.dumpCmd,
Charset: c.charset,
MySQLDumpOption: mysqlutil.MySQLDumpOption{
NoData: true,
AddDropTable: true,
NeedUseDb: true,
DumpRoutine: true,
DumpTrigger: false,
},
DumpDir: c.Params.BackupDir,
Ip: c.Params.Host,
Port: c.Params.Port,
DbBackupUser: c.GeneralParam.RuntimeAccountParam.AdminUser,
DbBackupPwd: c.GeneralParam.RuntimeAccountParam.AdminPwd,
DbNames: c.dbs,
DumpCmdFile: c.dumpCmd,
Charset: c.charset,
MySQLDumpOption: dumpOption,
},
OutputfileName: c.Params.BackupFileName,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type Dumper interface {
type MySQLDumpOption struct {
/* DumpSchema bool
DumpData bool */
NoData bool
AddDropTable bool // 默认 false 代表添加 --skip-add-drop-table 选项
NeedUseDb bool
NoCreateDb bool
NoCreateTb bool
DumpRoutine bool // 默认 false 代表添加不导出存储过程,True导出存储过程
DumpTrigger bool // 默认 false 代表添加不导出触发器
DumpEvent bool // 默认 false 导出 event

NoData bool
AddDropTable bool // 默认 false 代表添加 --skip-add-drop-table 选项
NeedUseDb bool
NoCreateDb bool
NoCreateTb bool
DumpRoutine bool // 默认 false 代表添加不导出存储过程,True导出存储过程
DumpTrigger bool // 默认 false 代表添加不导出触发器
DumpEvent bool // 默认 false 导出 event
GtidPurgedOff bool // --set-gtid-purged=OFF
}

type runtimectx struct {
Expand Down Expand Up @@ -238,6 +238,9 @@ func (m *MySQLDumper) getDumpCmd(dbName, outputFile, errFile, dumpOption string)
if m.DumpEvent {
dumpOption += " --events"
}
if m.GtidPurgedOff {
dumpOption += " --set-gtid-purged=OFF"
}
dumpCmd = fmt.Sprintf(
`%s
-h%s
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/charts/db-simulation/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 0.0.1-alpha.30
appVersion: 0.0.1-alpha.32
description: A Helm chart for Kubernetes
name: db-simulation
type: application
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/templates/dbsimulation-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
image: "{{ .Values.global.imageRegistry | default "mirrors.tencent.com" }}/build/blueking/tendb-8.0.18:4.1_v2"
- version: "tdbctl"
image: "{{ .Values.global.imageRegistry | default "mirrors.tencent.com" }}/build/blueking/tdbctl:2.4.1_v3"
- vesion: "spider"
- version: "spider"
image: "{{ .Values.global.imageRegistry | default "mirrors.tencent.com" }}/build/blueking/tspider3:3.7.8_v1"
dbconf:
user: "{{ $dbsimulationDB.user }}"
Expand Down

0 comments on commit 017014d

Please sign in to comment.