flume实现kafka到hdfs实时数据采集 - 有负载均衡策略
2016-03-31 10:53
716 查看
方案:
两台采集机器dc007.dx.momo.com,dc008.dx.momo.com.有两个写hdfs的sink,分别部署到两台机器,然后两个负载均衡的agent,也是分布部属到两台机器上,每一个agent都是写到两个hdfs sink的source端.
配置:
*******************************************hdfs sink
hdfs-sink.sources = r1
hdfs-sink.sinks = k1
hdfs-sink.channels = c1
# Describe/configure the source
hdfs-sink.sources.r1.type = avro
hdfs-sink.sources.r1.channels = c1
hdfs-sink.sources.r1.bind = dc008.dx.momo.com
hdfs-sink.sources.r1.port = 5555
# Describe the sink
hdfs-sink.sinks.k1.type = hdfs
#保证每天的每个小时一个文件夹
hdfs-sink.sinks.k1.hdfs.path = hdfs://nameservice1/user/dc/test/flume/sdk_function_log/%Y%m%d/%Y%m%d%H
hdfs-sink.sinks.k1.hdfs.filePrefix = base.log
#如果n秒没有写文件就自动关闭hdfs文件,当每个小时结束的时候可以在10s后关闭文件
hdfs-sink.sinks.k1.hdfs.idleTimeout = 10
#以文本形式写入hdfs
hdfs-sink.sinks.k1.hdfs.fileType=DataStream
hdfs-sink.sinks.k1.hdfs.writeFormat=Text
#控制文件大小
hdfs-sink.sinks.k1.hdfs.rollInterval=0
#256mb
hdfs-sink.sinks.k1.hdfs.rollSize=256000000
hdfs-sink.sinks.k1.hdfs.rollCount=0
# Use a channel which buffers events in memory
hdfs-sink.channels.c1.type = memory
hdfs-sink.channels.c1.capacity = 10000
hdfs-sink.channels.c1.transactionCapacity = 10000
# Bind the source and sink to the channel
hdfs-sink.sources.r1.channels = c1
hdfs-sink.sinks.k1.channel = c1
*******************************************
*******************************************load balance
lb-kafka-hdfs.sources=r1
lb-kafka-hdfs.sinks=k1 k2
lb-kafka-hdfs.channels=c1
#failover conf
lb-kafka-hdfs.sinkgroups = g1
lb-kafka-hdfs.sinkgroups.g1.sinks = k1 k2
lb-kafka-hdfs.sinkgroups.g1.processor.type = load_balance
lb-kafka-hdfs.sinkgroups.g1.processor.backoff = true
lb-kafka-hdfs.sinkgroups.g1.processor.selector = round_robin
#source conf
lb-kafka-hdfs.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
lb-kafka-hdfs.sources.r1.channels = c1
lb-kafka-hdfs.sources.r1.zookeeperConnect = dc002.dx:2181,dc003.dx:2181,dc004.dx:2181,dc005.dx:2181,dc006.dx:2181/kafka_0.8.2.2
lb-kafka-hdfs.sources.r1.groupId = flume-test
lb-kafka-hdfs.sources.r1.topic = sdk_function_log
lb-kafka-hdfs.sources.r1.kafka.consumer.timeout.ms = 100
#sink conf
lb-kafka-hdfs.sinks.k1.type = avro
lb-kafka-hdfs.sinks.k1.channel = c1
lb-kafka-hdfs.sinks.k1.hostname = dc007.dx.momo.com
lb-kafka-hdfs.sinks.k1.port = 5555
lb-kafka-hdfs.sinks.k2.type = avro
lb-kafka-hdfs.sinks.k2.channel = c1
lb-kafka-hdfs.sinks.k2.hostname = dc008.dx.momo.com
lb-kafka-hdfs.sinks.k2.port = 5555
#channel conf
lb-kafka-hdfs.channels.c1.type = memory
lb-kafka-hdfs.channels.c1.capacity = 10000
lb-kafka-hdfs.channels.c1.transactionCapacity = 10000
*******************************************
启动命令:
1.先启动两个sink,在dc007.dx,dc008.dx
flume-ng agent --conf /home/dc/datacenter/soft/flume/default/conf -f /home/dc/datacenter/src/flume-conf/lb_kafka_hdfs/hdfs-sink.conf -Dflume.root.logger=INFO,console -n hdfs-sink
2.启动两个负载服务,在dc007.dx,dc008.dx
flume-ng agent --conf /home/dc/datacenter/soft/flume/default/conf -f /home/dc/datacenter/src/flume-conf/lb_kafka_hdfs/lb-kafka-hdfs.conf -Dflume.root.logger=INFO,console -n lb-kafka-hdfs
两台采集机器dc007.dx.momo.com,dc008.dx.momo.com.有两个写hdfs的sink,分别部署到两台机器,然后两个负载均衡的agent,也是分布部属到两台机器上,每一个agent都是写到两个hdfs sink的source端.
配置:
*******************************************hdfs sink
hdfs-sink.sources = r1
hdfs-sink.sinks = k1
hdfs-sink.channels = c1
# Describe/configure the source
hdfs-sink.sources.r1.type = avro
hdfs-sink.sources.r1.channels = c1
hdfs-sink.sources.r1.bind = dc008.dx.momo.com
hdfs-sink.sources.r1.port = 5555
# Describe the sink
hdfs-sink.sinks.k1.type = hdfs
#保证每天的每个小时一个文件夹
hdfs-sink.sinks.k1.hdfs.path = hdfs://nameservice1/user/dc/test/flume/sdk_function_log/%Y%m%d/%Y%m%d%H
hdfs-sink.sinks.k1.hdfs.filePrefix = base.log
#如果n秒没有写文件就自动关闭hdfs文件,当每个小时结束的时候可以在10s后关闭文件
hdfs-sink.sinks.k1.hdfs.idleTimeout = 10
#以文本形式写入hdfs
hdfs-sink.sinks.k1.hdfs.fileType=DataStream
hdfs-sink.sinks.k1.hdfs.writeFormat=Text
#控制文件大小
hdfs-sink.sinks.k1.hdfs.rollInterval=0
#256mb
hdfs-sink.sinks.k1.hdfs.rollSize=256000000
hdfs-sink.sinks.k1.hdfs.rollCount=0
# Use a channel which buffers events in memory
hdfs-sink.channels.c1.type = memory
hdfs-sink.channels.c1.capacity = 10000
hdfs-sink.channels.c1.transactionCapacity = 10000
# Bind the source and sink to the channel
hdfs-sink.sources.r1.channels = c1
hdfs-sink.sinks.k1.channel = c1
*******************************************
*******************************************load balance
lb-kafka-hdfs.sources=r1
lb-kafka-hdfs.sinks=k1 k2
lb-kafka-hdfs.channels=c1
#failover conf
lb-kafka-hdfs.sinkgroups = g1
lb-kafka-hdfs.sinkgroups.g1.sinks = k1 k2
lb-kafka-hdfs.sinkgroups.g1.processor.type = load_balance
lb-kafka-hdfs.sinkgroups.g1.processor.backoff = true
lb-kafka-hdfs.sinkgroups.g1.processor.selector = round_robin
#source conf
lb-kafka-hdfs.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
lb-kafka-hdfs.sources.r1.channels = c1
lb-kafka-hdfs.sources.r1.zookeeperConnect = dc002.dx:2181,dc003.dx:2181,dc004.dx:2181,dc005.dx:2181,dc006.dx:2181/kafka_0.8.2.2
lb-kafka-hdfs.sources.r1.groupId = flume-test
lb-kafka-hdfs.sources.r1.topic = sdk_function_log
lb-kafka-hdfs.sources.r1.kafka.consumer.timeout.ms = 100
#sink conf
lb-kafka-hdfs.sinks.k1.type = avro
lb-kafka-hdfs.sinks.k1.channel = c1
lb-kafka-hdfs.sinks.k1.hostname = dc007.dx.momo.com
lb-kafka-hdfs.sinks.k1.port = 5555
lb-kafka-hdfs.sinks.k2.type = avro
lb-kafka-hdfs.sinks.k2.channel = c1
lb-kafka-hdfs.sinks.k2.hostname = dc008.dx.momo.com
lb-kafka-hdfs.sinks.k2.port = 5555
#channel conf
lb-kafka-hdfs.channels.c1.type = memory
lb-kafka-hdfs.channels.c1.capacity = 10000
lb-kafka-hdfs.channels.c1.transactionCapacity = 10000
*******************************************
启动命令:
1.先启动两个sink,在dc007.dx,dc008.dx
flume-ng agent --conf /home/dc/datacenter/soft/flume/default/conf -f /home/dc/datacenter/src/flume-conf/lb_kafka_hdfs/hdfs-sink.conf -Dflume.root.logger=INFO,console -n hdfs-sink
2.启动两个负载服务,在dc007.dx,dc008.dx
flume-ng agent --conf /home/dc/datacenter/soft/flume/default/conf -f /home/dc/datacenter/src/flume-conf/lb_kafka_hdfs/lb-kafka-hdfs.conf -Dflume.root.logger=INFO,console -n lb-kafka-hdfs
相关文章推荐
- Kafka 之 中级
- 负载均衡技术沙龙1期(关于咱的图片)
- 负载均衡沙龙活动第二期现场问答汇集
- 流量引导:网络世界的负载均衡解密
- 流量引导:网络世界的负载均衡解密
- 浅谈sqlserver的负载均衡问题
- asp.net实现负载均衡
- PHP开发负载均衡指南
- Win2003利用dfs(分布式文件系统)在负载均衡下的文件同步配置方案
- LVS+Keepalived构建高可用负载均衡(测试篇)
- 简单测试Apache是如何完成负载均衡策略配置
- Apache负载均衡设置方法 mod_proxy使用介绍
- LVS(Linux Virtual Server)Linux 虚拟服务器介绍及配置(负载均衡系统)
- Shell脚本实现把进程负载均衡到多核CPU中
- tomcat6_apache2.2_ajp 负载均衡加集群实战分享
- [Oracle] RAC 之 - 负载均衡深入解析
- windows NLB+ARR实现Web负载均衡高可用/可伸缩的方法
- haproxy+keepalived实现高可用负载均衡(理论篇)
- Keepalived+HAProxy实现MySQL高可用负载均衡的配置
- 理解web服务器和数据库的负载均衡以及反向代理