3.Flume简单应用-netcat

1.安装netcat
这里写图片描述

rpm -ivh ./*.rpm

重启xineted

./etc/rc.d/init.d/xineted restart

2.使用flume命令

$ bin/flume-ng 
Usage: bin/flume-ng <command> [options]...

commands:
  agent                     run a Flume agent

global options:
  --conf,-c <conf>          use configs in <conf> directory
  -Dproperty=value          sets a Java system property value

agent options:
  --name,-n <name>          the name of this agent (required)
  --conf-file,-f <file>     specify a config file (required if -z missing)

 >>>>>>>>>>>>>>>>>>>>>>>>>>命令格式
 bin/flume-ng agent --conf conf --name agent-test --conf-file test.conf
 bin/flume-ng agent -c conf -n agent-test -f test.conf

—————————————————————— **配置文件**—————————
# The configuration file needs to define the sources, 
# the channels and the sinks.

### define agent
a1.sources = r1
a1.channels = c1
a1.sinks = k1

### define sources
a1.sources.r1.type = netcat
a1.sources.r1.bind = hadoop-senior-CDH
a1.sources.r1.port = 44444

### define channels
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

### define sink
a1.sinks.k1.type = logger
a1.sinks.k1.maxBytesToLog = 2014

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

3.运行
(1) 在Flume目录执行

bin/flume-ng agent \
-c conf \
-n a1 \
-f conf/a1.conf \
-Dflume.root.logger=DEBUG,console

(2)查看端口,启动了44444端口

netstat -tnlp
tcp  0  0 ::ffff:192.168.88.131:44444 :::*            LISTEN      3278/java   

(3)通过44444端口发送数据

telnet hadoop-CDH 44444
Trying 192.168.88.131...
Connected to hadoop-CDH.
Escape character is '^]'.
aa
OK
hello flume
OK
hi
OK

(4)收到消息

2017-05-02 04:20:42,369 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:70)] Event: { headers:{} body: 68 65 6C 6C 6F 20 66 6C 75 6D 65 0D             hello flume. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值