Flume——安装与配置

来源:互联网 发布:十宗罪网络剧百度云 编辑:程序博客网 时间:2024/05/16 05:23
  1)Flume简介
     Flume是Cloudera提供的一个海量日志收集系统,Flume支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume还提供了对数据进行的简单处理,并写到各种数据接收方(可定制)的能力。Flume说白了就是一个融入Hadoop当中的分布式、可靠、和高可用的海量日志采集、聚合和传输的系统。

  2)Flume安装
     Flume提供了两种安装方式,第一种和普通的unix环境安装软件一样,使用apt-get install flume的形式实现;另外一种是下载tar包安装方式。因为对于Flume需要安装到多台机器上,一般不建议使用第一种安装,所以接下来就对tar安装方式进行说明:
     首先,从https://github.com/cloudera/flume/downloads下载所需的tar包,这里将以flume-0.0.3.tar.gz 部署到hadoop集群中为例,将其解压到$FLUME_HOME目录下(自定义),最好是和hadoop集群安装目录一致,这样方便管理。
     然后,需要将 $FLUME_CONF_DIR添加到环境变量中,也就是通过vim /etc/profile:

点击(此处)折叠或打开

  1. $FLUME_CONF_DIR = $FLUME_HOME/conf

     最后,为了运行的便利,将flume安装路径以及zookeeper安装路径添加到环境变量中,之所以需要有zookeeper,是因为flume对其有所依赖。

点击(此处)折叠或打开

  1. export FLUME_HOME=/usr/local/hadoop/flume-0.9.3
  2. export PATH=$FLUME_HOME/bin:$PATH

  3. export ZOOKEEPER=/usr/local/hadoop/zookeeper-3.3.4-cdh3u3
  4. export PATH=$ZOOKEEPER/bin:$PATH
     这样,就完成了在一条机器上flume的安装,键入flume可以看到flume所有命令项参数:

点击(此处)折叠或打开

  1. usage: flume command [args...]
  2. commands include:
  3. dump Takes a specified source and dumps to console
  4. node Start a Flume node/agent (with watchdog)
  5. master Start a Flume Master server (with watchdog)
  6. version Dump flume build version information
  7. node_nowatch Start a flume node/agent (no watchdog)
  8. master_nowatch Start a Flume Master server (no watchdog)
  9. class <class> Run specified fully qualified class using Flume environment (no watchdog)
  10. ex: flume com.cloudera.flume.agent.FlumeNode
  11. classpath Dump the classpath used by the java executables
  12. shell Start the flume shell
  13. killmaster Kill a running master
  14. dumplog Takes a specified WAL/DFO log file and dumps to console

  3)Flume配置
     进入$FLUME_HOME/conf目录,其中有3个文件,flume-conf.xml、flume-site.xml、log4j.properties ,第一个是flume默认配置文件,第二个是用户配置文件。有的版本没有flume-site.xml,这时候会有个模板文件,把它cat或是mv进flume-site.xml就okay了。下面是简要配置:

点击(此处)折叠或打开

  1. <configuration>

  2. <property>
  3. <name>flume.master.servers</name>
  4. <value>hadoop-01</value>   // 可以设置多个服务主节点,根据集群大小设置
  5. <description>This is the address for the config servers status
  6. server (http)
  7. </description>
  8. </property>

  9. <property>
  10. <name>flume.collector.event.host</name> // 也可以多个
  11. <value>hadoop-02</value>
  12. <description>
  13. This is the host name for default "remote" collector.
  14. </description>
  15. </property>

  16. <property>
  17. <name>flume.collector.port</name> 
  18. <value>35853</value>
  19. <description>
  20. This is default tcp port that the collector listens to in order to receive events it is collecting.
  21. </description>
  22. </property>

  23. </configuration>
  将配置好的flume整个目录通过scp -r copy到集群中其它节点上。这样在命令行中运行flume master启动主节点,键入flume node 启动其它节点。然而,在实际环境中,需要用户进行适当调整,这可以参考 http://archive.cloudera.com/cdh/3/flume/UserGuide/。
原创粉丝点击