九、flume案例(一)

1. 目标

source监听本地44444端口的数据,然后由sink在控制台展示出来。

2. 实现过程

1》在~/software下载flume最新版本:wget http://mirrors.shu.edu.cn/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
2》在当前文件夹下解压:tar -zxvf apache-flume-1.9.0-bin.tar.gz
3》进入flume根目录,新建job文件夹,在job下vim flume-telnet.conf,输入:

#single-node flume configuration

#first: name the component on this agent
a1.sources = r1
a1.channels = c1
a1.sinks =  k1

#second: describe the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

#third: describe the channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.transactionCapacity = 100

#fouth: describe the sink
a1.sinks.k1.type = logger

#fifth: bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

然后保存并退出
4》在flume根目录下执行bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-telnet.conf -Dflume.root.logger==INFO,console启动flume,启动命令详解:

  • 该命令是在flume分发包的根目录执行的
  • bin/flume-ng agent --conf conf/是固定写法,表示执行bin下的flume-ng这个文件 agent表示一个组件 --conf conf/表示配置文件是在conf目录下
  • –name a1表示这个组件的名字叫做a1
  • –conf-file job/flume-telnet.conf表示自己写的配置文件在job目录下,名字叫做flume-telnet.conf
  • -D表示动态的指定参数,这里指定的应该是root logger的日志级别

控制台没有报错,说明启动成功
5》使用telnet连接本地44444端口:telnet localhost 44444
6》在telnet控制台输入aaa,bbb,ccc看到flume的控制台抓取到了相应的数据,大功告成!!!

3. 参考文档

http://flume.apache.org/FlumeUserGuide.html#starting-an-agent

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值