企业中的日志存放_1

  1. 201611/20161112.log.tmp
  2.   第二天文件变为20161112.log20161113.log.tmp
  3. 拷贝一份flume-conf.properties.template改名为dir-mem-hdfs.properties
  4. 实现监控某一目录,如有新文件产生则上传至hdfs,另外过滤掉新文件中tmp文件
  5. dir-mem-hdfs.properties
  6.   a1.sources = s1
  7.   a1.channels = c1
  8.   a1.sinks = k1
  9.   # defined the source
  10.   a1.sources.s1.type = spooldir
  11.   a1.sources.s1.spoolDir = /opt/data/log_hive/20161109
  12.   a1.sources.s1.includePattern = ([^ ]*\.log$) # 包含某些字段
  13.   a1.sources.s1.ignorePattern = ([^ ]*\.tmp$) # 忽略某些字段
  14.   # defined the channel
  15.   a1.channels.c1.type = memory
  16.   a1.channels.c1.capacity = 1000
  17.   a1.channels.c1.transactionCapacity = 1000
  18.   # defined the sink
  19.   a1.sinks.k1.type = hdfs
  20.   a1.sinks.k1.hdfs.useLocalTimeStamp = true
  21.   a1.sinks.k1.hdfs.path = /flume/spdir
  22.   a1.sinks.k1.hdfs.fileType = DataStream
  23.   a1.sinks.k1.hdfs.rollInterval = 0
  24.   a1.sinks.k1.hdfs.rollSize = 20480
  25.   a1.sinks.k1.hdfs.rollCount = 0
  26.   # The channel can be defined as follows.
  27.   a1.sources.s1.channels = c1
  28.   a1.sinks.k1.channel = c1
  29. flmue目录下执行
  30.   bin/flume-ng agent -c conf/ -n a1 -f conf/dir-mem-hdfs.properties -Dflume.root.logger=INFO,console
  31.   这里使用了memory channel,可以使用file channel更加安全

企业中的日志存放_2

  1. 201611/20161112.log
  2.   第二天文件继续往20161112.log
  3. 这样,既要使用execspoolingdir,如何处理
  4. 编译flume1.7tail dir source,并集成到我们已有的flume环境
  5.   1. window上下载安装git
  6.   2. 在某个目录下加一个空的文件夹(文件夹路径尽量不要有中文),例GitHub
  7.   3. 使用github常用命令
  8.     $ pwd
  9.     $ ls
  10.     $ cd /C/Users/Administrator/Desktop/GitHub
  11.     $ git clone (https|git)://github.com/apache/flume.git
  12.     $ cd flume
  13.     $ git branch -r # 查看有哪些分支
  14.     $ git branch -r # 查看当前属于哪个分支
  15.     $ git checkout origin/flume-1.7 #别换分支
  16.   拷贝flume\flume-ng-sources\flume-taildir-source
  17.   使用eclipse导入flume-taildir-source项目
  18.   修改pom.xml
  19.   <repositories>
  20.     <repository>
  21.       <id>cloudera</id>
  22.       <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
  23.     </repository>
  24.   </repositories>
  25.   <modelVersion>4.0.0</modelVersion>
  26.   <groupId>org.apache.flume.flume-ng-sources</groupId>
  27.   <artifactId>flume-taildir-source</artifactId>
  28.   <version>1.5.0-cdh5.3.6</version>
  29.   <name>Flume Taildir Source</name>
  30.   <build>
  31.     <plugins>
  32.       <plugin>
  33.         <groupId>org.apache.maven.plugins</groupId>
  34.         <artifactId>maven-compiler-plugin</artifactId>
  35.         <version>2.3.2</version>
  36.         <configuration>
  37.           <source>1.7</source>
  38.           <target>1.7</target>
  39.         </configuration>
  40.       </plugin>
  41.     </plugins>
  42.   </build>
  43.   <dependencies>
  44.     <dependency>
  45.       <groupId>org.apache.flume</groupId>
  46.       <artifactId>flume-ng-core</artifactId>
  47.       <version>1.5.0-cdh5.3.6</version>
  48.     </dependency>
  49.     <dependency>
  50.       <groupId>junit</groupId>
  51.       <artifactId>junit</artifactId>
  52.       <version>4.10</version>
  53.       <scope>test</scope>
  54.     </dependency>
  55.   </dependencies>
  56.   4. MAVEN_BULID项目,获取jar包并放到当前flume的环境中(lib目录)
  57.   5. 创建文件夹和文件
  58.     $ mkdir -p /opt/cdh-5.6.3/apache-flume-1.5.0-cdh5.3.6-bin/position
  59.     $ mkdir -p /opt/data/tail/hadoop-dir/
  60.     $ echo "" > /opt/data/tail/hadoop.log
  61.     拷贝一份flume-conf.properties.template改名为tail-mem-hdfs.properties
  62.     可从源码看出需要的参数
  63.       a1.sources = s1
  64.       a1.channels = c1
  65.       a1.sinks = k1
  66.       # defined the source
  67.       a1.sources.s1.type = org.apache.flume.source.taildir.TaildirSource
  68.       a1.sources.s1.positionFile = /opt/cdh-5.6.3/apache-flume-1.5.0-cdh5.3.6-bin/position/taildir_position.json
  69.       a1.sources.s1.filegroups = f1 f2
  70.       a1.sources.s1.filegroups.f1 = /opt/data/tail/hadoop.log
  71.       a1.sources.s1.filegroups.f2 = /opt/data/tail/hadoop-dir/.*
  72.       a1.sources.s1.headers.f1.headerKey1 = value1
  73.       a1.sources.s1.headers.f2.headerKey1 = value2-1
  74.       a1.sources.s1.headers.f2.headerKey2 = value2-2
  75.       a1.sources.s1.fileHeader = true
  76.       # defined the channel
  77.       a1.channels.c1.type = memory
  78.       a1.channels.c1.capacity = 1000
  79.       a1.channels.c1.transactionCapacity = 1000
  80.       # defined the sink
  81.       a1.sinks.k1.type = hdfs
  82.       a1.sinks.k1.hdfs.useLocalTimeStamp = true
  83.       a1.sinks.k1.hdfs.path = /flume/spdir
  84.       a1.sinks.k1.hdfs.fileType = DataStream
  85.       a1.sinks.k1.hdfs.rollInterval = 0
  86.       a1.sinks.k1.hdfs.rollSize = 20480
  87.       a1.sinks.k1.hdfs.rollCount = 0
  88.       # The channel can be defined as follows.
  89.       a1.sources.s1.channels = c1
  90.       a1.sinks.k1.channel = c1
  91.   flmue目录下执行
  92.     bin/flume-ng agent -c conf/ -n a1 -f conf/tail-mem-hdfs.properties -Dflume.root.logger=INFO,console
  93.     测试文件或新数据

