---
title: "建立主从关系"
method: POST
path: "/mysql/change-master"
tags: ["mysql"]
---

# 建立主从关系

`POST /mysql/change-master`

执行 change master to

## Request body

- DbmServicesMysqlDbToolsDbactuatorPkgComponentsMysqlBuildMSRelationComp
  - `extend` DbmServicesMysqlDbToolsDbactuatorPkgComponentsMysqlBuildMSRelationParam
    - `bin_file` string, required — binlog 文件名称
    - `bin_position` integer, required — binlog 位点信息
    - `force` boolean — 如果当前实例存在主从关系是否直接reset slave后,强制change master
    - `host` string, required — 具体操作内容需要操作的参数
    - `is_gtid` boolean — 是否启动GID方式进行建立主从
    - `master_host` string, required — change master to 主库ip
    - `master_port` integer, required — change master to 主库端口
    - `max_tolerate_delay` integer — 最大容忍延迟, 当 主从延迟 小于 该值, 认为建立主从关系成功. 不传或者为 0 时，表示不检查
    - `not_start_io_thread` boolean — 不启动 io_thread。默认false 表示启动 io_thread
    - `not_start_sql_thread` boolean — 不启动 sql_thread。默认false 表示启动 sql_thread
    - `port` integer, required — 当前实例的端口
  - `general` DbmServicesMysqlDbToolsDbactuatorPkgComponentsGeneralParam
    - `runtime_account` DbmServicesMysqlDbToolsDbactuatorPkgComponentsRuntimeAccountParam
      - `admin_pwd` string — mysql admin 密码，环境变量 GENERAL_ACCOUNT_admin_pwd
      - `admin_user` string — mysql admin 账户，环境变量 GENERAL_ACCOUNT_admin_user
      - `backup_pwd` string — dbbackup pwd
      - `backup_user` string — dbbackup user
      - `monitor_access_all_pwd` string — mysql monitor@% 密码
      - `monitor_access_all_user` string — mysql monitor@%
      - `monitor_pwd` string — mysql monitor 密码，环境变量 GENERAL_ACCOUNT_monitor_pwd
      - `monitor_user` string — mysql monitor 账户，环境变量 GENERAL_ACCOUNT_monitor_user
      - `proxy_admin_pwd` string — proxy admin pwd
      - `proxy_admin_user` string — proxy admin user
      - `repl_pwd` string — repl pwd, 环境变量 GENERAL_ACCOUNT_repl_pwd
      - `repl_user` string — repl user, 环境变量 GENERAL_ACCOUNT_repl_user
      - `tdbctl_pwd` string
      - `tdbctl_user` string
      - `yw_pwd` string — yw pwd
      - `yw_user` string — yw user
    - `runtime_extend` DbmServicesMysqlDbToolsDbactuatorPkgComponentsRuntimeExtend
      - `mysql_sys_users` string[]

---

[API](https://skmtc.net/tencentblueking/apis/dbactuator-api.md) · [All operations](https://skmtc.net/tencentblueking/apis/dbactuator-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tencentblueking/dbactuator-api/versions/dc22dd49fd50/schema)
