欢迎访问 生活随笔!

尊龙游戏旗舰厅官网

当前位置: 尊龙游戏旗舰厅官网 > 运维知识 > windows >内容正文

windows

storm基础系列之五-尊龙游戏旗舰厅官网

发布时间:2025/1/21 windows 21 豆豆
尊龙游戏旗舰厅官网 收集整理的这篇文章主要介绍了 storm基础系列之五---------接入数据收集系统flume 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

 

1.基本结构介绍

  flume是三层架构,agent,collector,storage。每一层都可水平扩展。

  其中,agent就是数据采集方;collector是数据整合方;storage是各种数据落地方,如hdfs。

  前两者都是由source和sink组成,source是数据读取组件,sink是数据分发组件。

  前两者作为不同类型node统一归master管理。可在master shell活web中动态配置。

2.自带的source

  text 文件,按行发送

  tail 探测新产生数据,安航发送

  fsyslog tcp(5140) 监听这个端口

  taildir("dirname"[, fileregex=".*"[, startfromend=false[, recursedepth=0]]]):监听目录中的文件末尾,使用正则去选定需要监听的文件(不包含目录),recursedepth为递归监听其下子目录的深度

3.想采集windows服务器上的日志文件,于是,研究了flume怎么在windows下部署。

    • 我用的是flulm1.6版本,直接尊龙游戏旗舰厅官网下载(不区分linux还是windows的)解压缩到本地
    • 下载了一个tail工具,用于动态读取日志文件增加的内容。原始下载地址找不到了,我放在自己云盘里:http://pan.baidu.com/s/1nuht1h3   提取码:ihx2 如果不可用请留言。
    • 使用方法就是直接解压缩,然后把exe文件放到c:/windows/system32/ 下,验证方式是随便找个txt文件,用tail -f 文件名。可以看到和linux一样的效果。
    • 把flume/conf下的flume-env.sh.template 文件的template后缀去掉,然后在里面加上java_home的配置: export java_home=d:\jdk1.8
    • 创建一个conf文件,exec_tail.conf,里面的内容是关于flume的配置: a1.sources = r1 a1.sinks = k1 a1.channels = c1 # describe/configure the source a1.sources.r1.type = exec a1.sources.r1.channels = c1 a1.sources.r1.command = tail -f d:\hadoopresouce\flume\logs\log_exec_tail.txt # 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

        其实里面需要修改的就是需要采集的文件全路径

    • 我使用了网上推荐的写一堆命令的方式,不过启动了不见效果。于是我采用其他人推荐的,写一个.bat方式。具体内容是: set flume_home=d:\hadoopresouce\flume set java_home=d:\jdk1.8 set java="%java_home%\bin\java.exe" set java_opts=-xmx1024m set conf=%flume_home%\conf\flume-conf.properties set agent=agent %java% %java_opts% -dflume.monitoring.type=http -dflume.monitoring.port=34545 -dlog4j.configuration=file:\\\%flume_home%\conf\log4j.properties -cp "%flume_home%\lib\*" org.apache.flume.node.application -f %flume_home%\conf\flume-conf.properties -n %agent%

        需要注意的是几处路径的配置

    • 至此,全部准备工作做完,下面在cmd进入flume/bin目录,执行这个.bat文件。
    • 通过http验证下:http://localhost:34545,能看到如下信息:

  { source.seqgensrc: { eventreceivedcount: "0", type: "source", appendbatchacceptedcount: "0", eventacceptedcount: "2532", appendreceivedcount: "0", starttime: "1468487063825", appendacceptedcount: "0", openconnectioncount: "0", appendbatchreceivedcount: "0", stoptime: "0" }, channel.memorychannel: { channelcapacity: "100", channelfillpercentage: "99.0", type: "channel", eventtakesuccesscount: "2423", channelsize: "99", starttime: "1468487063801", eventtakeattemptcount: "2424", eventputattemptcount: "2524", eventputsuccesscount: "2523", stoptime: "0" } }

4.读取目录新增加文件内容的配置

a1.sources.r1.type = spooldir a1.sources.r1.channels = c1 a1.sources.r1.spooldir = /home/master/yang/flume/logs a1.sources.r1.fileheader = true

5.写入kafka的配置

  这里踩的坑较多,一种可能是老版本配置,还有一种就是有的人没经过试验的东西就贴出来了。引以为戒,自己测试通过再贴,保持严谨,免得误人。

//看好类全路径是否都对,网上有不靠谱的写法,org.apache.flume.plugins.singlepartition 令人鄙视 a1.sinks.k1.type = org.apache.flume.sink.kafka.kafkasink //不知道为什么很多人这里项写为:a1.sinks.k1.metadata.broker.list,可能是之前版本有这个吧 a1.sinks.k1.brokerlist =master:9092,slave1:9092,slave2:9092 a1.sinks.k1.serializer.class=kafka.serializer.stringencoder //还有这玩意,这写法太坑人了a1.sinks.k1.custom.topic.name a1.sinks.k1.topic=kafka-storm-cluster a1.sinks.k1.channel=c1

6.读取telnet监控内容配置sink

a1.sources.r1.type= netcat a1.sources.r1.bind= localhost a1.sources.r1.port= 44444

7.常用命令:

启动: bin/flume-ng agent  -c ./conf/ -f conf/spool.conf -dflume.root.logger=debug,console -n a1

 

转载于:https://www.cnblogs.com/xyang/p/5667956.html

总结

以上是尊龙游戏旗舰厅官网为你收集整理的storm基础系列之五---------接入数据收集系统flume的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得尊龙游戏旗舰厅官网网站内容还不错,欢迎将尊龙游戏旗舰厅官网推荐给好友。

  • 上一篇:
  • 下一篇:
网站地图