欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Gravity 全量同步MySQL到TiDB

程序员文章站 2022-07-13 10:02:51
...
1.准备工作:
 1.1 源库MySQL必须保证GTID复制,若是传统复制需要在线切换为GTID复制:
  #cat /etc/my.cnf
server-id                     =100
#log-bin                       =/data/mysql/mysql_bin.log
log-bin                       =mysql_bin.log
binlog_format                 =ROW
expire-logs-days              =2
gtid_mode=ON
enforce-gtid-consistency=true
  1.2在源库需要创建复制用户:
  CREATE USER _gravity IDENTIFIED BY 'gravity';
GRANT SELECT, RELOAD, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT, CREATE, INSERT, UPDATE, DELETE ON *.* TO '_gravity'@'%';
GRANT ALL PRIVILEGES ON _gravity.* TO '_gravity'@'%';


GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, RELOAD, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO '_gravity'@'cdh-pd-db-4-172' identified by 'gravity';

mysql> GRANT ALL PRIVILEGES ON `_gravity`.* TO '_gravity'@'cdh-pd-db-4-172' identified by 'gravity';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;

2.设置:
在目标库的表定义要和源库的一致。

3.配置同步需要的文件: