欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

数据采集之flume

时间:2023-04-16
文章目录

前言一、flume是什么?二、使用步骤

1.flume框架2.安装netcat轻量级通讯工具(测试使用)3.配置flume工作文件4.启动flume5.监控文件


前言

上学的时候没有认真的学flume,现在来弥补。真是年少不知flume好,错把吴汉当成宝儿!


提示:以下是本篇文章正文内容,下面案例可供参考

一、flume是什么? 不专业的理解:英文翻译为:引水槽,放水沟。水就好比数据,那么我们就按照这个意思给它理解为引入数据的一个工具。
专业的解释:Apache Flume是一个分布式的、可靠的、可用的系统,用于有效地收集、 聚合和将大量日志数据从许多不同的源移动到一个集中的数据存储。 二、使用步骤 1.flume框架

数据源(日志)—>agent—>hdfs

agent:source、channel、sink。其中channel起到一个数据缓冲的作用。agent是一个jvm进程,输送数据。

2.安装netcat轻量级通讯工具(测试使用)

->sudo yum install -y nc
->判断端口是否被占用 sudo netstat -nlp | grep 9999
开服务端 nc -lk 9999
开客户端 nc localhost 9999
在服务端输入hello,在客户端可以看到接收到hello

3.配置flume工作文件

$mkdir job$cd job$touch net-flume-logger.conf

写入:

#example.conf: A single-node Flume configuration#Name the components on this agent 每个组件的名字,a1是agent的名字a1.sources = r1a1.sinks = k1a1.channels = c1#Describe/configure the source 监听端口的信息a1.sources.r1.type = netcata1.sources.r1.bind = localhosta1.sources.r1.port = 44444#Describe the sink 输出的类型a1.sinks.k1.type = logger#Use a channel which buffers events in memory 设置容量a1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100#Bind the source and sink to the channel source和sink绑定channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1

4.启动flume

$ bin/flume-ng agent -n a1 -c conf/ -f job/net-flume-logger.conf -Dflume.root.logger=INFO,console -DNC_PORT=9999

5.监控文件

先修改配置文件

a1.sources = r1a1.channels = c1a1.sinks = k1a1.sources.r1.type = execa1.sources.r1.command = tail -F /var/log/secure.log#监控的文件名称a1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100a1.sinks.k1.type=hdfsa1.sinks.k1.hdfs.path=hdfs://hadoop:50070/flume/%Y%m%d/%Ha1.sources.r1.channels = c1a1.sinks.k1.channel = c1


Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。