Linux安装flume并实现监控文件

flume的安装

1.找到flume的安装包并复制到/usr目录下
  • sudo cp flume-ng-1.6.0-cdh5.6.0.tar.gz /usr


    步骤
2.解压缩
  • sudo tar -zxvf flume-ng-1.6.0-cdh5.6.0.tar.gz


    步骤
3.更名成flume
  • sudo mv apache-flume-1.6.0-cdh5.6.0-bin flume


    步骤
4.修改权限为hadoop
  • sudo chown -R hadoop:hadoop flume


    步骤

    步骤
5.回到根目录下
  • cd
6.更改bashrc文件
  • vi .bashrc
    步骤

    添加以下内容:
    export FLUME_HOME=/usr/flume
    export FLUME_CONF=PATH:$FLUME_HOME/bin
    步骤
7.保存bashrc文件
  • source .bashrc


    步骤
8.修改flume-env.sh

进入cd /usr/flume/conf/ 目录下
发现没有flume-env.sh这个文件,将flume-env.sh.template复制并重新命名则得到这个文件

  • cp flume-env.sh.template flume-env.sh


    步骤

    打印Java环境变量所对应的值:

  • echo $JAVA_HOME


    步骤

    修改flume-env.sh这个文件:

  • vi flume-env.sh


    步骤

    加入以下内容:


    步骤

export JAVA_HOME=/usr/jdk18

#Give Flume more memory and pre-allocate, enable remote monitoring via JMX

export JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"

9.配置一个导入导出工程

首先配置一个导入flume_conf.conf文件

  • vi flume_conf.conf


    步骤
步骤

添加内容:
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source

a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/hadoop/flume/log.log

# Describe the sink

a1.sinks.k1.type = logger

# Use a channel which buffers events in memory

a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel

a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

10.新建一个文件并添加内容
步骤
11.启动flume

退到flume根目录下启动flume
./bin/flume-ng agent --conf ./conf --conf-file ./conf/flume_conf.conf --name a1 -Dflume.root.logger=INFO,console


步骤
12.在log.log文件下写东西,看flume端是否接收到
步骤

步骤

已经接收成功

(此文章仅作为个人学习笔记使用,如有错误欢迎指正~)

你可能感兴趣的:(Linux安装flume并实现监控文件)