企业中常用架构 Flume多sink

  1. 同一份数据采集到不同框架处理
  2. 采集source: 一份数据
  3. 管道channel: 多个
  4. 目标sink: 多个
  5. 如果多个sink从一个channel取数据将取不完整,而source会针对channel分别发送
  6. 设计: source--hive.log channel--file sink--hdfs(不同路径)
  7. 拷贝一份flume-conf.properties.template改名为hive-file-sinks.properties
  8. hive-file-sinks.properties
  9.   a1.sources = s1
  10.   a1.channels = c1 c2
  11.   a1.sinks = k1 k2
  12.   # defined the source
  13.   a1.sources.s1.type = exec
  14.   a1.sources.s1.command = tail -F /opt/cdh-5.6.3/hive-0.13.1-cdh5.3.6/logs/hive.log
  15.   a1.sources.s1.shell = /bin/sh -c
  16.   # defined the channel 1
  17.   a1.channels.c1.type = file
  18.   a1.channels.c1.checkpointDir = /opt/cdh-5.6.3/apache-flume-1.5.0-cdh5.3.6-bin/datas/checkp1
  19.   a1.channels.c1.dataDirs = /opt/cdh-5.6.3/apache-flume-1.5.0-cdh5.3.6-bin/datas/data1
  20.   # defined the channel 2
  21.   a1.channels.c2.type = file
  22.   a1.channels.c2.checkpointDir = /opt/cdh-5.6.3/apache-flume-1.5.0-cdh5.3.6-bin/datas/checkp2
  23.   a1.channels.c2.dataDirs = /opt/cdh-5.6.3/apache-flume-1.5.0-cdh5.3.6-bin/datas/data2
  24.   # defined the sink 1
  25.   a1.sinks.k1.type = hdfs
  26.   a1.sinks.k1.hdfs.path = /flume/hdfs/sink1
  27.   a1.sinks.k1.hdfs.fileType = DataStream
  28.   # defined the sink 2
  29.   a1.sinks.k2.type = hdfs
  30.   a1.sinks.k2.hdfs.path = /flume/hdfs/sink2
  31.   a1.sinks.k2.hdfs.fileType = DataStream
  32.   # The channel can be defined as follows.
  33.   a1.sources.s1.channels = c1 c2
  34.   a1.sinks.k1.channel = c1
  35.   a1.sinks.k2.channel = c2
  36. flmue目录下执行
  37.   bin/flume-ng agent -c conf/ -n a1 -f conf/hive-file-sinks.properties -Dflume.root.logger=INFO,console
  38. hive目录下执行
  39.   bin/hive -e "show databases"

