案例一:监控端口数据
目标:Flume监控一端Console,另一端Console发送消息,使被监控端实时显示。分步实现:
1) 安装telnet工具
2) 创建Flume Agent配置文件flume-telnet.conf
#定义Agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
#定义netcatsource
a1.sources.r1.type = netcat
a1.sources.r1.bind = xk1
a1.sources.r1.port = 44445
# 定义sink
a1.sinks.k1.type = logger
# 定义channel
a1.channels.c1.type = memory
a1.channels.c1.capacit=1000
a1.channels.c1.transactionCapacity = 100
# 双向链接
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
3) 判断44444端口是否被占用
$ netstat -tunlp | grep 44445
4) 启动flume配置文件
方法一:
/opt/module/flume-1.8.0/bin/flume-ng agent
–conf /opt/module/flume1.8.0/conf/ --name a1
–conf-file /opt/module/flume-1.8.0/jobconf/flume-telnet.conf
-Dflume.root.logger==INFO,console
方法二:
bin/flume-ng agent --conf conf/ --name a1 --conf-file conf/flume-telnet.conf -Dflume.root.logger==INFO,console
5) 使用telnet工具向本机的44444端口发送内容
$ telnet bigdata111 44445