首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Flume中的taildir源代码来仅附加.txt文件的最新行?

如何使用Flume中的taildir源代码来仅附加.txt文件的最新行?
EN

Stack Overflow用户
提问于 2017-07-10 23:39:28
回答 1查看 957关注 0票数 0

我最近问了一个问题Apache Flume - send only new file contents

我改写这个问题是为了了解更多,并为Flume的未来用户提供更多好处。

设置:两台服务器,其中一台有一个.txt文件,该文件定期向其追加行。

目标:使用flume TAILDIR源代码将最近编写的行附加到另一台服务器上的文件中。

问题:只要源文件添加了新的数据行,当前配置就会将服务器1上的文件中的所有内容附加到服务器2中的文件。这会导致文件2中出现重复行,并且无法从服务器1正确重新创建文件。

服务器1上的配置:

代码语言:javascript
复制
    #configure the agent
    agent.sources=r1
    agent.channels=k1
    agent.sinks=c1

    #using memort channel to hold upto 1000 events
    agent.channels.k1.type=memory
    agent.channels.k1.capacity=1000
    agent.channels.k1.transactionCapacity=100

    #connect source, channel,sink
    agent.sources.r1.channels=k1
    agent.sinks.c1.channel=k1

    #define source
    agent.sources.r1.type=TAILDIR
    agent.sources.r1.channels=k1
    agent.sources.r1.filegroups=f1

    agent.sources.r1.filegroups.f1=/home/tail_test_dir/test.txt
    agent.sources.r1.maxBackoffSleep=1000

    #connect to another box using avro and send the data
    agent.sinks.c1.type=avro
    agent.sinks.c1.hostname=10.10.10.4
    agent.sinks.c1.port=4545

服务器2上的配置:

代码语言:javascript
复制
    #configure the agent
    agent.sources=r1
    agent.channels=k1
    agent.sinks=c1

    #using memory channel to hold up to 1000 events
    agent.channels.k1.type=memory
    agent.channels.k1.capacity=1000
    agent.channels.k1.transactionCapacity=100

    #connect source, channel, sink
    agent.sources.r1.channels=k1
    agent.sinks.c1.channel=k1

    #here source is listening at the specified port using AVRO for data
    agent.sources.r1.type=avro
    agent.sources.r1.bind=0.0.0.0
    agent.sources.r1.port=4545

    #use file_roll and write file at specified directory
    agent.sinks.c1.type=file_roll
    agent.sinks.c1.sink.directory=/home/Flume_dump
EN

回答 1

Stack Overflow用户

发布于 2018-01-12 09:57:05

您必须设置位置json文件。则信源检查该位置,并且仅将新添加的行写入信宿。例如)agent.soures.s1.position文件= /var/log/flume/tail_position.json .json

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45016257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档