GithubHelp home page GithubHelp logo

q474818917 / canal Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 17.42 MB

License: Apache License 2.0

JavaScript 1.48% HTML 0.16% Vue 2.24% SCSS 0.21% Shell 1.12% Batchfile 0.12% Java 94.29% PLpgSQL 0.23% CSS 0.01% Dockerfile 0.08% Python 0.05%

canal's Introduction

build status codecov maven license average time to resolve an issue percentage of issues still open

简介

canal [kə'næl],译意为水道/管道/沟渠,主要用途是基于 MySQL 数据库增量日志解析,提供增量数据订阅和消费

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

基于日志增量订阅和消费的业务包括

  • 数据库镜像
  • 数据库实时备份
  • 索引构建和实时维护(拆分异构索引、倒排索引等)
  • 业务 cache 刷新
  • 带业务逻辑的增量数据处理

当前的 canal 支持源端 MySQL 版本包括 5.1.x , 5.5.x , 5.6.x , 5.7.x , 8.0.x

工作原理

MySQL主备复制原理

  • MySQL master 将数据变更写入二进制日志( binary log, 其中记录叫做二进制日志事件binary log events,可以通过 show binlog events 进行查看)
  • MySQL slave 将 master 的 binary log events 拷贝到它的中继日志(relay log)
  • MySQL slave 重放 relay log 中事件,将数据变更反映它自己的数据

canal 工作原理

  • canal 模拟 MySQL slave 的交互协议,伪装自己为 MySQL slave ,向 MySQL master 发送dump 协议
  • MySQL master 收到 dump 请求,开始推送 binary log 给 slave (即 canal )
  • canal 解析 binary log 对象(原始为 byte 流)

重要版本更新说明

  1. canal 1.1.x 版本(release_note),性能与功能层面有较大的突破,重要提升包括:
  1. canal 1.1.4版本,迎来最重要的WebUI能力,引入canal-admin工程,支持面向WebUI的canal动态管理能力,支持配置、任务、日志等在线白屏运维能力,具体文档:Canal Admin Guide

文档

多语言

canal 特别设计了 client-server 模式,交互协议使用 protobuf 3.0 , client 端可采用不同语言实现不同的消费逻辑,欢迎大家提交 pull request

canal 作为 MySQL binlog 增量获取和解析工具,可将变更记录投递到 MQ 系统中,比如 Kafka/RocketMQ,可以借助于 MQ 的多语言能力

相关开源&产品

问题反馈

版本: 1.1.5-SNAPSHOT

启动:

  • 服务端:deployer模块下的CanalLauncher
  • 客户端:example模块下的SimpleCanalClientTest

架构:

一个Canal Server对应多个Instance,每个Instance包含如下几个模块:parse、sink、eventStore

  • parse:负责从Master上拉去binlog日志,进行解析
  • sink:负责binlog加工处理
  • EventStore:负责存储
  • 最后通过Client长连接请求,或者MQ消息获取binlog(MQ可以解决多客户端语言问题,同时还有并发问题)

PS:

  • 关于MQ 消费端并发问题:
1、按table进行topic划分,一个表对应一个topic
2、多partition,可以通过配置instance.properties中的partitionHash,将相同id的路由到同一个分区。

这样client端消费binlog时就可以配置多个消费者
  • 关于client-adapter:类比etl
为了解决异构数据同步问题(MySQL -> ES\HBase\Oracle),
可以通过配置字段映射关系,将client-adapter编译打包,通过spi方式加载到canal-adapter.launcher
同时在binlog被清理的情况下,client-adapter支持全量同步,通过select * from
完整工程在:client-adapter/launcher

canal's People

Contributors

agapple avatar rewerma avatar lcybo avatar wingerx avatar lovepoem avatar bucketli avatar zavakid avatar duhengforever avatar withlin avatar openzyk avatar nbqyqx avatar lulu2panpan avatar cai1987 avatar iamyeka avatar q474818917 avatar kangzhidong avatar wu-jianqiang avatar kaimingwan avatar wenerme avatar jasonhx140 avatar dinozhang avatar smilingleo avatar alextouchpal avatar jiacheo avatar wangsaner avatar wenshao avatar yakirchen avatar likeloveluck avatar dragontree101 avatar lin848497337 avatar

Watchers

James Cloos avatar  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.