展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

linux安装Flume

  • 前提
已经安装了jdk1.8
  • 将apache-flume-1.9.0-bin.tar.gz上传到服务器
# 解压
tar -zxvf apache-flume-1.9.0-bin.tar.gz
# 移动
mv /home/apache-flume-1.9.0-bin/* /usr/local/software/flume-1.9.0

# 配置
vi /etc/profile
# 添加如下
export FLUME_HOME=/usr/local/software/flume-1.9.0
export PATH=$FLUME_HOME/bin:$PATH
# 生效
source /etc/profile

# 验证
[root@master ~]# flume-ng version
Flume 1.9.0
Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git
Revision: d4fcab4f501d41597bc616921329a4339f73585e
Compiled by fszabo on Mon Dec 17 20:45:25 CET 2018
From source with checksum 35db629a3bda49d23e9b3690c80737f9
  • 采集netcat消息,将消息数据打印到控制台上
# 安装
yum -y install nc

# 在如下路径下新建文件
[root@master test]# pwd
/usr/local/software/flume-1.9.0/conf/test
[root@master test]# ls
test.conf
[root@master test]# vi test.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

# 进入如下目录启动
[root@master flume-1.9.0]# pwd
/usr/local/software/flume-1.9.0
[root@master flume-1.9.0]# flume-ng agent -c ./conf -n a1 -f ./conf/test/test.conf -Dflume.root.logger=INFO,console
cket:sun.nio.ch.ServerSocketChannelImpl[/127.0.0.1:44444]

# 使用Xshell连接服务器新开1个窗口
[root@master ~]# nc localhost 44444
11
OK
22
OK

# 查看原来的窗口,接收到数据
2023-12-13 22:57:08,924 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 31 31                                           11 }
2023-12-13 22:57:10,871 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 32 32                                           22 }
posted @ 2023-12-13 14:08  DogLeftover  阅读(43)  评论(0编辑  收藏  举报