mirror of
https://github.com/dotnetcore/CanalSharp.git
synced 2026-10-17 05:11:07 +08:00
Merge branch 'main' of https://github.com/dotnetcore/CanalSharp into main
# Conflicts: # README.md
This commit is contained in:
@@ -1,45 +1,47 @@
|
||||
# CanalSharp
|
||||
|
||||
## 重构进度
|
||||
## 重构进度
|
||||
|
||||
目前重构的版本已经完全覆盖旧版本,且性能更高,代码更优美,实现了旧版本未实现的部分功能。支持最新的 Canal
|
||||
目前重构的版本已经完全覆盖旧版本,且性能更高,代码更优美,实现了旧版本未实现的部分功能。支持最新的 Canal
|
||||
|
||||
English README.md Will be provided after the refactoring is complete.
|
||||
|
||||
旧版本代码:https://github.com/dotnetcore/CanalSharp/tree/release/0.2.0
|
||||
|
||||
| Task | Status |
|
||||
| ------------------- | ------ |
|
||||
| protobuf 3 协议生成 | 已完成 |
|
||||
| 对接 Canal | 已完成 |
|
||||
| 数据订阅封装 | |
|
||||
| 集群支持(热备) | |
|
||||
| 数据发送到Kafka | |
|
||||
| 数据发送到Redis | |
|
||||
| protobuf 3 协议生成 | 已完成 |
|
||||
| 对接 Canal | 已完成 |
|
||||
| 数据订阅封装 | |
|
||||
| 集群支持(热备) | |
|
||||
| 数据发送到Kafka | |
|
||||
| 数据发送到Redis | |
|
||||
|
||||
## 快速入门
|
||||
## 快速入门
|
||||
|
||||
>先决条件:安装Java环境和需要使用的数据库开启binlog
|
||||
>先决条件:安装Java环境和需要使用的数据库开启binlog
|
||||
|
||||
### 1.运行 Canal Server
|
||||
### 1.运行 Canal Server
|
||||
|
||||
(1)下载最新的 Canal Server https://github.com/alibaba/canal/releases/latest, 下载 `canal.deployer-版本号-SNAPSHOT.tar.gz` 文件
|
||||
(1)下载最新的 Canal Server https://github.com/alibaba/canal/releases/latest, 下载 `canal.deployer-版本号-SNAPSHOT.tar.gz` 文件
|
||||
|
||||
(2)配置
|
||||
(2)配置
|
||||
|
||||
编辑文件 `conf/example/instance.properties`
|
||||
编辑文件 `conf/example/instance.properties`
|
||||
|
||||
设置 MySql 地址:`canal.instance.master.address=`
|
||||
设置 MySql 地址:`canal.instance.master.address=`
|
||||
|
||||
设置 MySql 用户:`canal.instance.dbUsername=`
|
||||
设置 MySql 用户:`canal.instance.dbUsername=`
|
||||
|
||||
设置 MySql 密码:`canal.instance.dbPassword=`
|
||||
设置 MySql 密码:`canal.instance.dbPassword=`
|
||||
|
||||
(3)运行
|
||||
进入 `bin` 目录,根据你的系统选择脚本运行。
|
||||
(3)运行
|
||||
进入 `bin` 目录,根据你的系统选择脚本运行。
|
||||
|
||||
### 2.使用
|
||||
### 2.使用
|
||||
|
||||
````csharp
|
||||
//初始化日志
|
||||
//初始化日志
|
||||
using var loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder
|
||||
@@ -48,19 +50,19 @@ using var loggerFactory = LoggerFactory.Create(builder =>
|
||||
.AddConsole();
|
||||
});
|
||||
|
||||
//创建连接
|
||||
var conn=new SimpleCanalConnection(new SimpleCanalConnectionOptions(Canal Server 地址,端口 默认 11111,ClientId 自定义), loggerFactory.CreateLogger<SimpleCanalConnection>());
|
||||
//创建连接
|
||||
var conn=new SimpleCanalConnection(new SimpleCanalConnectionOptions(Canal Server 地址,端口 默认 11111,ClientId 自定义), loggerFactory.CreateLogger<SimpleCanalConnection>());
|
||||
|
||||
//连接到 Canal Server
|
||||
//连接到 Canal Server
|
||||
await conn.ConnectAsync();
|
||||
//订阅需要处理的数据
|
||||
//订阅需要处理的数据
|
||||
await conn.SubscribeAsync();
|
||||
while (true)
|
||||
{
|
||||
//获取数据
|
||||
//获取数据
|
||||
var msg = await conn.GetAsync(1024);
|
||||
await Task.Delay(300);
|
||||
}
|
||||
````
|
||||
|
||||
>更详细的文档将在重构完成后提供
|
||||
>更详细的文档将在重构完成后提供
|
||||
|
||||
Reference in New Issue
Block a user