http://blog.csdn.net/hijk139/article/details/8308224

业务系统需要收集监控系统日志,想到了hadoop的flume。经过试验,虽说功能不算足够强大,但基本上能够满足功能需求。Flume 是一个分布式、可靠和高可用的服务日志收集工具,能够和hadoop,hive等配置完成日志收集,存储,分析处理等工作,更详细的介绍可以参见apache网站。下面介绍下简单的安装配置方法

1,网上下载flume-ng安装包,分别部署在收集和接收日志文件的服务器上,服务器上需安装jdk 1.6以上,
http://flume.apache.org/download.html
tar -zxvf apache-flume-1.3.0-bin.tar.gz
2, 日志文件接收端端新建conf/flume-conf.properties server端的具体配置如下

从avro source端接收数据,然后写入到HDFS文件系统中

  1. [flume@ conf]$ cat  flume-conf.properties
  2. agent.sources = avrosrc
  3. agent.channels = memoryChanne3
  4. agent.sinks = hdfsSink
  5. # For each one of the sources, the type is defined
  6. agent.sources.avrosrc.type = avro
  7. agent.sources.avrosrc.bind = 172.16.251.1
  8. agent.sources.avrosrc.port = 44444
  9. # The channel can be defined as follows.
  10. agent.sources.avrosrc.channels = memoryChanne3
  11. # Each channel's type is defined.
  12. agent.channels.memoryChanne3.type = memory
  13. agent.channels.memoryChanne3.keep-alive = 10
  14. agent.channels.memoryChanne3.capacity = 100000
  15. agent.channels.memoryChanne3.transactionCapacity =100000
  16. # Each sink's type must be defined
  17. agent.sinks.hdfsSink.type = hdfs
  18. agent.sinks.hdfsSink.channel = memoryChanne3
  19. agent.sinks.hdfsSink.hdfs.path = /logdata/%{hostname}_linux/%Y%m%d_date
  20. agent.sinks.hdfsSink.hdfs.filePrefix = %{datacenter}_
  21. agent.sinks.hdfsSink.hdfs.rollInterval = 0
  22. agent.sinks.hdfsSink.hdfs.rollSize = 4000000
  23. agent.sinks.hdfsSink.hdfs.rollCount = 0
  24. agent.sinks.hdfsSink.hdfs.writeFormat = Text
  25. agent.sinks.hdfsSink.hdfs.fileType = DataStream
  26. agent.sinks.hdfsSink.hdfs.batchSize = 10

如果flume和hadoop不是同一用户,需要注意相关权限问题

3,日志收集端的conf/flume-conf.properties server文件配置,这里收集二个日志文件到收集端

  1. agent.sources = tailsource-1 tailsource-2
  2. agent.channels = memoryChannel-1 memoryChannel-2
  3. agent.sinks = remotesink remotesink-2
  4. agent.sources.tailsource-1.type = exec
  5. agent.sources.tailsource-1.command = tail -F /tmp/linux2.log
  6. agent.sources.tailsource-1.channels = memoryChannel-1
  7. agent.sources.tailsource-2.type = exec
  8. agent.sources.tailsource-2.command = tail -F /tmp/linux2_2.log
  9. agent.sources.tailsource-2.channels = memoryChannel-2
  10. agent.sources.tailsource-1.interceptors = host_int timestamp_int inter1
  11. agent.sources.tailsource-1.interceptors.host_int.type = host
  12. agent.sources.tailsource-1.interceptors.host_int.hostHeader = hostname
  13. agent.sources.tailsource-1.interceptors.timestamp_int.type = org.apache.flume.interceptor.TimestampInterceptor$Builder
  14. #agent.sources.tailsource-1.interceptors = inter1
  15. agent.sources.tailsource-1.interceptors.inter1.type = static
  16. agent.sources.tailsource-1.interceptors.inter1.key = datacenter
  17. agent.sources.tailsource-1.interceptors.inter1.value = BEIJING
  18. agent.sources.tailsource-2.interceptors = host_int timestamp_int inter1
  19. agent.sources.tailsource-2.interceptors.host_int.type = host
  20. agent.sources.tailsource-2.interceptors.host_int.hostHeader = hostname
  21. agent.sources.tailsource-2.interceptors.timestamp_int.type = org.apache.flume.interceptor.TimestampInterceptor$Builder
  22. #agent.sources.tailsource-1.interceptors = inter1
  23. agent.sources.tailsource-2.interceptors.inter1.type = static
  24. agent.sources.tailsource-2.interceptors.inter1.key = datacenter
  25. agent.sources.tailsource-2.interceptors.inter1.value = linux2_2
  26. agent.channels.memoryChannel-1.type = memory
  27. agent.channels.memoryChannel-1.keep-alive = 10
  28. agent.channels.memoryChannel-1.capacity = 100000
  29. agent.channels.memoryChannel-1.transactionCapacity =100000
  30. agent.channels.memoryChannel-2.type = memory
  31. agent.channels.memoryChannel-2.keep-alive = 10
  32. agent.channels.memoryChannel-2.capacity = 100000
  33. agent.channels.memoryChannel-2.transactionCapacity =100000
  34. agent.sinks.remotesink.type = avro
  35. agent.sinks.remotesink.hostname = 172.16.251.1
  36. agent.sinks.remotesink.port = 44444
  37. agent.sinks.remotesink.channel = memoryChannel-1
  38. agent.sinks.remotesink-2.type = avro
  39. agent.sinks.remotesink-2.hostname = 172.16.251.1
  40. agent.sinks.remotesink-2.port = 44444
  41. agent.sinks.remotesink-2.channel = memoryChannel-2

