Flume监听端口数据
实验环境
IP | 主机名 | 组件 | 版本 |
---|---|---|---|
192.168.222.101 | master | flume | 1.6.0 |
192.168.222.102 | slave1 | jdk | 1.8 |
192.168.222.101 | master | jdk | 1.8 |
防火墙已关闭
1、配置conf文件
[root@master ~]# vim /usr/local/src/flume/conf/listen-port-data.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = netcat
# 配置主机名/IP地址
a1.sources.r1.bind = master
# 配置端口
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
2、运行flume
[root@master ~]# flume-ng agent --conf conf --conf-file /usr/local/src/flume/conf/listen-port-data.conf --name a1 -Dflume.root.logger=INFO,console
21/10/13 15:46:53 INFO node.Application: Starting new configuration:{ sourceRunners:{r1=EventDrivenSourceRunner: { source:org.apache.flume.source.NetcatSource{name:r1,state:IDLE} }} sinkRunners:{k1=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor@4a52f3b4 counterGroup:{ name:null counters:{} } }} channels:{c1=org.apache.flume.channel.MemoryChannel{name: c1}} }
21/10/13 15:46:53 INFO node.Application: Starting Channel c1
21/10/13 15:46:53 INFO node.Application: Waiting for channel: c1 to start. Sleeping for 500 ms
21/10/13 15:46:53 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: CHANNEL, name: c1: Successfully registered new MBean.
21/10/13 15:46:53 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: c1 started
21/10/13 15:46:54 INFO node.Application: Starting Sink k1
21/10/13 15:46:54 INFO node.Application: Starting Source r1
21/10/13 15:46:54 INFO source.NetcatSource: Source starting
21/10/13 15:46:54 INFO source.NetcatSource: Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/192.168.222.101:4444]
3、打开一个新的终端
-
安装telnet
[root@master ~]# yum install -y telnet
-
使用telnet命令
[root@master ~]# telnet master 4444 Trying 192.168.222.101... Connected to master. Escape character is '^]'. OK this is my first demo OK
-
接收端信息
21/10/13 15:51:46 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: c1 started 21/10/13 15:51:46 INFO node.Application: Starting Sink k1 21/10/13 15:51:46 INFO node.Application: Starting Source r1 21/10/13 15:51:46 INFO source.NetcatSource: Source starting 21/10/13 15:51:46 INFO source.NetcatSource: Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/192.168.222.101:4444] 21/10/13 15:51:52 INFO sink.LoggerSink: Event: { headers:{} body: 0D . } 21/10/13 15:52:01 INFO sink.LoggerSink: Event: { headers:{} body: 74 68 69 73 20 69 73 20 6D 79 20 66 69 72 73 74 this is my first }