Debezium

您所在的位置:网站首页 mysql怎么打开使用 Debezium

Debezium

2023-04-05 03:55| 来源: 网络整理| 查看: 265

0、背景

研究一下德比齐姆 2.1 版本官方文档

(1)本系列文章

格瑞图:Debezium-0001-德比齐姆官方文档

格瑞图:Debezium-0002~0005-入门

格瑞图:Debezium-0006~0028-连接器-01-MySQL

格瑞图:Debezium-0029~0037-API 和 SPI

格瑞图:Debezium-0038~0039-运维-01-德比齐姆界面

格瑞图:Debezium-0040-教程-01-德比齐姆介绍

格瑞图:Debezium-0041~0046-教程-02-启动服务

格瑞图:Debezium-0047-教程-03-部署 MySQL 连接器-01-注册连接器监控数据库

3、Deploying the MySQL connector - 注册 MySQL 连接器(1)Registering a connector to monitor the inventory database - 注册连接器监控数据库Open a new terminal, and use the curl command to register the Debezium MySQL connector.

02.开启一个新的终端,使用 curl 命令注册德比齐姆 MySQL 连接器。

This command uses the Kafka Connect service’s API to submit a POST request against the /connectors resource with a JSON document that describes the new connector (called inventory-connector).

该命令使用卡夫卡连接服务的接口,通过提交一个描述了新的连接器(叫做 i-c)捷森文档,到 POST 请求 /connectors 资源。

This command uses localhost to connect to the Docker host. If you are using a non-native Docker platform, replace localhost with the IP address of of your Docker host.

该命令使用本地 l 连接到道客主机。如果使用了非原生道客平台,替换本地 l 为实际的道客主机爱啤地址。

$ curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '{ "name": "inventory-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "mysql", "database.port": "3306", "database.user": "debezium", "database.password": "dbz", "database.server.id": "184054", "topic.prefix": "dbserver1", "database.include.list": "inventory", "schema.history.internal.kafka.bootstrap.servers": "kafka:9092", "schema.history.internal.kafka.topic": "schemahistory.inventory" } }'HTTP/1.1 201 Created Date: Sat, 25 Mar 2023 11:49:19 GMT Location: http://localhost:8083/connectors/inventory-connector Content-Type: application/json Content-Length: 500 Server: Jetty(9.4.48.v20220622) { "name": "inventory-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "mysql", "database.port": "3306", "database.user": "debezium", "database.password": "dbz", "database.server.id": "184054", "topic.prefix": "dbserver1", "database.include.list": "inventory", "schema.history.internal.kafka.bootstrap.servers": "kafka:9092", "schema.history.internal.kafka.topic": "schemahistory.inventory", "name": "inventory-connector" }, "tasks": [], "type": "source" }%

NOTE - 注意

Windows users may need to escape the double-quotes. For example:

温豆丝用户需要转义双引号。例如:

$ curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '{ \"name\": \"inventory-connector\", \"config\": { \"connector.class\": \"io.debezium.connector.mysql.MySqlConnector\", \"tasks.max\": \"1\", \"database.hostname\": \"mysql\", \"database.port\": \"3306\", \"database.user\": \"debezium\", \"database.password\": \"dbz\", \"database.server.id\": \"184054\", \"topic.prefix\": \"dbserver1\", \"database.include.list\": \"inventory\", \"schema.history.internal.kafka.bootstrap.servers\": \"kafka:9092\", \"schema.history.internal.kafka.topic\": \"schemahistory.inventory\" } }'Otherwise, you might see an error like the following:

否则将会看到如下错误:

{ "error_code": 500, "message": "Unexpected character ('n' (code 110)): was expecting double-quote to start field name\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 4]" }

NOTE - 注意

If you use Podman, run the following command:

如果使用豆人,运行下面的命令:

curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '{ "name": "inventory-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "0.0.0.0", "database.port": "3306", "database.user": "debezium", "database.password": "dbz", "database.server.id": "184054", "topic.prefix": "dbserver1", "database.include.list": "inventory", "schema.history.internal.kafka.bootstrap.servers": "0.0.0.0:9092", "schema.history.internal.kafka.topic": "schemahistory.inventory" } }'Verify that inventory-connector is included in the list of connectors:

03.验证 i-c 已经在连接器列表里了:

$ curl -H "Accept:application/json" localhost:8083/connectors/ ["inventory-connector"]Review the connector’s tasks:

查看连接器的任务:

$ curl -i -X GET -H "Accept:application/json" localhost:8083/connectors/inventory-connectorYou should see a response similar to the following (formatted for readability):HTTP/1.1 200 OK Date: Thu, 06 Feb 2020 22:12:03 GMT Content-Type: application/json Content-Length: 531 Server: Jetty(9.4.20.v20190813) { "name": "inventory-connector", ... "tasks": [ { "connector": "inventory-connector", ① "task": 0 } ] }The connector is running a single task (task 0) to do its work. The connector only supports a single task, because MySQL records all of its activities in one sequential binlog. This means the connector only needs one reader to get a consistent, ordered view of all of the events.

连接器运行了单任务(任务 0)来做他的工作。连接器仅支持单任务,因为 MySQL 记录其所有的活动到单个顺序的膑乐哥。这就意味着连接器仅需要一个读任务就可以获取所有事件一致的、顺序的视图。

N、后记

Sweetheart Abbey, Scotland

苏格兰甜心修道院

~



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3