4,后台运行
nohup bin/flume-ng agent -n agent -c conf -f conf/flume-conf.properties >1.log &

查看日志vi flume.log
端口连接情况 netstat -an|grep 44444
[flume@dtydb6 flume-1.4]$ netstat -an|grep 44444
tcp        0      0 ::ffff:172.16.251.1:44444   :::*                        LISTEN

5,测试方法

可以使用如下类似的脚本,定期向日志文件写入来进行测试

for i in {1..1000000}; do echo "LINUX2  PRESS ************* Flume log rotation $i" >> /tmp/linux3.log; sleep 0.0001; done

参考资料:
http://flume.apache.org/FlumeUserGuide.html

flume ng 1.3 安装(转)的更多相关文章

  1. flume ng系列之——flume安装

    flume版本:1.5.0 1.下载安装包: http://www.apache.org/dyn/closer.cgi/flume/1.5.0/apache-flume-1.5.0-bin.tar.g ...

  2. Flume 学习笔记之 Flume NG概述及单节点安装

    Flume NG概述: Flume NG是一个分布式,高可用,可靠的系统,它能将不同的海量数据收集,移动并存储到一个数据存储系统中.轻量,配置简单,适用于各种日志收集,并支持 Failover和负载均 ...

  3. Flume NG Getting Started(Flume NG 新手入门指南)

    Flume NG Getting Started(Flume NG 新手入门指南)翻译 新手入门 Flume NG是什么? 有什么改变? 获得Flume NG 从源码构建 配置 flume-ng全局选 ...

  4. 高可用Hadoop平台-Flume NG实战图解篇

    1.概述 今天补充一篇关于Flume的博客,前面在讲解高可用的Hadoop平台的时候遗漏了这篇,本篇博客为大家讲述以下内容: Flume NG简述 单点Flume NG搭建.运行 高可用Flume N ...

  5. 【转】Flume(NG)架构设计要点及配置实践

    Flume(NG)架构设计要点及配置实践   Flume NG是一个分布式.可靠.可用的系统,它能够将不同数据源的海量日志数据进行高效收集.聚合.移动,最后存储到一个中心化数据存储系统中.由原来的Fl ...

  6. Flume NG简介及配置

    Flume下载地址:http://apache.fayea.com/flume/ 常用的分布式日志收集系统: Apache Flume. Facebook Scribe. Apache Chukwa ...

  7. Flume NG 简介及配置实战

    Flume 作为 cloudera 开发的实时日志收集系统,受到了业界的认可与广泛应用.Flume 初始的发行版本目前被统称为 Flume OG(original generation),属于 clo ...

  8. 【Flume NG用户指南】(1)设置

    作者:周邦涛(Timen) Email:zhoubangtao@gmail.com 转载请注明出处:  http://blog.csdn.net/zhoubangtao/article/details ...

  9. 分布式实时日志系统(二) 环境搭建之 flume 集群搭建/flume ng资料

    最近公司业务数据量越来越大,以前的基于消息队列的日志系统越来越难以满足目前的业务量,表现为消息积压,日志延迟,日志存储日期过短,所以,我们开始着手要重新设计这块,业界已经有了比较成熟的流程,即基于流式 ...

随机推荐

  1. unity5.5 5.6 使用c#6.0或7.0

    http://blog.csdn.net/davied9/article/details/77281393

  2. php二维数组排序方法(array_multisort usort)

    一维数组排序可以使用asort.ksort等一些方法进程排序,相对来说比较简单.二维数组的排序怎么实现呢?使用array_multisort和usort可以实现 例如像下面的数组: $users = ...

  3. springMVC静态资源访问

    springMVC默认是访问不到静态资源的,如css,js等,需要在xml里进行配置 保证已经配置好了 web.xml, <!-- Spring MVC servlet --> <s ...

  4. JavaScript中有var和没var的区别

    Js中的变量声明的作用域是以函数为单位,所以我们经常见到避免全局变量污染的方法是 (function(){ // ... })(); 在函数内部,有var和没var声明的变量是不一样的.有var声明的 ...

  5. js 中onclick 事件 点击后指向自己的对象,查找或者添加属性 用关键字this 传入参数 (可以改变原标签css)

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  6. UWP 应用获取各类系统、用户信息 (1) - 设备和系统的基本信息、应用包信息、用户数据账户信息和用户账户信息

    应用开发中,开发者时常需要获取一些系统.用户信息用于数据统计遥测.问题反馈.用户识别等功能.本文旨在介绍在 Windows UWP 应用中获取一些常用系统.用户信息的方法.示例项目代码可参见 Gith ...

  7. Android之侧滑导航栏

    今天学习的新内容是侧滑导航栏,我想大家肯定都比较熟悉了,因为这个效果在qq里面也有,最近一直跟室友们玩的游戏是快速让自己的头像的点赞量上千.当然我的效果跟qq是没有办法比的,因为那里面的功能是在是太强 ...

  8. 关于easyui 圆角按钮在ie9不能隐藏

    (一)在easyui框架里 在a标签里添加class='easyui-linkbutton' 如: (二)问题:在ie9里圆角背景overflow:hidden 不起作用 (a)框架内 html 部分 ...

  9. 【Linux】IPC-消息队列

    问题 消息队列id 和键值KEY区别? 首先要注意一个概念:IPC结构都是内核的结构.也就是说IPC结构由内核维护,对于每个进程都是公共的,不属于某个特定进程.只有这样,IPC结构才能支持它们&quo ...

  10. zookeeper的JavaAPI

    org.apache.zookeeper.Zookeeper Zookeeper 是在 Java 中客户端主类,负责建立与 zookeeper 集群的会话,并提供方法进行操作. org.apache. ...