StreamSets MySQL Binlog解析配置

2024-09-06 11:32

本文主要是介绍StreamSets MySQL Binlog解析配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

MySQLbinlog日志作为用于MySQL主从复制的途径。 MySQL复制允许通过binlog维护多个将数据从主服务器复制到从属服务器的副本。 StreamSets可以从MySQL主数据库捕获更改,然后将更改的数据传递到Data Collector管道。
GTID是MySQL数据库事务的全局唯一ID,在MySQL中无论GTID是否打开都可以通过StreamSets处理MySQL binglog。
MySQL binlog文件提供了MySQL数据库的变化记录信息,包含有字段变化的映射记录。只包含insert,update,delete记录。在启动MySQL binlog解析之前你可以通过一个单独的pipeline 使用JDBC Query Consumeror 或者JDBC Multitable Consumer去读取MySQL之前已经存在的数据。
在配置MySQL binlog解析时,我们可以指定MySQL binlog的解析位置,或者从开始读取(beginning)。MySQL的连接可以使用用户认证或者SSL认证,还可以指定表进行复制,或者单独排除某些不需要的表。

安装配置:1,初始化JDBC Drive在启动MySQL  binlog解析同步之前,我们必须先添加MySQL JDBC drive到streamsets,否则是无法连接MySQL的。MySQL JDBC drive添加的路径为:example: /app/streamsets/streamsets-datacollector-mysql-binlog-lib/lib/mysql-connector-java-5.1.41-bin.jar2,初始化offset在启动MySQL  binlog解析同步之前,我们还可以对起始同步的binlog offset进行指定,在指定offset之后 StreamSets pipeline会从该位置一直持续的同步数据,直到streamsets停止为止。offset的设置格式根据GTID的开启与否有以下不同:GTID enabled当MySQL GTID打开时,MySQL binlog的初始化offset包含一个GTID,格式如下:<source_id>:<transaction_id>例如: 8720bebf-bb38-11e6-97b1-0242ac110004:7066GTID disabled当MySQL GTID关闭时,MySQL binlog包含binlog文件名和日志偏移量:<binary log file name>:<position>列如:mysql-bin.000004:587

注意:如果在使用MySQL binlog 解析管道后更改数据库服务器上的GTID模式,则必须重置offset并更改初始偏移值的格式。 否则将无法正确读取偏移量。
当管道停止时,MySQL binlog pipeline将记录其停止读取的偏移量。 当pipeline再次启动时,将从上一次保存的偏移继续进行处理。 您可以重置offset来处理所有请求的对象。

CRUD operation type

MySQL在binlog中为每个事务生成一个记录。 该记录包括包含操作类型,更改数据捕获信息和已更改数据的字段和记录头属性。
注意:如果将binlog中记录的事务回滚到MySQL数据库中,MySQL将原始事务保留在日志中,然后记录回滚事务。 因此,MySQL binlog可以处理在原始事务和回滚事务。
每个生成的记录包括以下信息:
 CRUD操作类型
 CRUD操作类型存储在类型记录字段中,也存储在sdc.operation.type记录头属性中。
 类型字段包含以下字符串值之一:INSERT,DELETE或UPDATE。
sdc.operation.type记录头属性包含以下数值之一:
1用于插入数据
2用于删除数据
3用于更新数据
可以使用类型记录字段或sdc.operation.type记录头属性将记录写入目标系统。 支持CRUD的目标,例如JDBC Producer和Kudu,使用sdc.operation.type头属性。
Change data capture information
更改数据捕获信息存储在以下记录字段中:
BinLogFilename - 禁用GTID时
BinLogPosition - 禁用GTID时
SeqNo - 启用GTID时
GTID - 启用GTID时
table
ServerId
database
timestamp
offset
New data:
包含要插入或更新的新数据的字段显示在“数据映射”字段中。
Changed data
包含要更新的旧数据或删除记录中的字段的字段将显示在OldData映射字段中。
例如,当从启用GTID的MySQL服务器的二进制日志文件中读取时,将生成以下记录:
Configuring a MySQL Binary Log Origin
Configure a MySQL Binary Log origin to process change data capture (CDC) information provided by MySQL binary logs.

