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

[经验分享] Flume NG 学习笔记(三)流配置

[复制链接]

尚未签到

发表于 2019-1-30 09:47:41 | 显示全部楼层 |阅读模式
版权声明:本文为博主原创文章,未经博主允许不得转载。
目录(?)[+]


  

  在通过flume采集日志数据的时候,一般都是通过flume 代理从日志源或者日志客户端采集数据到flume代理中,然后再由flume代理送到目标存储.上图中就是每个一级flume代理负责从webserv采集数据,然后再由一个二级flume代理进行日志汇总。


  

  Flume支持从一个源发送事件到多个通道中,这被称为事件流的复用。这里需要在配置中定义事件流的复制/复用,选择1个或者多个通道进行数据流向。
  下面的内容主要介绍flume 流配置,这节比较水,因为都比较简单。
一、单一代理流配置
  下面的配置例子是外部数据源通过avro客户端发送数据到HDFS上。下面无节操的直接拷官网
  

  [html] view plain copy

  •   agent_foo.sources= avro-AppSrv-source  
  •   agent_foo.sinks= hdfs-Cluster1-sink  
  •   agent_foo.channels= mem-channel-1  
  •      
  •   # set channel for sources, sinks  
  •      
  •   # properties of avro-AppSrv-source  
  •   agent_foo.sources.avro-AppSrv-source.type= avro  
  •   agent_foo.sources.avro-AppSrv-source.bind= localhost  
  •   agent_foo.sources.avro-AppSrv-source.port= 10000  
  •      
  •   # properties of mem-channel-1  
  •   agent_foo.channels.mem-channel-1.type= memory  
  •   agent_foo.channels.mem-channel-1.capacity= 1000  
  •   agent_foo.channels.mem-channel-1.transactionCapacity= 100  
  •      
  •   # properties of hdfs-Cluster1-sink  
  •   agent_foo.sinks.hdfs-Cluster1-sink.type= hdfs  
  •   agent_foo.sinks.hdfs-Cluster1-sink.hdfs.path= hdfs://namenode/flume/webdata  
  

  

二、单代理多流配置
  单代理多流配置是上面的加强版,相当于一个代理两个流,一个是从外部avro客户端到HDFS,另一个是Linux命令(tail)的输出到Avro接受代理,2个做成配置。继续无节操的直接拷官网
  

  [html] view plain copy

  •   # list the sources, sinks and channelsin the agent  
  •   agent_foo.sources= avro-AppSrv-source1 exec-tail-source2  
  •   agent_foo.sinks= hdfs-Cluster1-sink1 avro-forward-sink2  
  •   agent_foo.channels= mem-channel-1 file-channel-2  
  •      
  •   # flow #1 configuration  
  •   agent_foo.sources.avro-AppSrv-source1.channels= mem-channel-1  
  •   agent_foo.sinks.hdfs-Cluster1-sink1.channel= mem-channel-1  
  •      
  •   # flow #2 configuration  
  •   agent_foo.sources.exec-tail-source2.channels= file-channel-2  
  •   agent_foo.sinks.avro-forward-sink2.channel= file-channel-2  
  


  

三、配置多代理流程
  这个配置就是学习(二)的第二个例子,简单的讲就是数据源发送的事件由第一个Flume代理发送到下一个Flume代理中。下面是官网:
  

  [html] view plain copy

  •   # list sources, sinks and channels inthe agent  
  •   agent_foo.sources= avro-AppSrv-source  
  •   agent_foo.sinks= avro-forward-sink  
  •   agent_foo.channels= file-channel  
  •      
  •   # define the flow  
  •   agent_foo.sources.avro-AppSrv-source.channels= file-channel  
  •   agent_foo.sinks.avro-forward-sink.channel= file-channel  
  •      
  •   # avro sink properties  
  •   agent_foo.sources.avro-forward-sink.type= avro  
  •   agent_foo.sources.avro-forward-sink.hostname= 10.1.1.100  
  •   agent_foo.sources.avro-forward-sink.port= 10000  
  •      
  •   # configure other pieces  
  •   #...  
  

  

  例子都不难理解
四、多路复用流
  Flume支持从一个源到多个通道和sinks,叫做fan out。有两种模式的fan out,复制和复用。复制就是流的事件被发送到所有的配置通道去。
  

  [html] view plain copy

  •   # List the sources, sinks and channelsfor the agent  
  •   .sources=   
  •   .sinks=   
  •   .channels=   
  •      
  •   # set list of channels for source(separated by space)  
  •   .sources..channels=   
  •      
  •   # set channel for sinks  
  •   .sinks..channel=   
  •   .sinks..channel=   
  •      
  •   .sources..selector.type= replicating  
  其中,.sources..selector.type= replicating 这个源的选择类型为复制。这个参数不指定一个选择的时候,默认情况下它复制
  

  复用则是麻烦一下,流的事情是被筛选的发生到不同的渠道,需要指定源和扇出通道的规则,感觉与case when 类似。
  复用的参数为:.sources..selector.type = multiplexing
  

  [html] view plain copy

  •   # Mapping for multiplexing selector  
  •   .sources..selector.type= multiplexing  
  •   .sources..selector.header=   
  •   .sources..selector.mapping.=   
  •   .sources..selector.mapping.=   
  •   .sources..selector.mapping.=   
  •   #...  
  •      
  •   .sources..selector.default=   
  

  

  官网中给出例子,可以看出流的事件要声明一个头部,然后我们检查头部对应的值,这里我们可以认为是事件属性,如果指定的值与设定的通道相匹配,那么就将该事件发送到被匹配到的通道中去。这个参数就是默认通道.sources..selector.default =
  下面是官网中复用的详细配置例子
  

  [html] view plain copy

  •   # list the sources, sinks and channelsin the agent  
  •   agent_foo.sources= avro-AppSrv-source1  
  •   agent_foo.sinks= hdfs-Cluster1-sink1 avro-forward-sink2  
  •   agent_foo.channels= mem-channel-1 file-channel-2  
  •      
  •   # set channels for source  
  •   agent_foo.sources.avro-AppSrv-source1.channels= mem-channel-1 file-channel-2  
  •      
  •   # set channel for sinks  
  •   agent_foo.sinks.hdfs-Cluster1-sink1.channel= mem-channel-1  
  •   agent_foo.sinks.avro-forward-sink2.channel= file-channel-2  
  •      
  •   # channel selector configuration  
  •   agent_foo.sources.avro-AppSrv-source1.selector.type= multiplexing  
  •   agent_foo.sources.avro-AppSrv-source1.selector.header= State  
  •   agent_foo.sources.avro-AppSrv-source1.selector.mapping.CA= mem-channel-1  
  •   agent_foo.sources.avro-AppSrv-source1.selector.mapping.AZ= file-channel-2  
  •   agent_foo.sources.avro-AppSrv-source1.selector.mapping.NY= mem-channel-1 file-channel-2  
  •   agent_foo.sources.avro-AppSrv-source1.selector.default= mem-channel-1  
  

  

  上面例子中,设置事件的头属性Header 为“State”作为的选择检查。剩下的就是与case when 基本一样。其中,例子中的配置
  agent_foo.sources.avro-AppSrv-source1.selector.mapping.NY= mem-channel-1 file-channel-2 从这里可以看出映射允许每个值通道可以重叠。默认值可以包含任意数量的通道。
  





运维网声明 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-669459-1-1.html 上篇帖子: flume sinke 至hdfs 收集的一些资料 下篇帖子: flume 日志搬家上半场
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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