喵星之旅-调皮的大象-Flume安装

安装

将apache-flume-1.9.0-bin.tar.gz上传到linux

解压软件,重命名

1
2
tar -zxf  apache-flume-1.9.0-bin.tar.gz -C /opt/bunny/ 
mv /opt/bunny/apache-flume-1.9.0-bin /opt/bunny/flume

将lib文件夹下的guava-11.0.2.jar删除以兼容Hadoop 3.1.3
rm /opt/bunny/flume/lib/guava-11.0.2.jar

初步验证

使用Flume监听一个端口,收集该端口数据,并打印到控制台。

在flume目录下创建job文件夹并进入job文件夹。

1
2
mkdir -p /opt/bunny/flume/job/simpleCase
cd /opt/bunny/flume/job/simpleCase

编写配置文件(注释去掉!!!):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
vim flume-1-netcat-logger.conf

#Name the components on this agent
a1.sources = r1 # 为a1的Source组件命名为r1,多个组件用空格间隔
a1.sinks = k1 # 为a1的Sink组件命名为k1,多个组件用空格间隔
a1.channels = c1 # 为a1的Channel组件命名为c1,多个组件用空格间隔

# Describe/configure the source
a1.sources.r1.type = netcat # 配置r1的类型
a1.sources.r1.bind = h102 # 配置r1的绑定地址
a1.sources.r1.port = 44444 # 配置r1的监听端口

# Describe the sink
a1.sinks.k1.type = logger # 配置k1的类型为logger,输出到控制台

# Use a channel which buffers events in memory
a1.channels.c1.type = memory # 配置c1的类型为memory
a1.channels.c1.capacity = 1000 # 配置c1的容量为1000个事件
a1.channels.c1.transactionCapacity = 100 # 配置c1的事务容量为100个事件

# Bind the source and sink to the channel
a1.sources.r1.channels = c1 # 配置r1的channel属性,指定r1连接到那个channel
a1.sinks.k1.channel = c1 # 配置k1的channel属性,指定k1连接到那个channel

部署运行flume监听端口

1
2
3
cd /opt/bunny/flume

bin/flume-ng agent --conf conf/ --name a1 --conf-file job/simpleCase/flume-1-netcat-logger.conf -Dflume.root.logger=INFO,console

使用netcat工具向本机的44444端口发送内容.在Flume监听页面观察接收数据情况

1
nc localhost 44444

在此窗口输入内容,则监听页面会显示内容。

文章目录
  1. 安装
  2. 初步验证
|