In the Properties panel, on the General tab, configure the following properties:
General Property Description
Name Stage name.
Description Optional description.
On Record Error Error record handling for the stage:
• Discard - Discards the record.
• Send to Error - Sends the record to the pipeline for error handling.
• Stop Pipeline - Stops the pipeline.
On the MySQL Binary Log tab, configure the following properties:
MySQL Binary Log Property Description
Hostname MySQL server hostname.
Port MySQL server port.
Server ID Replication server ID that the origin uses to connect to the master MySQL server. Must be unique from the server ID of the replication master and of all the other replication slaves.
When the MySQL server database is enabled for GTID, the server ID is optional.
Start from Beginning Specifies whether to start reading events from the beginning of the binary log. When not selected, the origin begins reading events from the last saved offset.
Initial Offset Read events starting at this offset in the binary log.
If you configure an initial offset value and configure the origin to start from the beginning, then the origin starts reading from the initial offset.
On the Credentials tab, configure the following properties:
Credentials Property Description
Username MySQL username.
The user must have the REPLICATION SLAVE MySQL privilege.
Password MySQL password.
Tip: To secure sensitive information such as usernames and passwords, you can use runtime resources or Hashicorp Vault secrets. For more information, see Using Runtime Resources or Accessing Hashicorp Vault Secrets.
On the Advanced tab, configure the following properties:
Advanced Property Description
Batch Wait Time (ms) Number of milliseconds to wait before sending a partial or empty batch.
Max Batch Size (records) Maximum number of records processed at one time. Honors values up to the Data Collector maximum batch size.
Default is 1000. The Data Collector default is 1000.
Connection Timeout (ms) Maximum time in milliseconds to wait for a connection to the MySQL server.
Use SSL Specifies whether to use SSL/TLS to connect to the MySQL server.
Include Tables List of tables to include when reading change events in the binary log file.
Ignore Tables List of tables to ignore when reading change events in the binary log file.

这篇关于StreamSets MySQL Binlog解析配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1141885

相关文章

使用Jackson进行JSON生成与解析的新手指南

《使用Jackson进行JSON生成与解析的新手指南》这篇文章主要为大家详细介绍了如何使用Jackson进行JSON生成与解析处理,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. 核心依赖2. 基础用法2.1 对象转 jsON(序列化)2.2 JSON 转对象(反序列化)3.

Springboot @Autowired和@Resource的区别解析

《Springboot@Autowired和@Resource的区别解析》@Resource是JDK提供的注解,只是Spring在实现上提供了这个注解的功能支持,本文给大家介绍Springboot@... 目录【一】定义【1】@Autowired【2】@Resource【二】区别【1】包含的属性不同【2】@

MySQL双主搭建+keepalived高可用的实现

《MySQL双主搭建+keepalived高可用的实现》本文主要介绍了MySQL双主搭建+keepalived高可用的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、测试环境准备二、主从搭建1.创建复制用户2.创建复制关系3.开启复制,确认复制是否成功4.同

SpringCloud动态配置注解@RefreshScope与@Component的深度解析

《SpringCloud动态配置注解@RefreshScope与@Component的深度解析》在现代微服务架构中,动态配置管理是一个关键需求,本文将为大家介绍SpringCloud中相关的注解@Re... 目录引言1. @RefreshScope 的作用与原理1.1 什么是 @RefreshScope1.

Java并发编程必备之Synchronized关键字深入解析

《Java并发编程必备之Synchronized关键字深入解析》本文我们深入探索了Java中的Synchronized关键字,包括其互斥性和可重入性的特性,文章详细介绍了Synchronized的三种... 目录一、前言二、Synchronized关键字2.1 Synchronized的特性1. 互斥2.

MyBatis 动态 SQL 优化之标签的实战与技巧(常见用法)

《MyBatis动态SQL优化之标签的实战与技巧(常见用法)》本文通过详细的示例和实际应用场景,介绍了如何有效利用这些标签来优化MyBatis配置,提升开发效率,确保SQL的高效执行和安全性,感... 目录动态SQL详解一、动态SQL的核心概念1.1 什么是动态SQL?1.2 动态SQL的优点1.3 动态S

Mysql表的简单操作(基本技能)

《Mysql表的简单操作(基本技能)》在数据库中,表的操作主要包括表的创建、查看、修改、删除等,了解如何操作这些表是数据库管理和开发的基本技能,本文给大家介绍Mysql表的简单操作,感兴趣的朋友一起看... 目录3.1 创建表 3.2 查看表结构3.3 修改表3.4 实践案例:修改表在数据库中,表的操作主要

SpringBoot日志配置SLF4J和Logback的方法实现

《SpringBoot日志配置SLF4J和Logback的方法实现》日志记录是不可或缺的一部分,本文主要介绍了SpringBoot日志配置SLF4J和Logback的方法实现,文中通过示例代码介绍的非... 目录一、前言二、案例一:初识日志三、案例二:使用Lombok输出日志四、案例三:配置Logback一

springboot security之前后端分离配置方式

《springbootsecurity之前后端分离配置方式》:本文主要介绍springbootsecurity之前后端分离配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的... 目录前言自定义配置认证失败自定义处理登录相关接口匿名访问前置文章总结前言spring boot secu

一文详解SpringBoot响应压缩功能的配置与优化

《一文详解SpringBoot响应压缩功能的配置与优化》SpringBoot的响应压缩功能基于智能协商机制,需同时满足很多条件,本文主要为大家详细介绍了SpringBoot响应压缩功能的配置与优化,需... 目录一、核心工作机制1.1 自动协商触发条件1.2 压缩处理流程二、配置方案详解2.1 基础YAML