kafka---->kafka connect的使用(一)
这里面介绍一下kafka connect的一些使用。
kafka connect的使用
一、在config目录下面复制一个file-srouce.properties并且修改内容
huhx@gohuhx:~/server/kafka_2.11-1.1.0/config$ cp connect-file-source.properties connect-file-source-test.properties
huhx@gohuhx:~/server/kafka_2.11-1.1.0/config$ cp connect-standalone.properties connect-standalone-test.properties
修改huhx目录下面的connect-standalone-test.properties文件里面的内容如下:
key.converter.schemas.enable=false
value.converter.schemas.enable=false
connect-file-source-test.properties的内容如下:
name=local-file-source
connector.class=FileStreamSource
tasks.max=
file=/home/huhx/Documents/linux.txt
topic=connect-linux transforms=MakeMap, InsertSource
transforms.MakeMap.type=org.apache.kafka.connect.transforms.HoistField$Value
transforms.MakeMap.field=line
transforms.InsertSource.type=org.apache.kafka.connect.transforms.InsertField$Value
transforms.InsertSource.static.field=data_source
transforms.InsertSource.static.value=test-file-source
指定了topic为connect-test,指定了读取的文件为/home/huhx/Documents/linux.txt。其中linux.txt的内容如下
I love you.
my name is huhx.
code for me?
二、运行connect-standalone.sh命令,可以将对huhx.txt文件处理之后的内容发布到connect-test的topic上
huhx@gohuhx:~/server/kafka_2.-1.1.$ bin/connect-standalone.sh config/connect-standalone-test.properties config/connect-file-source-test.properties
运行之后,我们在connect-test主题里面可以看到如下的输出:
huhx@gohuhx:~/server/kafka_2.-1.1.$ bin/kafka-console-consumer.sh --bootstrap-server localhost: --topic connect-linux --from-beginning
{"line":"I love you.","data_source":"test-file-source"}
{"line":"my name is huhx.","data_source":"test-file-source"}
{"line":"code for me?","data_source":"test-file-source"}
关于上述配置的transforms可以参考下述的文档https://kafka.apache.org/documentation/#connect
友情链接
kafka---->kafka connect的使用(一)的更多相关文章
- Why do Kafka consumers connect to zookeeper, and producers get metadata from brokers?
Why do Kafka consumers connect to zookeeper, and producers get metadata from brokers? Ask Question u ...
- [Kafka] - Kafka Java Consumer实现(二)
Kafka提供了两种Consumer API,分别是:High Level Consumer API 和 Lower Level Consumer API(Simple Consumer API) H ...
- [Kafka] - Kafka Java Consumer实现(一)
Kafka提供了两种Consumer API,分别是:High Level Consumer API 和 Lower Level Consumer API(Simple Consumer API) H ...
- [Spark][kafka]kafka 生产者,消费者 互动例子
[Spark][kafka]kafka 生产者,消费者 互动例子 # pwd/usr/local/kafka_2.11-0.10.0.1/bin 创建topic:# ./kafka-topics.sh ...
- Zookeeper与Kafka Kafka
Zookeeper与Kafka Kafka Kafka SocketServer是基于Java NIO开发的,采用了Reactor的模式(已被大量实践证明非常高效,在Netty和Mina中广泛使用). ...
- Kafka启动遇到ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
------------恢复内容开始------------ Kafka启动遇到ERROR Exiting Kafka due to fatal exception (kafka.Kafka$) 解决 ...
- [Kafka] - Kafka基本操作命令
Kafka支持的基本命令位于${KAFKA_HOME}/bin文件夹中,主要是kafka-topics.sh命令:Kafka命令参考页面: kafka-0.8.x-帮助文档 -1. 查看帮助信息 b ...
- Kafka – kafka consumer
ConsumerRecords<String, String> records = consumer.poll(100); /** * Fetch data for the topic ...
- [Kafka] - Kafka基本概念介绍
Kafka官方介绍:Kafka是一个分布式的流处理平台(0.10.x版本),在kafka0.8.x版本的时候,kafka主要是作为一个分布式的.可分区的.具有副本数的日志服务系统(Kafka™ is ...
- [Kafka] - Kafka 安装介绍
Kafka是由LinkedIn公司开发的,之后贡献给Apache基金会,成为Apache的一个顶级项目,开发语言为Scala.提供了各种不同语言的API,具体参考Kafka的cwiki页面: Kafk ...
随机推荐
- 深入理解JVM(10)——Class文件结构
什么是“JVM”的无关性 Java具有平台无关性,也就是任何操作系统都能够运行Java代码,之所以能够实现这一点,是因为Java运行在虚拟机上,不同的操作系统都有各自的Java虚拟机,从而实现一次编译 ...
- 安装oracle11g不能启动图形化界面
问题:安装oracle11g时出现xhost: unable to open display "192.168.2.12:0.0".打不开图形化界面等. 终极解决方法:1.使用X ...
- JS_高程7.函数表达式(1)
定义函数的两种常见的方法: 1 . 函数声明 2. 函数表达式 # 差异 (1)函数声明 ,具有函数声明提升的特征. (2)函数声明的函数的name属性为函数的名称:使用函数表达式定义的函数在ES5中 ...
- C_求两个日期相隔的天数(闰年)
#include <stdio.h> #include <math.h> int leap_year(int year){ == || (year%== && ...
- 【动态规划】Column Addition @ICPC2017Tehran/upcexam5434
时间限制: 1 Sec 内存限制: 128 MB 题目描述 A multi-digit column addition is a formula on adding two integers writ ...
- GMA Round 1 最大值
传送门 最大值 求$f(x)=cos(x)+\sqrt{cos^2(x)-4\sqrt{3}cos(x)+4\sqrt{2}sin(x)+10}$的最大值.保留到小数点后3位. $f(x)+\sqrt ...
- js中的iterable用法
iterable字面意思:可迭代的,可重复的 . 遍历Array可以采用下标循环,遍历Map和Set就无法使用下标.为了统一集合类型,ES6标准引入了新的iterable类型,Array.Map和Se ...
- flink 有状态udf 引起血案一
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/rlnLo2pNEfx9c/article/details/83422587 场景 近期在做一个画像的 ...
- Delphi提取PDF文本
生成PDF的控件很多,但解析的不是太多,pdf Toolkit可以,但测试的第一个复杂的pdf就报告错误,并且汉字乱码,可能使用的版本或使用方法不对. 想起之前使用java调用的Apache名下的pd ...
- redis 4.0.8 源码包安装集群
系统:centos 6.9软件版本:redis-4.0.8,rubygems-2.7.7,gcc version 4.4.7 20120313,openssl-1.1.0h,zlib-1.2.11 y ...