canel-1.1.5 canal.deployer安装

article/2025/10/3 12:32:19

简介

image.png

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

工作原理

canal 模拟 MySQL slave 的交互协议,伪装自己为 MySQL slave ,向 MySQL master 发送 dump 协议

MySQL master 收到 dump 请求,开始推送 binary log 给 slave (即 canal )
canal 解析 binary log 对象(原始为 byte 流)

安装

下载canal.deployer

地址:https://github.com/alibaba/canal/releases

准备

对于自建 MySQL , 需要先开启 Binlog 写入功能,配置 binlog-format 为 ROW 模式,my.cnf 中配置如下

[mysqld]

log-bin=mysql-bin # 开启 binlog

binlog-format=ROW # 选择 ROW 模式

server_id=1 # 配置 MySQL replaction 需要定义,不要和 canal 的 slaveId 重复

注意:针对阿里云 RDS for MySQL , 默认打开了 binlog , 并且账号默认具有 binlog

dump 权限 , 不需要任何权限或者 binlog 设置,可以直接跳过这一步

授权 canal 链接 MySQL 账号具有作为 MySQL slave 的权限, 如果已有账户可直接 grant

CREATE USER canal IDENTIFIED BY ‘canal’;

GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON . TO ‘canal’@’%’;

– GRANT ALL PRIVILEGES ON . TO ‘canal’@’%’ ;

FLUSH PRIVILEGES;

启动

下载 canal, 访问 release 页面 , 选择需要的包下载, 如以 1.0.17 版本为例

wget https://github.com/alibaba/canal/releases/download/canal-1.0.17/canal.deployer-1.0.17.tar.gz

解压缩

mkdir /tmp/canal
tar zxvf canal.deployer-$version.tar.gz -C /tmp/canal

解压完成后,进入 /tmp/canal 目录,可以看到如下结构

drwxr-xr-x 2 jianghang jianghang  136 2013-02-05 21:51 bin
drwxr-xr-x 4 jianghang jianghang  160 2013-02-05 21:51 conf
drwxr-xr-x 2 jianghang jianghang 1.3K 2013-02-05 21:51 lib
drwxr-xr-x 2 jianghang jianghang   48 2013-02-05 21:29 logs

配置修改

vi conf/example/instance.properties

##mysql serverId
canal.instance.mysql.slaveId = 1234
#position info,需要改成自己的数据库信息
canal.instance.master.address = 127.0.0.1:3306 
canal.instance.master.journal.name = 
canal.instance.master.position = 
canal.instance.master.timestamp = 
#canal.instance.standby.address = 
#canal.instance.standby.journal.name =
#canal.instance.standby.position = 
#canal.instance.standby.timestamp = 
#username/password,需要改成自己的数据库信息
canal.instance.dbUsername = canal  
canal.instance.dbPassword = canal
canal.instance.defaultDatabaseName =
canal.instance.connectionCharset = UTF-8
#table regex
canal.instance.filter.regex = .\*\\\\..\*
canal.instance.connectionCharset 代表数据库的编码方式对应到 java 中的编码类型,比如 UTF-8,GBK , ISO-8859-1
如果系统是1个 cpu,需要将 canal.instance.parser.parallel 设置为 false

启动

sh bin/startup.sh

查看 server 日志

vi logs/canal/canal.log

2013-02-05 22:45:27.967 [main] INFO  com.alibaba.otter.canal.deployer.CanalLauncher - ## start the canal server.
2013-02-05 22:45:28.113 [main] INFO  com.alibaba.otter.canal.deployer.CanalController - ## start the canal server[10.1.29.120:11111]
2013-02-05 22:45:28.210 [main] INFO  com.alibaba.otter.canal.deployer.CanalLauncher - ## the canal server is running now ......

查看 instance 的日志

vi logs/example/example.log

2013-02-05 22:50:45.636 [main] INFO  c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [canal.properties]
2013-02-05 22:50:45.641 [main] INFO  c.a.o.c.i.spring.support.PropertyPlaceholderConfigurer - Loading properties file from class path resource [example/instance.properties]
2013-02-05 22:50:45.803 [main] INFO  c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start CannalInstance for 1-example 
2013-02-05 22:50:45.810 [main] INFO  c.a.otter.canal.instance.spring.CanalInstanceWithSpring - start successful....

关闭

sh bin/stop.sh

--------------------------------文章来源 https://www.byteblogs.com/article/200


http://chatgpt.dhexx.cn/article/eBVWkZ0S.shtml

相关文章

Kubernetes基于canel的网络策略

Calico的官方地址:https://docs.projectcalico.org/v3.8/getting-started/kubernetes/installation/flannel 安装canel之前需要注意 如果您使用的是pod CIDR 10.244.0.0/16,请跳至下一步。如果您使用的是其他pod CIDR,请使用以下命令设置一个…

binlog以及Canel

一、NDB存储引擎 在介绍binlog之前,需要先了解一下NDB NDB 存储引擎也叫NDB Cluster 存储引擎,主要用于MySQL Cluster 分布式集群环境。 NDB特点: • 分布式:分布式存储引擎,可以由多个NDBCluster存储引擎组成集群分别存放整体数据的一部分 • 支持事务:和Innodb一样…

canel的网络策略

资源: https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/flannel 基于pod Egress 是Pod作为客户端(需要定义目标端口和目标地址) ingress 是pod作为服务端(需要定义目标地址和pod自己的端口) canel工作的默认网段是192.168.0.0/16的网…

超详细的Canal入门,看这篇就够了!

