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

相关文章

MySQL常用字符串函数示例和场景介绍

《MySQL常用字符串函数示例和场景介绍》MySQL提供了丰富的字符串函数帮助我们高效地对字符串进行处理、转换和分析,本文我将全面且深入地介绍MySQL常用的字符串函数,并结合具体示例和场景,帮你熟练... 目录一、字符串函数概述1.1 字符串函数的作用1.2 字符串函数分类二、字符串长度与统计函数2.1

SpringBoot多环境配置数据读取方式

《SpringBoot多环境配置数据读取方式》SpringBoot通过环境隔离机制,支持properties/yaml/yml多格式配置,结合@Value、Environment和@Configura... 目录一、多环境配置的核心思路二、3种配置文件格式详解2.1 properties格式(传统格式)1.

SQL Server跟踪自动统计信息更新实战指南

《SQLServer跟踪自动统计信息更新实战指南》本文详解SQLServer自动统计信息更新的跟踪方法,推荐使用扩展事件实时捕获更新操作及详细信息,同时结合系统视图快速检查统计信息状态,重点强调修... 目录SQL Server 如何跟踪自动统计信息更新:深入解析与实战指南 核心跟踪方法1️⃣ 利用系统目录

MySQL 内存使用率常用分析语句

《MySQL内存使用率常用分析语句》用户整理了MySQL内存占用过高的分析方法,涵盖操作系统层确认及数据库层bufferpool、内存模块差值、线程状态、performance_schema性能数据... 目录一、 OS层二、 DB层1. 全局情况2. 内存占js用详情最近连续遇到mysql内存占用过高导致

全面解析Golang 中的 Gorilla CORS 中间件正确用法

《全面解析Golang中的GorillaCORS中间件正确用法》Golang中使用gorilla/mux路由器配合rs/cors中间件库可以优雅地解决这个问题,然而,很多人刚开始使用时会遇到配... 目录如何让 golang 中的 Gorilla CORS 中间件正确工作一、基础依赖二、错误用法(很多人一开

Debian系和Redhat系防火墙配置方式

《Debian系和Redhat系防火墙配置方式》文章对比了Debian系UFW和Redhat系Firewalld防火墙的安装、启用禁用、端口管理、规则查看及注意事项,强调SSH端口需开放、规则持久化,... 目录Debian系UFW防火墙1. 安装2. 启用与禁用3. 基本命令4. 注意事项5. 示例配置R

Mysql中设计数据表的过程解析

《Mysql中设计数据表的过程解析》数据库约束通过NOTNULL、UNIQUE、DEFAULT、主键和外键等规则保障数据完整性,自动校验数据,减少人工错误,提升数据一致性和业务逻辑严谨性,本文介绍My... 目录1.引言2.NOT NULL——制定某列不可以存储NULL值2.UNIQUE——保证某一列的每一

解密SQL查询语句执行的过程

《解密SQL查询语句执行的过程》文章讲解了SQL语句的执行流程,涵盖解析、优化、执行三个核心阶段,并介绍执行计划查看方法EXPLAIN,同时提出性能优化技巧如合理使用索引、避免SELECT*、JOIN... 目录1. SQL语句的基本结构2. SQL语句的执行过程3. SQL语句的执行计划4. 常见的性能优

深度解析Nginx日志分析与499状态码问题解决

《深度解析Nginx日志分析与499状态码问题解决》在Web服务器运维和性能优化过程中,Nginx日志是排查问题的重要依据,本文将围绕Nginx日志分析、499状态码的成因、排查方法及解决方案展开讨论... 目录前言1. Nginx日志基础1.1 Nginx日志存放位置1.2 Nginx日志格式2. 499

SQL Server 中的 WITH (NOLOCK) 示例详解

《SQLServer中的WITH(NOLOCK)示例详解》SQLServer中的WITH(NOLOCK)是一种表提示,等同于READUNCOMMITTED隔离级别,允许查询在不获取共享锁的情... 目录SQL Server 中的 WITH (NOLOCK) 详解一、WITH (NOLOCK) 的本质二、工作