当前位置: 首页 > 工具软件 > MySQL Syncer > 使用案例 >

mysql syncer_MySQL实时同步数据到TiDB指引

艾善
2023-12-01

$vim /home/tidb/tidb-enterprise-tools-latest-linux-amd64/conf/config.toml

log-level = "info"

log-file = "/home/tidb/tidb-enterprise-tools-latest-linux-amd64/log/syncer.log"

log-rotate = "day"

server-id = 3

## meta 文件地址

meta = "/home/tidb/tidb-enterprise-tools-latest-linux-amd64/conf/syncer.meta"

worker-count = 16

batch = 1000

flavor = "mysql"

## pprof 调试地址,Prometheus 也可以通过该地址拉取 Syncer metrics

status-addr = ":8271"

## 如果设置为 true,Syncer 遇到 DDL 语句时就会停止退出

stop-on-ddl = false

## 跳过 DDL 语句,格式为 **前缀完全匹配**,如:`DROP TABLE ABC` 至少需要填入 `DROP TABLE`

# skip-ddls = ["ALTER USER", "CREATE USER"]

## 在使用 route-rules 功能后,

## replicate-do-db & replicate-ignore-db 匹配合表之后 (target-schema & target-table) 数值

## 优先级关系: replicate-do-db --> replicate-do-table --> replicate-ignore-db --> replicate-ignore-table

## 指定要同步数据库名;支持正则匹配,表达式语句必须以 `~` 开始

#replicate-do-db = ["~^b.*","s1"]

replicate-do-db = ["notify"]

## 指定 **忽略** 同步数据库;支持正则匹配,表达式语句必须以 `~` 开始

#replicate-ignore-db = ["~^b.*","s1"]

# skip-dmls 支持跳过 DML binlog events,type 字段的值可为:'insert','update' 和 'delete'

# 跳过 foo.bar 表的所有 delete 语句

# [[skip-dmls]]

# db-name = "foo"

# tbl-name = "bar"

# type = "delete"

#

# 跳过所有表的 delete 语句

# [[skip-dmls]]

# type = "delete"

#

# 跳过 foo.* 表的 delete 语句

# [[skip-dmls]]

# db-name = "foo"

# type = "delete"

## 指定要同步的 db.table 表

## db-name 与 tbl-name 不支持 `db-name ="dbname,dbname2"` 格式

#[[replicate-do-table]]

#db-name ="site_message"

#tbl-name = "business_user_link"

#[[replicate-do-table]]

#db-name ="site_message"

#tbl-name = "service_user_link"

#[[replicate-do-table]]

#db-name ="site_message"

#tbl-name = "message_business"

#[[replicate-do-table]]

#db-name ="site_message"

#tbl-name = "*"

#[[replicate-do-table]]

#db-name ="dbname1"

#tbl-name = "table-name1"

## 指定要同步的 db.table 表;支持正则匹配,表达式语句必须以 `~` 开始

#[[replicate-do-table]]

#db-name ="test"

#tbl-name = "~^a.*"

## 指定 **忽略** 同步数据库

## db-name & tbl-name 不支持 `db-name ="dbname,dbname2"` 语句格式

#[[replicate-ignore-table]]

#db-name = "your_db"

#tbl-name = "your_table"

## 指定要 **忽略** 同步数据库名;支持正则匹配,表达式语句必须以 `~` 开始

#[[replicate-ignore-table]]

#db-name ="test"

#tbl-name = "~^a.*"

# sharding 同步规则,采用 wildcharacter

# 1. 星号字符 (*) 可以匹配零个或者多个字符,

#    例子, doc* 匹配 doc 和 document, 但是和 dodo 不匹配;

#    星号只能放在 pattern 结尾,并且一个 pattern 中只能有一个

# 2. 问号字符 (?) 匹配任一一个字符

#[[route-rules]]

#pattern-schema = "route_*"

#pattern-table = "abc_*"

#target-schema = "route"

#target-table = "abc"

#[[route-rules]]

#pattern-schema = "route_*"

#pattern-table = "xyz_*"

#target-schema = "route"

#target-table = "xyz"

[from]

host = "192.168.1.98"

user = "root"

password = "xxxxxx"

port = 3306

[to]

host = "10.8.8.240"

user = "tidb"

password = "xxxxxx"

port = 4000

 类似资料: