Flume采集日志存储到HDFS

news/2024/5/20 0:49:18 标签: flume, hdfs, 大数据

1 日志服务器上配置Flume,采集本地日志文件,发送到172.19.115.96 的flume上进行聚合,如日志服务器有多组,则在多台服务器上配置相同的配置

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = TAILDIR
a1.sources.r1.filegroups = f1
#通配符是以.*为标识的,如采集所有文件则.*,此处表示采集.log结尾的文件
a1.sources.r1.filegroups.f1 = /home/admin/app/api/logs/.*log
#a1.sources.r1.filegroups = f1 f2
#a1.sources.r1.filegroups.f2 = /usr/local/flume-1.9.0/files2/.*
a1.sources.r1.positionFile = /usr/local/flume-1.9.0/taildir_position.json

# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = 172.19.115.96
a1.sinks.k1.port = 4141


# 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 hdfs服务器上配置flume

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 172.19.115.96
a1.sources.r1.port = 4141


# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://localhost:8020/test/%Y%m%d
#生成的hdfs文件名的前缀
a1.sinks.k1.hdfs.filePrefix = logs-
#指定滚动时间,默认是30秒,设置为0表示禁用该策略 生产调整为3600
a1.sinks.k1.hdfs.rollInterval = 10
#指定滚动大小,设置为0表示禁用该策略,128M
a1.sinks.k1.hdfs.rollSize = 134217700
#指定滚动条数
a1.sinks.k1.hdfs.rollCount = 0
#a1.sinks.k1.hdfs.batchSize = 100
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#生成的文件类型,默认是Sequencefile,可用DataStream,则为普通文本
a1.sinks.k1.hdfs.fileType = DataStream


# 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

3 在hdfs服务器上启动HDFS

start-dfs.sh

4 先启动hdfs服务器上的flume

 bin/flume-ng agent -c conf/ -f job/avro-flume-hdfs.conf -n a1

后台运行 

 nohup ./bin/flume-ng agent -c conf/ -f job/avro-flume-hdfs.conf -n a1 &

5 再启动日志服务器上的flume

bin/flume-ng agent -c conf/ -f job/file-flume-avro.conf -n a1

后台运行

nohup ./bin/flume-ng agent -c conf/ -f job/file-flume-avro.conf -n a1 &


http://www.niftyadmin.cn/n/5285506.html

相关文章

C语言——字符函数和字符串函数(三)【strtok,strerror,perror】

📝前言: 上一篇文章C语言——字符函数和字符串函数(二)对字符函数和字符串函数strstr,strcmp和strncmp进行了一定的讲解 这篇文章主要讲解以下函数的用法: 1,strtok 2,strerror 3,pe…

王者荣耀采用了一些什么技术开发的?

前言 《王者荣耀》属于典型的Moba类游戏,和《英雄联盟》属于同一种游戏类型,那么《王者荣耀》这种游戏是如何制作的?又需要学习哪些技术点呢?今天我们一起来分析一下。 对惹,这里有一个游戏开发交流小组,希…

危险品内陆运输相关知识_箱讯科技

危险品拖车 危险品拖车运输是一项涉及到高度危险物质的专业工作,需要确保合法合规的运输,并提供必要的信息以保障公共安全。进行这类运输时,需要携带一系列文件和具备特定的资质。 什么样的车适合做危险品拖车? 1、车辆类型:通…

vs code 代码统计 插件 (webstorm统计代码)

https://blog.csdn.net/aikudexiaohai/article/details/129367503 安装插件 VS Code Counter使用快捷键 Ctrl Shift P,搜素“VSCodeCounter”,选择 Count lines in directory。 在文件路径搜索框中,补充待统计的目录,如&#x…

前端---vscode 的基本使用

1. vscode 的基本介绍 全拼是 Visual Studio Code (简称 VS Code) 是由微软研发的一款免费、开源的跨平台代码编辑器,目前是前端(网页)开发使用最多的一款软件开发工具。 2. vscode 的安装 下载网址: Download Visual Studio Code - Mac, Linux, Windows选择对应…

科技云报道:开源才是大模型的未来?

科技云报道原创。 一年前,ChatGPT横空出世;7个多月后,Meta宣布开源LLaMA 2,并且可免费商用。 这一天,也成为大模型发展的分水岭。短时间内,LLaMA 2对一些闭源的大模型厂商造成了致命性的打击。 随后&…

Windows操作系统基础、命令与快捷键全攻略

基础知识: Windows系统是由微软公司开发的操作系统,广泛用于个人电脑和移动设备。Windows系统主要分为桌面和操作系统两部分,桌面是用户与计算机交互的主要界面,操作系统则负责管理计算机的硬件和软件资源。 命令: win…

轻松管理固定资产,易点易动固定资产管理系统为企业开启新篇章

在现代企业运营中,固定资产管理是一个不可忽视的关键环节。有效地管理和维护固定资产不仅可以提升企业运营效率,还能最大限度地发挥资产的价值。为了满足企业对固定资产管理的需求,我们推出了易点易动固定资产管理系统,一款功能强…