当前位置: 首页 > news >正文

go解析mysql binlog_一个应用它提取MySQL binlog,解析binlog并将增量更新数据推送到不同的接收器...

DolphinBeat

Other languages: 中文

This is a high available server that pulls MySQL binlog, parses binlog and pushs incremental update data into different sinks.

The types of sink supported currently and officially are Kafka and Stdout.

Features:

Supports MySQL and MariaDB.

Supports GTID and not GTID.

Supports MySQL failover: if using GTID, dolphinbeat can work smoothly even if MySQL failover.

Supports MySQL DDL: dolphinbeat can parse DDL statement and replay DDL upon it's own schema data in memory.

Supports breakpoint resume: dolphinbeat has persistent metadata, it can resume to work after crash recover.

Supports standalone and election mode: if election enabled, dolphinbeat follower will take over dead leader.

Supports filter rules base on database and table for each sink.

Supports HTTP API to inspect dolphinbeat.

Supports metrics in Prometheus style.

The types of sink are scalable, you can implement your own sink if need, but I recommend you to use Kafka sink and let business consumes data from Kafka.

Quick start

Prepare your MySQL source, trun on binlog with ROW format, and type following commands and you will see JSON printed by dolphinbeat's Stdout sink.

docker run -e MYSQL_ADDR='8.8.8.8:3306' -e MYSQL_USER='root' -e MYSQL_PASSWORD='xxx' bytewatch/dolphinbeat

{

"header": {

"server_id": 66693,

"type": "rotate",

"timestamp": 0,

"log_pos": 0

},

"next_log_name": "mysql-bin.000008",

"next_log_pos": 4

}

...

...

The docker image above is for MySQL with GTID and only with Stdout sink enabled.

If your source database is not GTID, please add -e GTID_ENABLED='false' arg. If your source database is MariaDB, please add -e FLAVOR='mariadb' arg.

If you want to have a deep test, type following commands and you will get a shell:

docker run -e MYSQL_ADDR='8.8.8.8:3306' -e MYSQL_USER='root' -e MYSQL_PASSWORD='xxx' sh

In this shell, you can modify configurations in /data directory, and then start dolphinbeat manually.

Configuration description is presented in Wiki.

Compile from source

Type following commands and you will get builded binary distribution at build/dolphinbeat directory:

go get github.com/bytewatch/dolphinbeat

make

Documents

Sink

Kafka

This is a sink used for production. Dolphinbeat write data encoded with Protobuf into Kafka and business consumes data from Kafka.

Business need use client library to decode data in Kafka message, do stream processing on the binlog stream.

The Protobuf protocol is presented in protocol.proto.

Kafka sink has following features:

Strong-ordered delivery: business will receive events in the same order with MySQL binlog.

Exactly-once delivery: client library can dedup duplicated message with same sequence number which may caused by producer retry or Kafka failover.

Unlimited event size: dolphinbeat use fragments algorithm like IPV4 if the binlog event is bigger than Kafka's max message size.

A small example using client library is presented in kafka-consumer.

kafka-consumer is a command tool to decode data in Kafka message and print out with JSON.

Stdout

This is a sink used for demonstration. Dolphinbeat write data encoded with JSON to Stdout.

Stdout sink doesn't support breakpoint resume.

Special thanks

Thank siddontang for his popular and powerful go-mysql library!

License

相关文章:

  • java运行时读取注解_Java自定义注解和运行时靠反射获取注解
  • java long polling_如何在Spring Boot应用程序中实现Long Polling REST endpoints ?
  • java获取其他线程的错误_java多线程开发容易犯的错误
  • java 检索数据_java代码实现搜索elasticsearch索引数据
  • java非异步线程池_Spring Boot利用@Async异步调用:ThreadPoolTaskScheduler线程池的优雅关闭详解...
  • mongo java driver 3.2_MongoDB-JAVA-Driver 3.2版本常用代碼全整理(2) - 查詢
  • java中标记怎么用_在Java中使用标记(标签)
  • java结束sql链接_数据查询时报出java.sql.SQLException: 关闭的连接
  • java 控制台画表格_Java库在控制台上构建和打印表格?
  • 242. valid anagram java_Leetcode242 Valid Anagram JAVA语言
  • java 查找大写字母_Java实现给定一个包含大写字母和小写字母的字符串,找到通过这些...
  • java 绘图球的移动_在Java上绘制2个朝不同方向移动的球,但一个消失了
  • php中购物车结算代码,jquery购物车结算功能实现方法
  • php.ini配置 耗时,配置PHP.INI监测服务器的脚本耗时
  • java自动生成测试与评估,jmeter如何自动生成测试报告
  • 《用数据讲故事》作者Cole N. Knaflic:消除一切无效的图表
  • CentOS 7 修改主机名
  • git 常用命令
  • JavaScript类型识别
  • Joomla 2.x, 3.x useful code cheatsheet
  • JS学习笔记——闭包
  • LintCode 31. partitionArray 数组划分
  • linux学习笔记
  • Mybatis初体验
  • Quartz初级教程
  • Vue全家桶实现一个Web App
  • 从输入URL到页面加载发生了什么
  • 深度解析利用ES6进行Promise封装总结
  • 数据库写操作弃用“SELECT ... FOR UPDATE”解决方案
  • 我与Jetbrains的这些年
  • 一文看透浏览器架构
  • 你对linux中grep命令知道多少?
  • Java性能优化之JVM GC(垃圾回收机制)
  • 支付宝花15年解决的这个问题,顶得上做出十个支付宝 ...
  • #WEB前端(HTML属性)
  • #我与Java虚拟机的故事#连载16:打开Java世界大门的钥匙
  • $.proxy和$.extend
  • $HTTP_POST_VARS['']和$_POST['']的区别
  • (1)(1.19) TeraRanger One/EVO测距仪
  • (10)Linux冯诺依曼结构操作系统的再次理解
  • (2022版)一套教程搞定k8s安装到实战 | RBAC
  • (HAL库版)freeRTOS移植STMF103
  • (Redis使用系列) Springboot 实现Redis消息的订阅与分布 四
  • (第27天)Oracle 数据泵转换分区表
  • (三)centos7案例实战—vmware虚拟机硬盘挂载与卸载
  • (转)es进行聚合操作时提示Fielddata is disabled on text fields by default
  • (转)socket Aio demo
  • ..thread“main“ com.fasterxml.jackson.databind.JsonMappingException: Jackson version is too old 2.3.1
  • .net mvc 获取url中controller和action
  • .NET 分布式技术比较
  • .net 获取url的方法
  • .net 使用ajax控件后如何调用前端脚本
  • .NET值类型变量“活”在哪?
  • .pyc文件是什么?
  • /使用匿名内部类来复写Handler当中的handlerMessage()方法