阿里开源的MySQL 数据库增量日志解析,提供增量数据订阅和消费。

agapple df86f94409 fixed issue template 6 anni fa
.github df86f94409 fixed issue template 6 anni fa
.mvn e7b81cd83a fixed mvn wrapper 6 anni fa
client fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
client-adapter 21309cb065 resove Could not resolve dependencies for project com.alibaba.otter:client-adapter.hbase:jar:1.1.4-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.7 at specified path 6 anni fa
common fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
dbsync fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
deployer fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
docker 46b6528273 fixed tablemeta check 6 anni fa
driver fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
example fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
filter fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
images 5588da59b9 Update response time image. 6 anni fa
instance fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
meta 55030476ee reverse jdk to 1.8 6 anni fa
parse fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
prometheus fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
protocol fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
server 69df50fe17 fixed issue #1672 , CanalKafkaProducer send 6 anni fa
sink fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
store fadfe1d6ca [maven-release-plugin] prepare for next development iteration 6 anni fa
.gitignore a81d2710ff fixed MQ partition 6 anni fa
.travis.yml 2b8120b6ed update pom 6 anni fa
LICENSE.txt a0defe575b init 10 anni fa
README.md 6febcf1a0f add test coverage and jdk11 6 anni fa
RELEASE.txt a0defe575b init 10 anni fa
codeformat.xml 7ebb3fd1ab fixed code template and format 10 anni fa
codetemplates.xml 7ebb3fd1ab fixed code template and format 10 anni fa
mvnw 2810e7e815 add mvnw 6 anni fa
pom.xml cd007088db reverse jdk to 1.8 6 anni fa

README.md

<div class="iteye-blog-content-contain">

Build Status codecov maven license Average time to resolve an issue Percentage of issues still open

背景

早期,阿里巴巴B2B公司因为存在杭州和美国双机房部署,存在跨机房同步的业务需求。不过早期的数据库同步业务,主要是基于trigger的方式获取增量变更,不过从2010年开始,阿里系公司开始逐步的尝试基于数据库的日志解析,获取增量变更进行同步,由此衍生出了增量订阅&消费的业务,从此开启了一段新纪元。

ps. 目前内部版本已经支持mysql和oracle部分版本的日志解析,当前的canal开源版本支持5.7及以下的版本(阿里内部mysql 5.7.13, 5.6.10, mysql 5.5.18和5.1.40/48)

基于日志增量订阅&消费支持的业务:

  1. 数据库镜像
  2. 数据库实时备份
  3. 多级索引 (卖家和买家各自分库索引)
  4. search build
  5. 业务cache刷新
  6. 价格变化等重要业务消息

项目介绍

名称:canal [kə'næl]

译意: 水道/管道/沟渠

语言: 纯java开发

定位: 基于数据库增量日志解析,提供增量数据订阅&消费,目前主要支持了mysql

关键词: mysql binlog parser / real-time / queue&topic

工作原理

mysql主备复制实现


从上层来看,复制分成三步:

  1. master将改变记录到二进制日志(binary log)中(这些记录叫做二进制日志事件,binary log events,可以通过show binlog events进行查看);
  2. slave将master的binary log events拷贝到它的中继日志(relay log);
  3. slave重做中继日志中的事件,将改变反映它自己的数据。

canal的工作原理:

原理相对比较简单:

  1. canal模拟mysql slave的交互协议,伪装自己为mysql slave,向mysql master发送dump协议
  2. mysql master收到dump请求,开始推送binary log给slave(也就是canal)
  3. canal解析binary log对象(原始为byte流)

重要版本更新说明

canal 1.1.x系列,参考release文档:版本发布信息

  1. 整体性能测试&优化,提升了150%. #726 参考: 【Performance
  2. 原生支持prometheus监控 #765Prometheus QuickStart
  3. 原生支持kafka消息投递 #695Canal Kafka/RocketMQ QuickStart
  4. 原生支持aliyun rds的binlog订阅 (解决自动主备切换/oss binlog离线解析) 参考: 【Aliyun RDS QuickStart
  5. 原生支持docker镜像 #801 参考: 【Docker QuickStart

相关文档

See the wiki page for : wiki文档

wiki文档列表

多语言业务

  1. canal整体交互协议设计上使用了protobuf3.0,理论上可以支持绝大部分的多语言场景,欢迎大家提交多客户端的PR
  2. canal作为MySQL binlog的增量获取工具,可以将数据投递到MQ系统中,比如Kafka/RocketMQ,可以借助于MQ的多语言能力

相关资料

相关开源

  1. 阿里巴巴分布式数据库同步系统(解决中美异地机房):http://github.com/alibaba/otter
  2. 阿里巴巴去Oracle数据迁移同步工具(目标支持MySQL/DRDS):http://github.com/alibaba/yugong

相关产品

  1. 阿里云分布式数据库DRDS
  2. 阿里云数据传输服务DTS
  3. 阿里云数据库备份服务DBS
  4. 阿里云数据管理服务DMS

问题反馈

  1. qq交流群: 161559791
  2. 邮件交流: jianghang115@gmail.com
  3. 新浪微博: agapple0002
  4. 报告issue:issues

最新更新

  1. canal发布重大版本更新1.1.0,具体releaseNode参考:https://github.com/alibaba/canal/releases/tag/canal-1.1.0
  2. canal c#客户端开源项目地址: https://github.com/dotnetcore/CanalSharp ,推荐!
  3. canal QQ讨论群已经建立,群号:161559791 ,欢迎加入进行技术讨论。
  4. canal消费端项目开源: Otter(分布式数据库同步系统),地址:https://github.com/alibaba/otter

  • Canal已在阿里云推出商业化版本 数据传输服务DTS, 开通即用,免去部署维护的昂贵使用成本。DTS针对阿里云RDS、DRDS等产品进行了适配,解决了Binlog日志回收,主备切换、VPC网络切换等场景下的订阅高可用问题。同时,针对RDS进行了针对性的性能优化。出于稳定性、性能及成本的考虑,强烈推荐阿里云用户使用DTS产品。DTS产品使用文档
  • DTS支持阿里云RDS&DRDS的Binlog日志实时订阅,现推出首月免费体验,限时限量,立即体验>>>