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.配置同步需要的文件:
上一篇: 数据库与TiDB的同步
下一篇: TiDB学习之 MySQL数据同步