设为首页 收藏本站
查看: 1031|回复: 0

[经验分享] Flume NG configuration sample

[复制链接]

尚未签到

发表于 2015-11-27 17:22:30 | 显示全部楼层 |阅读模式
  1.  配置source 为 exec
  

agent1.sources = tail

agent1.channels = MemoryChannel-2

agent1.sinks = HDFS



agent1.sources.tail.type = exec

agent1.sources.tail.command = tail -f /var/log/apache2/access.log.1

agent1.sources.tail.channels = MemoryChannel-2



agent1.sinks.HDFS.channel = MemoryChannel-2

agent1.sinks.HDFS.type = hdfs

agent1.sinks.HDFS.hdfs.path = hdfs://localhost:9000/flume

agent1.sinks.HDFS.hdfs.file.Type
= DataStream




agent1.channels.MemoryChannel-2.type
= memory




and the command I issuing is -

bin/flume-ng agent -n agent1 -c conf/ -f conf/agent1.conf
  
  


  2. 配置source为 seq
  


  3. source exec, 并且组建source group
  

tail1.sources = src1
tail1.channels = ch1
tail1.sinks = sink1 sink2
tail1.sinkgroups = sg1
tail1.sources.src1.type = exec
tail1.sources.src1.command = tail -F /tmp/acess_log
tail1.sources.src1.channels = ch1
tail1.channels.ch1.type = memory
tail1.channels.ch1.capacity = 500
tail1.sinks.sink1.type = avro
tail1.sinks.sink1.hostname = localhost
tail1.sinks.sink1.port = 6000
tail1.sinks.sink1.batch-size = 1
tail1.sinks.sink1.channel = ch1
tail1.sinks.sink2.type = avro
tail1.sinks.sink2.hostname = localhost
tail1.sinks.sink2.port = 6001
tail1.sinks.sink2.batch-size = 1
tail1.sinks.sink2.channel = ch1
tail1.sinkgroups.sg1.sinks = sink1 sink2
tail1.sinkgroups.sg1.processor.type = failover
tail1.sinkgroups.sg1.processor.priority.sink1 = 1
tail1.sinkgroups.sg1.processor.priority.sink2 = 2
######################################################
collector1.sources = src1
collector1.channels = ch1
collector1.sinks = sink1
collector1.sources.src1.type = avro
collector1.sources.src1.bind = localhost
collector1.sources.src1.port = 6000
collector1.sources.src1.channels = ch1
collector1.channels.ch1.type = memory
collector1.channels.ch1.capacity = 500
collector1.sinks.sink1.type = hdfs
collector1.sinks.sink1.hdfs.path = collector1
collector1.sinks.sink1.hdfs.filePrefix = access_log
collector1.sinks.sink1.channel = ch1
######################################################
collector2.sources = src1
collector2.channels = ch1
collector2.sinks = sink1
collector2.sources.src1.type = avro
collector2.sources.src1.bind = localhost
collector2.sources.src1.port = 6001
collector2.sources.src1.channels = ch1
collector2.channels.ch1.type = memory
collector2.channels.ch1.capacity = 500
collector2.sinks.sink1.type = hdfs
collector2.sinks.sink1.hdfs.path = collector2
collector2.sinks.sink1.hdfs.filePrefix = access_log
collector2.sinks.sink1.channel = ch1

  4. Sample configuration and Client
  What I am seeing is that for every event that I send a new file in hadoop is being created. I was expecting that file handle would just write to existing file until it gets rolled over as specified in the configs. Am I doing something wrong?



12/06/15 17:28:52 INFO hdfs.BucketWriter: Creating hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027956.tmp

12/06/15 17:28:52 INFO hdfs.BucketWriter: Renaming hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027956.tmp to hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027956

12/06/15 17:28:52 INFO hdfs.BucketWriter: Creating hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027957.tmp

12/06/15 17:28:52 INFO hdfs.BucketWriter: Renaming hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027957.tmp to hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027957

12/06/15 17:28:52 INFO hdfs.BucketWriter: Creating hdfs://dsdb1:54310/flume/'dslg1'/FlumeData.1339806027958.tmp





foo.sources = avroSrc

foo.channels = memoryChannel

foo.sinks = hdfsSink

# For each one of the sources, the type is defined

foo.sources.avroSrc.type = avro

# The channel can be defined as follows.

foo.sources.avroSrc.channels = memoryChannel

foo.sources.avroSrc.bind = 0.0.0.0

foo.sources.avroSrc.port = 41414

# Each sink's type must be defined

foo.sinks.hdfsSink.type = hdfs

foo.sinks.hdfsSink.hdfs.path = hdfs://dsdb1:54310/flume/'%{host}'

foo.sinks.hdfsSink.file.Prefix = web

foo.sinks.hdfsSink.file.rollInterval  = 600

foo.sinks.hdfsSink.file.Type  = SequenceFile

#Specify the channel the sink should use

foo.sinks.hdfsSink.channel = memoryChannel



code:



public void sendDataToFlume(String data) {

  // Create flume event object

  Event event = EventBuilder.withBody(data, Charset.forName("UTF-8"));

  Map<String,String> headers = new HashMap<String,String>();

  headers.put(&quot;host&quot;, hostName);

  event.setHeaders(headers);

  try {

   rpcClient.append(event);

  } catch (EventDeliveryException e) {

   connect();

  }







@Test

public void testAvroClient() throws InterruptedException{

  AvroClient aClient = new AvroClient();

  int i = 0;

  int j = 500;

  while(i&#43;&#43; < j){

   aClient.sendDataToFlume(&quot;Hello&quot;);

   if(i == j/2){

    //Thread.sleep(30000);

   }

  }

  

}

}









After I changed my config to this it worked. It looks like flume creates new file for any of the conditions that matches first. Since there is a default of 10 for rollCount it was creating a new document. But I think it causes lot of problem because I need
to now keep track and estimate all these variables. I think it should just do based on what's specified in the config, so if I only specify rollSize then it souldn't consider any other options for it's logic to create a new file.



foo.sinks.hdfsSink.type = hdfs

foo.sinks.hdfsSink.hdfs.path = hdfs://dsdb1:54310/flume/%{host}

foo.sinks.hdfsSink.hdfs.filePrefix = web

foo.sinks.hdfsSink.hdfs.rollInterval  = 600

foo.sinks.hdfsSink.hdfs.rollCount  = 200000000

foo.sinks.hdfsSink.hdfs.rollSize  = 5000000000

foo.sinks.hdfsSink.hdfs.fileType  = SequenceFile
  


  5.  example: http://mapredit.blogspot.de/2012/03/flumeng-evolution.html
  


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-144275-1-1.html 上篇帖子: Flume(NG)架构设计要点及配置实践 下篇帖子: Flume学习07 — FlumeRpcClientUtils工具类
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表