kafka实时读取sqlserver数据_Debezium SQL Server Source Connector+Kafka+Spark+MySQL 实时数据处理...

写在前面前段时间在实时获取SQLServer数据库变化时候,整个过程可谓是坎坷。然后就想在这里记录一下。ps:后面应该会将数据放到Kudu上。然后主要记录一下,整个组件使用和组件对接过程中一些注意点和坑。开始吧在处理实时数据时,需要即时地获得数据库表中数据的变化,然后将数据变化发送到Kafka中。不同的数据库有不同的组件进行处理。常见的MySQL数据库,就有比较多的支持 canal ,maxwel...
摘要由CSDN通过智能技术生成

写在前面

前段时间在实时获取SQLServer数据库变化时候,整个过程可谓是坎坷。然后就想在这里记录一下。

ps:后面应该会将数据放到Kudu上。

然后主要记录一下,整个组件使用和组件对接过程中一些注意点和坑。

开始吧

在处理实时数据时,需要即时地获得数据库表中数据的变化,然后将数据变化发送到Kafka中。不同的数据库有不同的组件进行处理。

常见的MySQL数据库,就有比较多的支持 canal ,maxwell等,他们都是类似 MySQL binlog 增量订阅&消费组件这种模式 。那么关于微软的SQLServer数据库,好像整个开源社区 支持就没有那么好了。

1.选择Connector

Debezium的SQL Server连接器是一种源连接器,可以获取SQL Server数据库中现有数据的快照,然后监视和记录对该数据的所有后续行级更改。每个表的所有事件都记录在单独的Kafka Topic中,应用程序和服务可以轻松使用它们。然后本连接器也是基于MSSQL的change data capture实现。

2.安装Connector

我参照官方文档安装是没有问题的。

2.1 Installing Confluent Hub Client

Confluent Hub客户端本地安装为Confluent Platform的一部分,位于/ bin目录中。

Linux

Download and unzip the Confluent Hub tarball.

[root@hadoop001 softs]# ll confluent-hub-client-latest.tar

-rw-r--r--. 1 root root 6909785 9月 24 10:02 confluent-hub-client-latest.tar

[root@hadoop001 softs]# tar confluent-hub-client-latest.tar -C ../app/conn/

[root@hadoop001 softs]# ll ../app/conn/

总用量 6748

drwxr-xr-x. 2 root root 27 9月 24 10:43 bin

-rw-r--r--. 1 root root 6909785 9月 24 10:02 confluent-hub-client-latest.tar

drwxr-xr-x. 3 root root 34 9月 24 10:05 etc

drwxr-xr-x. 2 root root 6 9月 24 10:08 kafka-mssql

drwxr-xr-x. 4 root root 29 9月 24 10:05 share

[root@hadoop001 softs]#

配置bin目录到系统环境变量中

export CONN_HOME=/root/app/conn

export PATH=$CONN_HOME/bin:$PATH

确认是否安装成功

[root@hadoop001 ~]# source /etc/profile

[root@hadoop001 ~]# confluent-hub

usage: confluent-hub [ ]

Commands are:

help Display help information

install install a component from either Confluent Hub or from a local file

See 'confluent-hub help ' for more information on a specific command.

[root@hadoop001 ~]#

2.2 Install the SQL Server Connector

使用命令confluent-hub

[root@hadoop001 ~]# confluent-hub install debezium/debezium-connector-sqlserver:0.9.4

The component can be installed in any of the following Confluent Platform installations:

1. / (installed rpm/deb package)

2. /root/app/conn (where this tool is installed)

Choose one of these to continue the installation (1-2): 2

Do you want to install this into /root/app/conn/share/confluent-hub-components? (yN) n

Specify installation directory: /root/app/conn/share/java/confluent-hub-client

Component's license:

Apache 2.0

https://github.com/debezium/debezium/blob/master/LICENSE.txt

I agree to the software license agreement (yN) y

You are about to install 'debezium-connector-sqlserver' from Debezium Community, as published on Confluent Hub.

Do you want to continue? (yN) y

注意:Specify installation directory:这个安装目录最好是你刚才的confluent-hub 目录下的 /share/java/confluent-hub-client 这个目录下。其余的基本操作就好。

3.配置Connector

首先需要对Connector进行配置,配置文件位于 $KAFKA_HOME/config/connect-distributed.properties:

# These are defaults. This file just demonstrates how to override some settings.

# kafka集群地址,我这里是单节点

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值