博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Flume 示例
阅读量:4677 次
发布时间:2019-06-09

本文共 2416 字,大约阅读时间需要 8 分钟。

1.Syslog Tcp Source

sysylog通过配置一个端口,flume能够监控这个端口的数据。如果通往这个端口发送数据可以被flume接收到。可以通过socket发送。

#配置文件:syslog_case5.conf# Name the components on this agenta1.sources = r1a1.sinks = k1a1.channels = c1 # Describe/configure the sourcea1.sources.r1.type =syslogtcpa1.sources.r1.port =50000a1.sources.r1.host =192.168.233.128a1.sources.r1.channels =c1 # Describe the sinka1.sinks.k1.type = logger a1.sinks.k1.channel = c1 # Use a channel which buffers events inmemorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100

这里我们设置的侦听端口为192.168.233.128 50000

#敲命令

flume-ng agent -c -conf -f conf/syslog_case5.conf -n a1 -Dflume.root.logger=INFO,console

启动成功后

打开另一个终端输入,往侦听端口送数据

echo "hello looklook5" | nc 192.168.233.128 50000

然后看之前的终端,将会有如下显示:

数据已经发送过来了。

也可以通过代码,用socket向端口发送数据

Socket client = null;        try {            client = new Socket("192.168.1.75", 50000);            OutputStream out = client.getOutputStream();            String event = "hello world \n";            out.write(event.getBytes());            out.flush();            out.close();            client.close();        } catch (IOException e) {            e.printStackTrace();        }

发送的内容要以换行符结尾"\n"

 2.Taildir Source

taildir source通过监控一个目录或文件,目录的文件有任何改变会将新增加的内容写入到flume中。

a1.sources = r1a1.sinks = k1a1.channels = c1 # Describe/configure the sourcea1.sources.r1.type = TAILDIRa1.sources.r1.positionFile = /usr/apache-flume-1.7.0-bin/taildir_position1.jsona1.sources.r1.filegroups = f1a1.sources.r1.headers.f1.headerKey1 = value1#a1.sources.r1.filegroups.f1 = /usr/apache-flume-1.7.0-bin/test/.*a1.sources.r1.filegroups.f1 = /opt/apache-tomcat-7.0.72/8080/logs/.*a1.sources.r1.fileHeader = true# Describe the sinka1.sinks.k1.type = hdfsa1.sinks.k1.hdfs.path = hdfs://127.0.0.1:9008/tomcat/%Y-%m-%da1.sinks.k1.hdfs.writeFormat = Texta1.sinks.k1.hdfs.fileType = DataStreama1.sinks.k1.hdfs.rollInterval = 0a1.sinks.k1.hdfs.rollSize = 0a1.sinks.k1.hdfs.rollCount = 0a1.sinks.k1.hdfs.filePrefix = loga1.sinks.k1.hdfs.useLocalTimeStamp = truea1.sinks.k1.hdfs.idleTimeout = 30 # Use a channel which buffers events in memorya1.channels.c1.type = filea1.channels.c1.checkpointDir = /usr/apache-flume-1.7.0-bin/checkpointa1.channels.c1.dataDirs = /usr/apache-flume-1.7.0-bin/data# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1

 

转载于:https://www.cnblogs.com/Gyoung/p/6402184.html

你可能感兴趣的文章
python第四天练习题
查看>>
【bzoj4543】Hotel加强版(thr)
查看>>
没有标题(1)
查看>>
React-Native学习手册----搭建基于ios平台的开发环境
查看>>
Android手机 Fildder真机抓包
查看>>
[stm32] 中断
查看>>
L1-043 阅览室
查看>>
我大学时代的好朋友要结婚了!
查看>>
RTP Payload Format for Transport of MPEG-4 Elementary Streams over http
查看>>
PAT-1134. Vertex Cover (25)
查看>>
git 命令图解
查看>>
分布式存储系统可靠性系列三:设计模式
查看>>
this关键字的由来及使用
查看>>
两个时间相差多少 .net中的timespan应用
查看>>
递归 换零钱问题——由打靶子问题引申
查看>>
Python-函数基础
查看>>
Extensible Messaging and Presence Protocol (XMPP) 简介
查看>>
Farm Irrigation
查看>>
windows平板的开发和选型
查看>>
无平方因子的数(数论初步) By ACReaper
查看>>