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

相关文章

nginx -t、nginx -s stop 和 nginx -s reload 命令的详细解析(结合应用场景)

《nginx-t、nginx-sstop和nginx-sreload命令的详细解析(结合应用场景)》本文解析Nginx的-t、-sstop、-sreload命令,分别用于配置语法检... 以下是关于 nginx -t、nginx -s stop 和 nginx -s reload 命令的详细解析,结合实际应

SQL server数据库如何下载和安装

《SQLserver数据库如何下载和安装》本文指导如何下载安装SQLServer2022评估版及SSMS工具,涵盖安装配置、连接字符串设置、C#连接数据库方法和安全注意事项,如混合验证、参数化查... 目录第一步:打开官网下载对应文件第二步:程序安装配置第三部:安装工具SQL Server Manageme

C#连接SQL server数据库命令的基本步骤

《C#连接SQLserver数据库命令的基本步骤》文章讲解了连接SQLServer数据库的步骤,包括引入命名空间、构建连接字符串、使用SqlConnection和SqlCommand执行SQL操作,... 目录建议配合使用:如何下载和安装SQL server数据库-CSDN博客1. 引入必要的命名空间2.

MyBatis中$与#的区别解析

《MyBatis中$与#的区别解析》文章浏览阅读314次,点赞4次,收藏6次。MyBatis使用#{}作为参数占位符时,会创建预处理语句(PreparedStatement),并将参数值作为预处理语句... 目录一、介绍二、sql注入风险实例一、介绍#(井号):MyBATis使用#{}作为参数占位符时,会

Linux下进程的CPU配置与线程绑定过程

《Linux下进程的CPU配置与线程绑定过程》本文介绍Linux系统中基于进程和线程的CPU配置方法,通过taskset命令和pthread库调整亲和力,将进程/线程绑定到特定CPU核心以优化资源分配... 目录1 基于进程的CPU配置1.1 对CPU亲和力的配置1.2 绑定进程到指定CPU核上运行2 基于

全面掌握 SQL 中的 DATEDIFF函数及用法最佳实践

《全面掌握SQL中的DATEDIFF函数及用法最佳实践》本文解析DATEDIFF在不同数据库中的差异,强调其边界计算原理,探讨应用场景及陷阱,推荐根据需求选择TIMESTAMPDIFF或inte... 目录1. 核心概念:DATEDIFF 究竟在计算什么?2. 主流数据库中的 DATEDIFF 实现2.1

MySQL 多列 IN 查询之语法、性能与实战技巧(最新整理)

《MySQL多列IN查询之语法、性能与实战技巧(最新整理)》本文详解MySQL多列IN查询,对比传统OR写法,强调其简洁高效,适合批量匹配复合键,通过联合索引、分批次优化提升性能,兼容多种数据库... 目录一、基础语法:多列 IN 的两种写法1. 直接值列表2. 子查询二、对比传统 OR 的写法三、性能分析

MySQL中的LENGTH()函数用法详解与实例分析

《MySQL中的LENGTH()函数用法详解与实例分析》MySQLLENGTH()函数用于计算字符串的字节长度,区别于CHAR_LENGTH()的字符长度,适用于多字节字符集(如UTF-8)的数据验证... 目录1. LENGTH()函数的基本语法2. LENGTH()函数的返回值2.1 示例1:计算字符串

Spring Boot spring-boot-maven-plugin 参数配置详解(最新推荐)

《SpringBootspring-boot-maven-plugin参数配置详解(最新推荐)》文章介绍了SpringBootMaven插件的5个核心目标(repackage、run、start... 目录一 spring-boot-maven-plugin 插件的5个Goals二 应用场景1 重新打包应用

Java中读取YAML文件配置信息常见问题及解决方法

《Java中读取YAML文件配置信息常见问题及解决方法》:本文主要介绍Java中读取YAML文件配置信息常见问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录1 使用Spring Boot的@ConfigurationProperties2. 使用@Valu