Flume 官网地址:http://flume.apache.org/
下载地址:http://archive.apache.org/dist/flume/
(1)将 apache-flume-1.9.0-bin.tar.gz 上传到 linux 的/opt/software 目录下
(2)解压 apache-flume-1.9.0-bin.tar.gz 到/opt/module/目录下
tar -zxvf /opt/software/apache-flume-1.9.0-bin.tar.gz -C /opt/module/
(3)修改 apache-flume-1.9.0-bin 的名称为 flume
mv /opt/module/apache-flume-1.9.0-bin /opt/module/flume
(4)将 lib 文件夹下的 guava-11.0.2.jar 删除以兼容 Hadoop 3.1.3
rm /opt/module/flume/lib/guava11.0.2.jar
(1)安装 netcat 工具(在software目录下)
sudo yum install -y nc #若在root用户下,则无需sudo
(2)判断 44444 端口是否被占用
sudo netstat -nlp | grep 44444
(3)在 flume 目录下创建 job 文件夹并进入 job 文件夹
mkdir job
cd job
(4)在 job 文件夹下创建 Flume Agent 配置文件 flume-netcat-logger.conf
vim flume-netcat-logger.conf
(5)在 flume-netcat-logger.conf 文件中添加如下内容
添加内容如下:
# Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # 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
(6)先开启 flume 监听端口(进入filum目录下)
#第一种写法
bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-netcat-logger.conf - Dflume.root.logger=INFO,console
#第二种写法
bin/flume-ng agent -c conf/ -n a1 -f job/flume-netcat-logger.conf -Dflume.root.logger=INFO,console
(7)再开启一个窗口,使用 netcat 工具向本机的 44444 端口发送内容,出现以下结果时证明安装成功