【问题标题】:Why does an optional flume channel cause a non-optional flume channel to have problems?为什么可选的水槽通道会导致非可选的水槽通道出现问题?
【发布时间】:2015-06-25 17:03:29
【问题描述】:

我有一个看似简单的 Flume 配置,但给我带来了很多问题。我先描述一下问题,然后我会列出配置文件。

我有 3 台服务器:Server1、Server2、Server3。

服务器 1: Netcat 源/Syslogtcp 源(我在没有 acks 和 syslogtcp 的 netcat 上测试了这个) 2个记忆通道 2 个 Avro 接收器(每个通道一个) 使用可选的第二个内存通道复制选择器

服务器2,3: Avro 源 记忆通道 卡夫卡水槽

在我的模拟中,Server2 正在模拟“生产”,因此不会出现任何数据丢失,而 Server3 正在模拟“开发”并且数据丢失很好。 我的假设是使用 2 个通道和 2 个源将使两个服务器彼此分离,如果 Server3 出现故障,它不会影响 Sever2(尤其是使用可选配置选项!)。然而,这种情况并非如此。当我运行我的模拟并使用 CTRL-C 终止 Server3 时,我在 Server2 上遇到了减速,并且从 Server2 到 Kafka 接收器的输出变成了爬行。当我在 Server3 上恢复 Flume 代理时,一切恢复正常。

我没想到会有这种行为。我所期望的是,因为我有两个通道和两个接收器,如果一个通道和/或接收器出现故障,另一个通道和/或接收器应该没有问题。这是 Flume 的限制吗?这是对我的源、接收器或通道的限制吗?有没有办法让 Flume 在我使用具有多个通道和接收器的代理时表现得彼此分离?我真的不想在一台机器上为每个“环境”(生产和开发)安装多个 Flume 代理。附件是我的配置文件,因此您可以以更技术的方式查看我所做的:

SERVER1(一级代理)

#Describe the top level configuration    
agent.sources = mySource
agent.channels = defaultChannel1 defaultChannel2
agent.sinks = mySink1 mySink2

#Describe/configure the source
agent.sources.mySource.type = netcat
agent.sources.mySource.port = 6666
agent.sources.mySource.bind = 0.0.0.0
agent.sources.mySource.max-line-length = 150000
agent.sources.mySource.ack-every-event = false
#agent.sources.mySource.type = syslogtcp
#agent.sources.mySource.host = 0.0.0.0
#agent.sources.mySource.port = 7103
#agent.sources.mySource.eventSize = 150000
agent.sources.mySource.channels = defaultChannel1 defaultChannel2
agent.sources.mySource.selector.type = replicating
agent.sources.mySource.selector.optional = defaultChannel2

#Describe/configure the channel
agent.channels.defaultChannel1.type = memory
agent.channels.defaultChannel1.capacity = 5000
agent.channels.defaultChannel1.transactionCapacity = 200

agent.channels.defaultChannel2.type = memory
agent.channels.defaultChannel2.capacity = 5000
agent.channels.defaultChannel2.transactionCapacity = 200

#Avro Sink
agent.sinks.mySink1.channel = defaultChannel1
agent.sinks.mySink1.type = avro
agent.sinks.mySink1.hostname = Server2
agent.sinks.mySink1.port = 6666

agent.sinks.mySink2.channel = defaultChannel2
agent.sinks.mySink2.type = avro
agent.sinks.mySink2.hostname = Server3
agent.sinks.mySink2.port = 6666

SERVER2 "PROD" FLUME 代理

#Describe the top level configuration
agent.sources = mySource
agent.channels = defaultChannel
agent.sinks = mySink

#Describe/configure the source
agent.sources.mySource.type = avro
agent.sources.mySource.port = 6666
agent.sources.mySource.bind = 0.0.0.0
agent.sources.mySource.max-line-length = 150000
agent.sources.mySource.channels = defaultChannel

#Describe/configure the interceptor
agent.sources.mySource.interceptors = myInterceptor
agent.sources.mySource.interceptors.myInterceptor.type = myInterceptor$Builder

#Describe/configure the channel
agent.channels.defaultChannel.type = memory
agent.channels.defaultChannel.capacity = 5000
agent.channels.defaultChannel.transactionCapacity = 200

#Describe/configure the sink
agent.sinks.mySink.type = org.apache.flume.sink.kafka.KafkaSink
agent.sinks.mySink.topic = Server2-topic
agent.sinks.mySink.brokerList = broker1:9092, broker2:9092
agent.sinks.mySink.requiredAcks = -1
agent.sinks.mySink.batchSize = 100
agent.sinks.mySink.channel = defaultChannel

SERVER3 "DEV" FLUME 代理

#Describe the top level configuration
agent.sources = mySource
agent.channels = defaultChannel
agent.sinks = mySink

#Describe/configure the source
agent.sources.mySource.type = avro
agent.sources.mySource.port = 6666
agent.sources.mySource.bind = 0.0.0.0
agent.sources.mySource.max-line-length = 150000
agent.sources.mySource.channels = defaultChannel

#Describe/configure the interceptor
agent.sources.mySource.interceptors = myInterceptor
agent.sources.mySource.interceptors.myInterceptor.type = myInterceptor$Builder

#Describe/configure the channel
agent.channels.defaultChannel.type = memory
agent.channels.defaultChannel.capacity = 5000
agent.channels.defaultChannel.transactionCapacity = 200

#Describe/configure the sink
agent.sinks.mySink.type = org.apache.flume.sink.kafka.KafkaSink
agent.sinks.mySink.topic = Server3-topic
agent.sinks.mySink.brokerList = broker1:9092, broker2:9092
agent.sinks.mySink.requiredAcks = -1
agent.sinks.mySink.batchSize = 100
agent.sinks.mySink.channel = defaultChannel 

感谢您的帮助!

【问题讨论】:

    标签: java apache-kafka flume avro flume-ng


    【解决方案1】:

    我会考虑调整这个配置参数,因为它与内存通道有关:

    agent.channels.defaultChannel.capacity = 5000 agent.channels.defaultChannel.transactionCapacity = 200

    可能先尝试加倍,然后再次执行测试,您应该会看到改进:

    agent.channels.defaultChannel.capacity = 10000 agent.channels.defaultChannel.transactionCapacity = 400

    在测试期间观察 Apache Flume 实例的 JVM 也会很好

    【讨论】:

    • 我最终想出了一些非常酷的东西,使用故障转移接收器来处理这个问题。我也大大增加了渠道容量。感谢您的帮助。
    • @PhillipAMnn 我希望你也可以将其标记为答案:)
    • 虽然这不是真正的答案......这只是一个建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 2018-11-20
    • 1970-01-01
    相关资源
    最近更新 更多