Flume_企业中日志处理的更多相关文章

  1. 东正王增涛浅析OA信息化整合平台系统在企业中的应用价值

    王增涛说OA信息化整合平台系统作为企业管理中最基础的管理软件,已在企业成长道路上存在多年,它的应用开启了智能移动办公的先河,也让企业的办公流程管理更加的便捷.高效.流畅.省时.省力,它的使用不但让企业 ...

  2. 利用log4j+mongodb实现分布式系统中日志统一管理

    背景     在分布式系统当中,我们有各种各样的WebService,这些服务可能分别部署在不同的服务器上,并且有各自的日志输出.为了方便对这些日志进行统一管理和分析.我们可以将日志统一输出到指定的数 ...

  3. 再谈SQL Server中日志的的作用

    简介     之前我已经写了一个关于SQL Server日志的简单系列文章.本篇文章会进一步挖掘日志背后的一些概念,原理以及作用.如果您没有看过我之前的文章,请参阅:     浅谈SQL Server ...

  4. LR中日志设置和日志函数

    LR中日志参数的设置与使用 1.Run-Time Setting日志参数的设置 在loadrunner的vuser菜单下的Run-Time Setting的General的LOG选项中可以对在执行脚本 ...

  5. Android中日志信息的打印方式

    Android中日志信息的打印方式主要有以下7种: 1)System.out(i级别) 2)System.err(w级别) 3)Log.v 4)Log.d 5)Log.i 6)Log.w 7)Log. ...

  6. SQL Server中日志

    再谈SQL Server中日志的的作用 简介 之前我已经写了一个关于SQL Server日志的简单系列文章.本篇文章会进一步挖掘日志背后的一些概念,原理以及作用.如果您没有看过我之前的文章,请参阅: ...

  7. 详解BOM用途分类及在汽车企业中的应用

    摘要:在整车企业中,信息系统的BOM是联系CAD.CAPP.PDM和ERP的纽带,按照用途划分产品要经过产品设计,工程设计.工艺制造设计.生产制造4个阶段,相应的在这4个过程中分别产生了名称十分相似但 ...

  8. YII2中日志的配置与使用

    YII2中给我们提供了非常方便的日志组件,只需要简单配置一下就可以使用. 我们在config/web.php中配置如下: return [ //log必须在bootstrap期间就被加载,便于及时调度 ...

  9. Tomcat中日志组件

    Tomcat日志组件 AccessLog接口 public interface AccessLog { public void log(Request request, Response respon ...

随机推荐

  1. [转]加速Android Studio/Gradle构建

    加速Android Studio/Gradle构建 android android studio gradle   已经使用Android Studio进行开发超过一年,随着项目的增大,依赖库的增多, ...

  2. 【安装Redis】CentOS7 下安装NodeJs+Express+MongoDB+Redis

    Redis,V3.2,官网l官方链接:http://www.redis.io/download,参考:http://blog.csdn.net/mlks_2008/article/details/19 ...

  3. 在WebPart中获取Office 365中的未读邮件数

    // Create the web request HttpWebRequest request = WebRequest.Create("https://outlook.office365 ...

  4. Linux 软件包管理

    简介: linux中软件包的管理随着linux版本的不同而不同,一般RPM和DPKG是最常见的两类软件包管理工具.分别应用基于rpm软件包的linux发行版本和基于deb软件包的linux发行版本. ...

  5. CentOS 7 (RHEL 7)服务管理命令的变化

    CentOS 7 (RHEL 7)带来了新的服务管理命令,为了保持兼容原有的命令仍可以使用,以下是新旧命令的对照. 启动.停止.重启.重载.检查服务:6: service httpd start|st ...

  6. Fedora 安装gcc gcc-c++

    Fedora本身没有自带gcc 和 g++编译器,所以需要我们自己去安装,步骤如下: 1.切换到root用户(或者跳过这个步骤,直接在下面命令前面加上 sudo) su root 2.安装gcc yu ...

  7. hadoop2.6.4 搭建单机模式

    注(要先安装jdk,最好jdk版本>=1.7) 安装jdk  http://www.cnblogs.com/zhangXingSheng/p/6228432.html     给普通用户添加su ...

  8. UML大战需求分析——阅读笔记05

    最近看过几个程序员大学后一起创业,与大公司抢项目并成功逆袭的视频,感触颇深:第一.技术是关键:第二.有一群可靠并且技术超群的队友,在关键时刻不会掉链子:第三.善于部署谨慎周密的计划:第四.一流的口才+ ...

  9. xss漏洞修复,待完善

    1.防止sql注入 /// <summary> /// 分析用户请求是否正常 /// </summary> /// <param name="Str" ...

  10. Python,ElementTree模块处理XML时注释无法读取和保存的问题

    from xml.etree import ElementTree class CommentedTreeBuilder ( ElementTree.XMLTreeBuilder ): def __i ...