我最近问了一个问题Apache Flume - send only new file contents
我改写这个问题是为了了解更多,并为Flume的未来用户提供更多好处。
设置:两台服务器,其中一台有一个.txt文件,该文件定期向其追加行。
目标:使用flume TAILDIR源代码将最近编写的行附加到另一台服务器上的文件中。
问题:只要源文件添加了新的数据行,当前配置就会将服务器1上的文件中的所有内容附加到服务器2中的文件。这会导致文件2中出现重复行,并且无法从服务器1正确重新创建文件。
服务器1上的配置:
#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上的配置:
#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发布于 2018-01-12 09:57:05
您必须设置位置json文件。则信源检查该位置,并且仅将新添加的行写入信宿。例如)agent.soures.s1.position文件= /var/log/flume/tail_position.json .json
https://stackoverflow.com/questions/45016257
复制相似问题