TIDB作为mysql的从库使用

1,TIDB安装部署

link

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;

小结:syncer在使用过程中,如果遇到同步一场,会立刻退出程序,没有异常处理机制,如果在生产上使用还是建议使用官方的DM工具。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值