Coder Social home page Coder Social logo

jihenry / go-mysql-syncer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hacktmz/go-mysql-syncer

0.0 0.0 0.0 513 KB

基于go-mysql & gorail二次开发的binlog解析工具,使用MQ跨机房同步,增加了修改表结构后依然能正常工作的特性,多个mysql同时处理的功能

Makefile 0.47% Go 99.53%

go-mysql-syncer's Introduction

go-mysql-syncer

  • 一个基于go-mysql &gorail二次开发的binlog解析工具,最终生成SQL语句使用MQ发送到消费者进行执行(这里使用banyandb的Queue可更换成kafka)
  • 增加了修改表结构(alter table)和创建库表(create table)后依然能正常工作的特性
  • 数据分库处理(后期可能会精确到表)
  • 多个mysql实例同时处理的功能
  • 解决跨机房mysql自带同步缓慢的问题
    • 修改了go-mysql源码所以必须使用vendor下的包
  • consumer 多实例分库消费,数据保证不丢失

build

  • make
  • ./Producer
  • ./Consumer

config

producer

  • 在conf目录下修改 producer.toml 配置mysql地址,banyandb集群agent地址和库表,mysql主库可以添加多个同时处理,只要保证id 、data_path和ns table选项不重复即可
  • 程序运行后会在conf目录下生成data_path配置的master.info文件,保存binlog文件名 pos号信息
    • 如果同步遇到drop table、drop database命令或者程序异常中断之后有表结构更改(alter table)命令那么需要删除master.info文件并手动进行全量同步,否则可能出现解析表字段名异常

consumer

  • 参考producer对应的配置修改 consumer.toml

架构图

go-mysql-syncer's People

Contributors

hacktmz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.