(02)Flume安装及其启动

chenguangchun 2020-02-13

1、将文件解压到/usr/local

[ src]# tar -zxvf apache-flume-1.6.0-bin.tar.gz -C /usr/local/

  2、创建flume-env.sh文件,并设置jdk路径

[ local]# cp /usr/local/apache-flume-1.6.0-bin/conf/flume-env.sh.template /usr/local/apache-flume-1.6.0-bin/conf/flume-env.sh
[ local]# vim /usr/local/apache-flume-1.6.0-bin/conf/flume-env.sh

增加以下配置:

export JAVA_HOME=/usr/local/java/jdk1.8.0_201

如下图所示:

(02)Flume安装及其启动

  3、创建配置文件a3.conf 

[ apache-flume-1.6.0-bin]# mkdir /usr/local/apache-flume-1.6.0-bin/myagent

[ apache-flume-1.6.0-bin]# vim /usr/local/apache-flume-1.6.0-bin/myagent/a3.conf

内容如下:

#bin/flume-ng agent -n a3 -f myagent/a3.conf -c conf -Dflume.root.logger=INFO,console

#定义agent名, source、channel、sink的名称
a3.sources = r1
a3.channels = c1
a3.sinks = k1

#具体定义source
a3.sources.r1.type = spooldir
a3.sources.r1.spoolDir = /usr/local/logs/flumelogs

#具体定义channel
a3.channels.c1.type = memory
a3.channels.c1.capacity = 1000
a3.channels.c1.transactionCapacity = 100

#具体定义sink
a3.sinks.k1.type = logger

#组装source、channel、sink
a3.sources.r1.channels = c1
a3.sinks.k1.channel = c1

指定source为spooldir,监控的目录是:/usr/local/logs/flumelogs,如果该目录下的文件发生变化,就会通过flume把新变化的文件信息采集过来缓存在memory,通过sink指定的logger打印在console(控制台)

  4、启动flume

[ apache-flume-1.6.0-bin]# bin/flume-ng agent -n a3 -f myagent/a3.conf -c conf -Dflume.root.logger=INFO,console

启动成功如下图所示:

(02)Flume安装及其启动

  5、测试

新建一个文件,如下图所示:

(02)Flume安装及其启动

   移动到 /usr/local/logs/flumelogs下,查看控制台已经打印出信息,如图所示:

(02)Flume安装及其启动

相关推荐

wsong / 0评论 2020-04-15