1,TIDB安装部署
2,全量数据同步:
下载官方同步工具
[root@tidb1 ~]# wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
[root@tidb1 ~]# tar xvf tidb-latest-linux-amd64.tar.gz
[root@tidb1 ~]# mv tidb-latest-linux-amd64 tidb-tool
[root@tidb1 ~]# cd tidb-tool/bin/
[root@tidb1 ~]# ./mydumper -h 192.168.50.2 -P 3306 -u root -p 123456 -t 16 -F 128 --regex '^(?!(mysql|sys))' -o ./test
全量导出数据,排除mysql,sys,默认会自动排除information_schema和performance_schema两个库
3,导入全量数据:
[root@tidb1 ~]# ./loader -u root -p 123456 -h 192.168.50.31 -P 4000 -t 16 -d ./test
4,增量数据导入:
[root@tidb1 test]# cat metadata
Started dump at: 2019-04-11 16:10:41
SHOW MASTER STATUS:
Log: mysql-bin.000034
Pos: 395907578
GTID:4a5463b4-4ae5-11e9-b149-fa163ea5920b:1-114098
SHOW SLAVE STATUS:
Host: 192.168.61.3
Log:
Pos: 0
GTID:4a5463b4-4ae5-11e9-b149-fa163ea5920b:1-114098
Finished dump at: 2019-04-11 16:15:33
[root@tidb1 bin]# vi syncer.meta #新建syncer.meta文件,降对应的binlog信息填入
binlog-name = "mysql-bin.000034"
binlog-pos = 395907578
binlog-gtid = "4a5463b4-4ae5-11e9-b149-fa163ea5920b:1-114098"
[root@tidb1 bin]# cat config.toml #新建syncer的配置文件config.toml
log-level = "info"
log-file = "syncer.log"
log-rotate = "day"
server-id = 101
[from]
host = "192.168.50.2"
user = "root"
password = "123456"
port = 3306
[to]
host = "192.168.50.31"
user = "root"
password = "123456"
port = 4000
[root@tidb1 bin]# ./syncer -config config.toml --enable-gtid #启动同步进程
[2019/04/11 16:48:38] [info] binlogsyncer.go:132 create BinlogSyncer with config {101 mysql 192.168.50.2 3306 root false false <nil> false UTC true 0 30s 1m0s 0 false}
[2019/04/11 16:48:38] [info] binlogsyncer.go:364 begin to sync binlog from GTID set 4a5463b4-4ae5-11e9-b149-fa163ea5920b:1-114098
[2019/04/11 16:48:38] [info] binlogsyncer.go:195 register slave for master server 192.168.50.2
[2019/04/11 16:48:38] [info] binlogsyncer.go:715 rotate to (mysql-bin.000034, 4)
5,验证同步是否正常
[root@tidb1 bin]# mysql -uroot -p123 -h192.168.50.2 -e "use test;delete from tt_test where id=1;" #在原库删除数据
[root@tidb1 bin]# mysql -uroot -p123 -h192.168.50.31 -P4000
mysql> use test;
Database changed
mysql> select * fro tt_test limit 1;