当前位置:网站首页>Canal 的学习笔记
Canal 的学习笔记
2022-07-26 09:03:00 【白居不易.】
Canal 的学习笔记
1. 简介
官网:https://github.com/alibaba/canal
Canal,译意为水道/管道/沟渠,主要用途是基于 MySQL 数据库增量日志解析,提供增量数据订阅和消费。
canal 是用java开发的基于数据库增量日志解析,提供增量数据订阅&消费的中间件。目前,canal主要支持了MySQL的binlog 解析,解析完成后才利用 canal client 用来处理获得的相关数据。(数据库同步需要阿里的otter中间件,基于canal)
这里我们可以简单地把canal 理解为一个用来同步增量数据的一个工具。
早期阿里巴巴因为杭州和美国双机房部署,存在跨机房同步的业务需求,实现方式主要是基于业务 trigger 获取增量变更。从 2010 年开始,业务逐步尝试数据库日志解析获取增量变更进行同步,由此衍生出了大量的数据库增量订阅和消费业务。
基于日志增量订阅和消费的业务包括
- 数据库镜像
- 数据库实时备份
- 索引构建和实时维护(拆分异构索引、倒排索引等)
- 业务 cache 刷新
- 带业务逻辑的增量数据处理
当前的 canal 支持源端 MySQL 版本包括 5.1.x,5.5.x,5.6.x,5.7.x,8.0.x
2. 工作原理
MySQL主备复制原理
- MySQL master 将数据变更写入二进制日志(binary log,其中记录叫做二进制日志事件binary log events,可以通过 show binlog events 进行查看)
- MySQL slave 将 master 的 binary log events 拷贝到它的中继日志(relay log)
- MySQL slave 重放 relay log 中事件,将数据变更反映它自己的数据
canal工作原理
- cannl 模拟 MySQL slave 的交互协议,伪装自己为 MySQL slave,向MySQL master 发送dump 协议
- MySQL master 收到 dump 请求,开始推送 binary log 给 slave (即 canal)
- canal 解析 binary log 对象(原始为 byte 流),再发送到存储目的地,比如MySQL,Kafka,Elastic Search 等等。
3. canal下载地址
下载地址:https://github.com/alibaba/canal/releases
边栏推荐
- Sklearn machine learning foundation (linear regression, under fitting, over fitting, ridge regression, model loading and saving)
- redis原理和使用-基本特性
- Clean the label folder
- Simple message mechanism of unity
- 李沐d2l(六)---模型选择
- Zipkin安装和使用
- Mutual transformation of array structure and tree structure
- Elastic APM安装和使用
- 03 exception handling, state keeping, request hook -- 04 large project structure and blueprint
- 基于序的评价指标 (特别针对推荐系统和多标签学习)
猜你喜欢
随机推荐
How to quickly learn a programming language
高数 | 武爷『经典系列』每日一题思路及易错点总结
Kotlin properties and fields
力扣题DFS
Espressif plays with the compilation environment
Introduction to excellent verilog/fpga open source project (30) - brute force MD5
209. Subarray with the smallest length
What are the differences in the performance of different usages such as count (*), count (primary key ID), count (field) and count (1)? That's more efficient
Regular expression: judge whether it conforms to USD format
Center an element horizontally and vertically
day06 作业--技能题6
Set of pl/sql -2
Numpy Foundation
tornado之多进程服务
Learn more about the difference between B-tree and b+tree
redis原理和使用-基本特性
Laravel框架日志文件存放在哪里?怎么用?
机器学习中的概率模型
Qtcreator reports an error: you need to set an executable in the custom run configuration
JDBC数据库连接池(Druid技术)