ES 多channel、多sink

1.配置文件

a1.sources = r1
a1.sinks = k1 k2 k3
a1.channels = c1 c2 c3

# Describe/configure the source
a1.sources.r1.type = jsyh.forward.source.kafka.KafkaSource
#a1.sources.r1.statServiceType = application
a1.sources.r1.zookeeperConnect = 192.168.1.33:2180,192.168.1.33:2181,192.168.1.33:2182
a1.sources.r1.topic = jsbank123
a1.sources.r1.groupId = forward
a1.sources.r1.kafka.consumer.timeout.ms = 100
a1.sources.r1.channels = c1 c2 c3
a1.sources.r1.selector.type = multiplexing
a1.sources.r1.selector.header = ck
a1.sources.r1.selector.mapping.0 = c1
a1.sources.r1.selector.mapping.1 = c2
a1.sources.r1.selector.mapping.2 = c3
a1.sources.r1.selector.default = c3

# Describe the sink
a1.sinks.k1.type = jsyh.forward.sink.elasticsearch2.AppElasticSearchSink
a1.sinks.k1.hostNames = 192.168.1.35:9300,192.168.1.35:9301,192.168.1.35:9302
a1.sinks.k1.indexName = jsbank_app_prim
#a1.sinks.k1.indexType = bar_type
a1.sinks.k1.clusterName = els5-35
a1.sinks.k1.batchSize = 500
a1.sinks.k1.ttl = 5d
a1.sinks.k1.serializer = jsyh.forward.sink.elasticsearch2.AppElasticSearchDynamicSerializer
a1.sinks.k1.indexNameBuilder = jsyh.forward.sink.elasticsearch2.TimeBasedIndexNameBuilder
a1.sinks.k1.sinkId = 1

a1.sinks.k2.type = jsyh.forward.sink.elasticsearch2.AppElasticSearchSink
a1.sinks.k2.hostNames = 192.168.1.35:9300,192.168.1.35:9301,192.168.1.35:9302
a1.sinks.k2.indexName = jsbank_app_prim
#a1.sinks.k2.indexType = bar_type
a1.sinks.k2.clusterName = els5-35
a1.sinks.k2.batchSize = 500
a1.sinks.k2.ttl = 5d
a1.sinks.k2.serializer = jsyh.forward.sink.elasticsearch2.AppElasticSearchDynamicSerializer
a1.sinks.k2.indexNameBuilder = jsyh.forward.sink.elasticsearch2.TimeBasedIndexNameBuilder
a1.sinks.k2.sinkId = 2

a1.sinks.k3.type = jsyh.forward.sink.elasticsearch2.AppElasticSearchSink
a1.sinks.k3.hostNames = 192.168.1.35:9300,192.168.1.35:9301,192.168.1.35:9302
a1.sinks.k3.indexName = jsbank_app_prim
#a1.sinks.k3.indexType = bar_type
a1.sinks.k3.clusterName = els5-35
a1.sinks.k3.batchSize = 500
a1.sinks.k3.ttl = 5d
a1.sinks.k3.serializer = jsyh.forward.sink.elasticsearch2.AppElasticSearchDynamicSerializer
a1.sinks.k3.indexNameBuilder = jsyh.forward.sink.elasticsearch2.TimeBasedIndexNameBuilder
a1.sinks.k3.sinkId = 3

# Use a channel which buffers events in memory
a1.channels.c1.transactionCapacity = 100000
a1.channels.c1.maxFileSize = 104857600
a1.channels.c1.type = file
a1.channels.c1.checkpointDir = /mnt/ssd/dmw-apm/app-forward-agent2-channel/1/checkpoint
a1.channels.c1.dataDirs = /mnt/ssd/dmw-apm/app-forward-agent2-channel/1/data

a1.channels.c2.transactionCapacity = 100000
a1.channels.c2.maxFileSize = 104857600
a1.channels.c2.type = file
a1.channels.c2.checkpointDir = /mnt/ssd/dmw-apm/app-forward-agent2-channel/2/checkpoint
a1.channels.c2.dataDirs = /mnt/ssd/dmw-apm/app-forward-agent2-channel/2/data

a1.channels.c3.transactionCapacity = 100000
a1.channels.c3.maxFileSize = 104857600
a1.channels.c3.type = file
a1.channels.c3.checkpointDir = /mnt/ssd/dmw-apm/app-forward-agent2-channel/3/checkpoint
a1.channels.c3.dataDirs = /mnt/ssd/dmw-apm/app-forward-agent2-channel/3/data

# Bind the source and sink to the channel
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c2
a1.sinks.k3.channel = c3

2.代码中添加:

private int channelSelectorKey = 0;
headers.put(KafkaSourceConstants.FLUME_CHANNEL_SELECTOR_KEY, "" + this.channelSelectorKey++);
if(this.channelSelectorKey >= KafkaSourceConstants.FLUME_CHANNEL_SELECTOR_KEY_MAX) {
     this.channelSelectorKey = 0;
}

如今的大数据技术应用场景,对实时性的要求已经越来越高。作为新一代大数据流处理框架,由于非常好的实时性,Flink独树一帜,在近些年引起了业内极大的兴趣和关注。Flink能够提供毫秒级别的延迟,同时保证了数据处理的低延迟、高吞吐和结果的正确性,还提供了丰富的时间类型和窗口计算、Exactly-once 语义支持,另外还可以进行状态管理,并提供了CEP(复杂事件处理)的支持。Flink在实时分析领域的优势,使得越来越多的公司开始将实时项目向Flink迁移,其社区也在快速发展壮大。目前,Flink已经成为各大公司实时领域的发力重点,特别是国内以阿里为代表的一众大厂,都在全力投入,不少公司为Flink社区贡献了大量源码。如今Flink已被很多人认为是大数据实时处理的方向和未来,很多公司也都在招聘和储备了解掌握Flink的人才。本教程将Flink理论与电商数据分析项目实战并重,对Flink基础理论知识做了系统的梳理和阐述,并通过电商用户行为分析的具体项目用多个指标进行了实战演练。为有志于增加大数据项目经验、扩展流式处理框架知识的工程师提供了学习方式。二、教程内容和目标本教程主要分为两部分:第一部分,主要是Flink基础理论的讲解,涉及到各种重要概念、原理和API的用法,并且会有大量的示例代码实现;第二部分,以电商作为业务应用场景,以Flink作为分析框架,介绍一个电商用户行为分析项目的开发实战。通过理论和实际的紧密结合,可以使学员对Flink有充分的认识和理解,在项目实战中对Flink和流式处理应用的场景、以及电商分析业务领域有更深刻的认识;并且通过对流处理原理的学习和与批处理架构的对比,可以对大数据处理架构有更全面的了解,为日后成长为架构师打下基础。三、谁适合学1、有一定的 Java、Scala 基础,希望了解新的大数据方向的编程人员2、有 Java、Scala 开发经验,了解大数据相关知识,希望增加项目经验的开发人员3、有较好的大数据基础,希望掌握Flink及流式处理框架的求职人员
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值