Flume netcat被动source示例

来源:互联网 发布:淘宝的排行榜在哪里 编辑:程序博客网 时间:2024/06/05 15:40

一个Flume任务就是一个Agent,是由三部分组成,如图所示:


主要关注source和sink。

source分为主动的source和被动的source。

sink比如HDFS客户端,Kafka客户端等。


tar -zxvf apache-flume-1.6.0-bin.tar.gz


配置环境变量

vim ~/.bash_profile

...

source ~/.bash_profile


vim test01

# example.conf: A single-node Flume configuration# Name the components on this agenta1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the sourcea1.sources.r1.type = netcata1.sources.r1.bind = nodea1.sources.r1.port = 44444# Describe the sinka1.sinks.k1.type = logger# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1

$ bin/flume-ng agent --conf apache-flume-1.6.0-bin/conf/ --conf-file test01 --name a1 -Dflume.root.logger=INFO,console

apache-flume-1.6.0-bin/conf/是flume的配置文件。

test01是当前agent的配置文件。


它是一个tcp协议,可以通过netstat -ntpl命令查看

现在通过telnet(tcp协议客户端)来发送消息:

命令telnet node1:44444

接下来就可在shell里发消息了。


(查看yum源 more /etc/yum.repos.d/local.repo

通过yum来安装telnet,yum -y install telnet)


官网:https://flume.apache.org/FlumeUserGuide.html