zoukankan      html  css  js  c++  java
  • flume ng 1.3 安装(转)

    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文件系统中

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


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

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

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

  • 相关阅读:
    Dockerfile简介及基于centos7的jdk镜像制作
    docker数据卷(Data Volumes)
    docker入门及常用命令
    Failed to start bean ‘org.springframework.kafka.config.internalKafkaListenerEndpointRegistry
    dubbo服务启动报:qos-server can not bind localhost:22222s
    Dubbo服务调用Failed to invoke the method错误记录
    java8-list转Map
    git remote: HTTP Basic: Access denied 错误解决办法
    SSH整合(二)
    SSH整合
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/4037439.html
Copyright © 2011-2022 走看看