思维导图 文章已收录Github精选,欢迎Star:https://github.com/yehongzhi/learningSummary 前言 我们都知道一个系统最重要的是数据,数据是保存在数据库里。但是很多时候不单止要保存在数据库中,还要同步保存到Elastic Search、HB…

数据同步神器Canel-day01

背景 关于数据同步的方式有很多种,现在有一个场景需要将mysql数据库的数据主动同步到我们的工程中,并且能再mysql数据库客户端更改某一行的数据也能将数据同步到另一个数据库或者工程中,对于这种场景的使用我们应该怎么去实现呢?…

Canal使用流程、部署安装文档

文章目录 背景信息使用流程步骤一:准备MySQL数据源步骤二:创建索引步骤三:安装并启动Canal-server(Deployer)步骤四:部署Client-Adapter步骤五:验证增量数据同步步骤六:同步MySQL全量数据(如果不…

Canel-简介使用

简介 canal 的工作原理 MySQL 主从复制过程 ➢ Master 主库将改变记录,写到二进制日志(binary log)中 ➢ Slave 从库向 mysql master 发送 dump 协议,将 master 主库的 binary log events 拷贝到它的中继日志(relay log); ➢ Slave 从…

检查页面Session是否过期,过期执行相应操作 解决方法

how to check session is expired or not if expired then redirect to login page 在项目中,如果客户打开页面时间过久容易导致页面Session过期,再进行任何操作时都会提示“Asp.Net session has expired”,这样毕竟都用户不太友好&#xff0…

thinkphp如何有效的设置session过期时间

thinkphp提供了一个参数让我们配置session过期时间。 SESSION_OPTIONS array(expire > 3600 ); 然而这一配置是否真的有效?在多次测试之后,不遂人意。 why?那我们试着从源码上分析这个配置参数的,它是怎么让尝试着然我们的…

session过期时间设置

设置session过期有三种方法: 1.在tomcat中进行设置 tomcat的conf文件下的,web.xml文件中 tomcat默认session超时时间为30分钟,可以根据需要修改,负数或0为不限制session失效时间 这里要注意这个session设置的时间是根据服务器来…

springboot+shiro中自定义session过期时间

在springboot工程中,使用shiro作为权限框架,并采用redis来管理session时,如何自定义session过期时间? 上面与会话或缓存相关的组件有: Session Manager:会话管理器Session DAO:会话 DAO&#…

JAVA WEB 设置session过期时间

1.在web容器中设置 &#xff08;以tomcat为例,Tomcat默认session超时时间为30分钟&#xff09; 在tomcat/conf/web.xml里面进行配置&#xff0c;单位是分钟&#xff0c;永不过期可以设置-1 <session-config> <!-- 时间单位为分钟--> <session-timeout>30&…

springboot2.0设置session过期时间。

目的&#xff1a;springboot2.0设置session过期时间。 网上很多设置 springboot session 过期时间&#xff0c;已经不适合 springboot2.0. 下面这个我亲测有效。 请注意格式&#xff1a;我这个用的是 application.yml servlet:session:timeout: 3600s 所有文章优先发布在个人…

Java 设置session过期时间

设置session过期或超时时间 设置session的过期或超时时间&#xff0c;有三个地方&#xff1a; a、tomcat的web.xml中&#xff0c;该单位为分&#xff1a; Xml代码 <session-config> <session-timeout>720</session-timeout> </session-config>…

web 项目中设置session过期时间

java web项目中要想设置session过期时间&#xff0c;有三种设置方法&#xff0c;都是给与某个过期时间值&#xff0c;其中-1 代表session永远不会过期。 1. 第一种方式&#xff1a;通过代码设置方式&#xff0c;其中600表示600秒 2. 第二种方式&#xff1a;通过web.xml方式&am…

session会话过期时间设置

具体设置很简单&#xff0c;方法有三种&#xff1a; &#xff08;1&#xff09;在主页面或者公共页面中加入&#xff1a;session.setMaxInactiveInterval(900); 参数900单位是秒&#xff0c;即在没有活动15分钟后&#xff0c;session将失效。设置为-1将永不关闭。 这里要注意…

关于Session过期/失效的理解,session与cookie的交互

一直好奇关于Session的过期&#xff0c;一种说法是关闭浏览器即Session失效&#xff0c;另一种说法是可以设置Session的过期时间&#xff0c;时间到了自动过期。 这两种说法到底是怎么回事&#xff1f;Session过期跟Cookie过期又有什么关系&#xff1f; 网上搜了几篇相关文章…

数据库 存储过程

创建存储过程 create procedures_student sex varchar&#xff08;10&#xff09; as select * from 学生信息 where 性别sex 这样就创建了一个存储过程 exec proc_student sex女 使用带默认值的参数 create proc p_employee departmentid varchar&…

数据库--存储过程

介绍 对sql语句进行封装、复用 创建、调用 --存储过程 --创建 create procedure p1() beginselect count(*) from t_test;end;--调用 call p1();存储过程查看、删除 --查看 select * from information_schema.ROUTINES WHERE ROUTINE_SCHEMA test SHOW create procedure p1…

SQL Sever数据库存储过程

一、背景介绍 1.遇到存储过程 回顾之前知识&#xff0c;使用在当下&#xff08;毕业设计&#xff09; 2.了解周边知识 二、思路&方案 1.了解存储过程定义、语法、种类 2.存储过程有什么优缺点 3。存储过程与触发器和函数的联系 三、过程 1.什么是存储过程&#xff1f;…