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

[经验分享] 使用flume搜集服务器log到hdfs

[复制链接]

尚未签到

发表于 2015-11-27 21:06:32 | 显示全部楼层 |阅读模式
  将多个logs服务器上的log搜集到hdfs服务器上,多个logs服务上的flume-sink和hdfs服务器上的flume-source都是avro类型,hdfs服务器上的flume-sink是hdfs类型
  

  
  Flume部署文档
  系统要求:
  Java 运行时环境

  
  部署方式:
  在logs和hdfs服务器上下载并解压flume包
  
  下载flume包并解压:
  http://mirror.bit.edu.cn/apache/flume/1.4.0/apache-flume-1.4.0-bin.tar.gz
  
logs服务器flume配置
  进入解压后的flume目录,修改配置文件:
  1.      Cp  conf/flume-env.sh.template conf/flume-env.sh
  在conf/flume-env.sh中添加
  JAVA_HOME=” JAVA HOME DIR”
  
  2.      在conf目录下创建flume.conf配置文件,添加以下内容
  修改agent.sources.loggerSource.command 值
  
  # Licensed to the Apache SoftwareFoundation (ASF) under one
  # or more contributor licenseagreements.  See the NOTICE file
  # distributed with this work for additionalinformation
  # regarding copyright ownership.  The ASF licenses this file
  # to you under the Apache License, Version2.0 (the
  # "License"); you may not usethis file except in compliance
  # with the License.  You may obtain a copy of the License at
  #
  # http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law oragreed to in writing,
  # software distributed under the License isdistributed on an
  # "AS IS" BASIS, WITHOUTWARRANTIES OR CONDITIONS OF ANY
  # KIND, either express or implied.  See the License for the
  # specific language governing permissionsand limitations
  # under the License.
  
  
  # The configuration file needs to definethe sources,
  # the channels and the sinks.
  # Sources, channels and sinks are definedper agent,
  # in this case called 'agent'
  
  agenta.sources = loggerSource
  agenta.channels = memoryChannel
  agenta.sinks = loggerSink
  
  # For each one of the sources, the type isdefined
  agenta.sources.loggerSource.type = exec
  agenta.sources.loggerSource.command = tail -F <logpath>
  
  # The channel can be defined as follows.
  agenta.sources.loggerSource.channels =memoryChannel
  
  # Each sink's type must be defined
  agenta.sinks.loggerSink.type = avro
  agenta.sinks.loggerSink.hostname = <hdfs serverip>
  agenta.sinks.loggerSink.port = 4141
  
  #Specify the channel the sink should use
  agenta.sinks.loggerSink.channel =memoryChannel
  
  # Each channel's type is defined.
  agenta.channels.memoryChannel.type = memory
  
  # Other config values specific to each typeof channel(sink or source)
  # can be defined as well
  # In this case, it specifies the capacityof the memory channel
  agenta.channels.memoryChannel.capacity =1000
  
  启动命令:
  ./bin/flume-ng agent --conf conf/  --conf-file conf/flume.conf --name agent
  
  
Hdfs 服务器flume配置
  进入解压后的flume目录,修改配置文件:
  1.      Cpconf/flume-env.sh.template conf/flume-env.sh
  在conf/flume-env.sh中添加
  JAVA_HOME=” JAVA HOME DIR”
  HADOOP_HOME= “HADOOP HOME”
  
  2.      在conf目录下创建flume.conf配置文件,添加以下内容
  
  
  # Licensed to the Apache SoftwareFoundation (ASF) under one
  # or more contributor license agreements.  See the NOTICE file
  # distributed with this work for additionalinformation
  # regarding copyright ownership.  The ASF licenses this file
  # to you under the Apache License, Version2.0 (the
  # &quot;License&quot;); you may not usethis file except in compliance
  # with the License.  You may obtain a copy of the License at
  #
  # http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law oragreed to in writing,
  # software distributed under the License isdistributed on an
  # &quot;AS IS&quot; BASIS, WITHOUTWARRANTIES OR CONDITIONS OF ANY
  # KIND, either express or implied.  See the License for the
  # specific language governing permissionsand limitations
  # under the License.
  
  
  # The configuration file needs to definethe sources,
  # the channels and the sinks.
  # Sources, channels and sinks are definedper agent,
  # in this case called 'agent'
  
  agent.sources = loggerSource
  agent.channels = memoryChannel
  agent.sinks = loggerSink
  
  # For each one of the sources, the type isdefined
  agent.sources.loggerSource.type = avro
  agent.sources.loggerSource.bind = 0.0.0.0
  agent.sources.loggerSource.port = 4141
  
  # The channel can be defined as follows.
  agent.sources.loggerSource.channels =memoryChannel
  
  # Each sink's type must be defined
  agent.sinks.loggerSink.type = hdfs
  agent.sinks.loggerSink.hdfs.path = <hdfs sink path>
  agent.sinks.loggerSink.hdfs.filePrefix =csplog-
  agent.sinks.loggerSink.hdfs.rollInterval=86400
  agent.sinks.loggerSink.hdfs.rollSize = 0
  agent.sinks.loggerSink.hdfs.rollCount = 0
  agent.sinks.loggerSink.hdfs.fileType =DataStream
  
  #Specify the channel the sink should use
  agent.sinks.loggerSink.channel =memoryChannel
  
  # Each channel's type is defined.
  agent.channels.memoryChannel.type = memory
  
  # Other config values specific to each typeof channel(sink or source)
  # can be defined as well
  # In this case, it specifies the capacityof the memory channel
  agent.channels.memoryChannel.capacity =1000
  
  
  启动命令:
  bin/flume-ng agent --conf conf/ --conf-fileflume.conf --name agent

运维网声明 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-144389-1-1.html 上篇帖子: flume连接metaQ传数据到spark进行实时计算 下篇帖子: flume学习(九):自定义拦截器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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