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

相关文章

网页解析 lxml 库--实战

lxml库使用流程 lxml 是 Python 的第三方解析库,完全使用 Python 语言编写,它对 XPath表达式提供了良好的支 持,因此能够了高效地解析 HTML/XML 文档。本节讲解如何通过 lxml 库解析 HTML 文档。 pip install lxml lxm| 库提供了一个 etree 模块,该模块专门用来解析 HTML/XML 文档,下面来介绍一下 lxml 库

SQL中的外键约束

外键约束用于表示两张表中的指标连接关系。外键约束的作用主要有以下三点: 1.确保子表中的某个字段(外键)只能引用父表中的有效记录2.主表中的列被删除时,子表中的关联列也会被删除3.主表中的列更新时,子表中的关联元素也会被更新 子表中的元素指向主表 以下是一个外键约束的实例展示

基于MySQL Binlog的Elasticsearch数据同步实践

一、为什么要做 随着马蜂窝的逐渐发展,我们的业务数据越来越多,单纯使用 MySQL 已经不能满足我们的数据查询需求,例如对于商品、订单等数据的多维度检索。 使用 Elasticsearch 存储业务数据可以很好的解决我们业务中的搜索需求。而数据进行异构存储后,随之而来的就是数据同步的问题。 二、现有方法及问题 对于数据同步,我们目前的解决方案是建立数据中间表。把需要检索的业务数据,统一放到一张M

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

如何去写一手好SQL

MySQL性能 最大数据量 抛开数据量和并发数,谈性能都是耍流氓。MySQL没有限制单表最大记录数,它取决于操作系统对文件大小的限制。 《阿里巴巴Java开发手册》提出单表行数超过500万行或者单表容量超过2GB,才推荐分库分表。性能由综合因素决定,抛开业务复杂度,影响程度依次是硬件配置、MySQL配置、数据表设计、索引优化。500万这个值仅供参考,并非铁律。 博主曾经操作过超过4亿行数据

hadoop开启回收站配置

开启回收站功能,可以将删除的文件在不超时的情况下,恢复原数据,起到防止误删除、备份等作用。 开启回收站功能参数说明 (1)默认值fs.trash.interval = 0,0表示禁用回收站;其他值表示设置文件的存活时间。 (2)默认值fs.trash.checkpoint.interval = 0,检查回收站的间隔时间。如果该值为0,则该值设置和fs.trash.interval的参数值相等。

NameNode内存生产配置

Hadoop2.x 系列,配置 NameNode 内存 NameNode 内存默认 2000m ,如果服务器内存 4G , NameNode 内存可以配置 3g 。在 hadoop-env.sh 文件中配置如下。 HADOOP_NAMENODE_OPTS=-Xmx3072m Hadoop3.x 系列,配置 Nam

性能分析之MySQL索引实战案例

文章目录 一、前言二、准备三、MySQL索引优化四、MySQL 索引知识回顾五、总结 一、前言 在上一讲性能工具之 JProfiler 简单登录案例分析实战中已经发现SQL没有建立索引问题,本文将一起从代码层去分析为什么没有建立索引? 开源ERP项目地址:https://gitee.com/jishenghua/JSH_ERP 二、准备 打开IDEA找到登录请求资源路径位置

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间