2-网站日志分析案例-基于Flume采集WEB日志-windows版本

简介: 文章目录2-网站日志分析案例-基于Flume采集WEB日志-windows版本1.Flume简介2.在Windows环境下安装Flume

2-网站日志分析案例-基于Flume采集WEB日志-windows版本

1.Flume简介

Flume is a distributed, reliable, and available service for

efficiently collecting, aggregating, and moving large amounts of log

data. It has a simple and flexible architecture based on streaming

data flows. It is robust and fault tolerant with tunable reliability

mechanisms and many failover and recovery mechanisms. It uses a simple

extensible data model that allows for online analytic application.


译文:Flume是一种分布式的、可靠的、可用的服务,用于高效地收集、聚合和移动大量的日志数据。它具有基于流数据流的简单而灵活的架构。它具有可调的可靠性机制和许多故障转移和恢复机制,具有健壮性和容错能力。它使用一个简单的可扩展数据模型,允许在线分析应用程序。

2.在Windows环境下安装Flume

1.本地需要配置JAVA_HOME

2.下载flume

https://flume.apache.org/download.html页面,我下载的版本为1.9.0

3.启动命令测试

D:\apache\apache-flume-1.9.0-bin\apache-flume-1.9.0-bin\bin>flume-ng version

安装是很简单的。

3.基于Flume完成Windows下的日志采集

3.1流程

sources类型选择:因为window下没有tail命令,所以无法监控单个文件,需要通过spooldir监控日志目录

channels类型选择:为了快,便捷,选择memory

sinks类型选择:采用logger和file_roll两种,其中logger为了查看是否成功,file_roll实现日志文件迁移

3.2具体配置

# 配置agent1的三个组件
agent1.sources = source1
agent1.sinks = sink1 sink2 sink3
agent1.channels = channel1
# Describe/configure spooldir source1
agent1.sources.source1.channels = channel1
agent1.sources.source1.type = spooldir
agent1.sources.source1.spoolDir = E://log
agent1.sources.source1.inputCharset = GBK
agent1.sources.source1.fileHeader = true
#configure host for source
agent1.sources.source1.interceptors = i1
agent1.sources.source1.interceptors.i1.type = host
agent1.sources.source1.interceptors.i1.hostHeader = hostname
# Describe sink1 file_roll
agent1.sinks.sink1.channel = channel1
agent1.sinks.sink1.type = file_roll
agent1.sinks.sink1.sink.directory = D://flume-collection
agent1.sinks.sink1.sink.rollInterval = 60
# Describe sink2
agent1.sinks.sink2.channel = channel1
agent1.sinks.sink2.type = logger
# Describe sink3
agent1.sinks.sink3.channel = channel1
agent1.sinks.sink3.type = hdfs
agent1.sinks.sinks.hdfs.useLocalTimeStamp = true
agent1.sinks.sink3.hdfs.path = /sx/logtable/%Y-%m-%d
agent1.sinks.sink3.hdfs.filePrefix = logevent
agent1.sinks.sink3.hdfs.rollInterval = 10
agent1.sinks.sink3.hdfs.rollSize = 134217728
agent1.sinks.sink3.hdfs.rollCount = 0
# Use a channel which buffers events in memory
agent1.channels.channel1.type = memory
agent1.channels.channel1.keep-alive = 120
agent1.channels.channel1.capacity = 500000
agent1.channels.channel1.transactionCapacity = 600

3.3 启动

D:\apache\apache-flume-1.9.0-bin\apache-flume-1.9.0-bin>.\bin\flume-ng agent --conf conf --conf-file  c

D:\apache\apache-flume-1.9.0-bin\apache-flume-1.9.0-bin>.\bin\flume-ng agent --conf conf --conf-file conf\log2file.conf --name agent1 -property flume.root.logger=INFO,console


3.4 注意事项

1.需要确定读取日志文件的编码格式,默认读取格式为UTF-8,如果编码不为默认,需要手动修改,如果编码格式不正确,可能出现:

FATAL: Spool Directory source source1: { spoolDir: E://log }: Uncaught exception in SpoolDirectorySource thread. Restart or reconfigure Flume to continue processing.
java.nio.charset.MalformedInputException: Input length = 1

2.agent1.sinks.sink1.sink.directory = D://flume-collection,要注意配置的key为sink.directory,否则会出现

Directory may not be null

的错误

4.总结

本文主要基于Flume实现了日志的采集,本文案例不复杂,但由于基于windows实现的案例不多,笔者尽量把自己遇到的问题描述在博客中,包括编码问题和配置的注意事项,减少大家的试错成本。

相关实践学习
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
相关文章
|
6月前
|
开发框架 监控 安全
Windows Defender 导致 Web IIS 服务异常停止排查
某日凌晨IIS服务异常停止,经查为Windows Defender安全补丁KB2267602触发引擎更新,导致系统资源波动,进而引发应用池回收。确认非人为操作,系统无重启。通过分析日志与监控,定位原因为Defender更新后扫描加重负载。解决方案:将IIS及.NET相关路径添加至Defender排除列表,避免业务影响。
720 116
|
6月前
|
Java 测试技术 网络安全
Burp Suite Professional 2025.10 for Windows x64 - 领先的 Web 渗透测试软件
Burp Suite Professional 2025.10 for Windows x64 - 领先的 Web 渗透测试软件
296 0
Burp Suite Professional 2025.10 for Windows x64 - 领先的 Web 渗透测试软件
|
6月前
|
开发框架 安全 .NET
Microsoft .NET Framework 3.5、4.5.2、4.8.1,适用于 Windows 版本的 .NET,Microsoft C Runtime等下载
.NET Framework是Windows平台的开发框架,包含CLR和FCL,支持多种语言开发桌面、Web应用。常用版本有3.5、4.5.2、4.8.1,系统可同时安装多个版本,确保软件兼容运行。
1540 0
Microsoft .NET Framework 3.5、4.5.2、4.8.1,适用于 Windows 版本的 .NET,Microsoft C Runtime等下载
|
7月前
|
运维 监控 安全
EventLog Analyzer:高效的Web服务器日志监控与审计解决方案
ManageEngine EventLog Analyzer是一款企业级Web服务器日志监控与审计工具,支持Apache、IIS、Nginx等主流服务器,实现日志集中管理、实时威胁检测、合规报表生成及可视化分析,助力企业应对安全攻击与合规挑战,提升运维效率。
380 1
|
9月前
|
运维 Linux 虚拟化
VMware虚拟机安装教程,Windows下安装VMware虚拟机,附VMware下载,Windows各版本系统镜像下载
虚拟机技术允许一台物理机运行多个操作系统,提升资源利用率,节省成本。通过快照、克隆等功能,实现系统快速恢复与复制,提高运维效率。本文详细介绍VMware虚拟机的安装步骤、Windows镜像下载及系统安装激活流程,适合初学者快速入门。
11682 0
|
9月前
|
安全 Linux iOS开发
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
730 0
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
|
9月前
|
Windows
Windows下版本控制器(SVN)-验证是否安装成功+配置版本库+启动服务器端程序
Windows下版本控制器(SVN)-验证是否安装成功+配置版本库+启动服务器端程序
256 2
|
9月前
|
Linux Docker Windows
windows docker安装报错适用于 Linux 的 Windows 子系统必须更新到最新版本才能继续。可通过运行 “wsl.exe --update” 进行更新。
适用于 Linux 的 Windows 子系统需更新至最新版本(如 wsl.2.4.11.0.x64.msi)以解决 2025 年 Windows 更新后可能出现的兼容性问题。用户可通过运行 “wsl.exe --update” 或访问提供的链接下载升级包进行更新。
3685 0
|
Windows
Windows下版本控制器(SVN)- 配置版本库
Windows下版本控制器(SVN)- 配置版本库
140 0

热门文章

最新文章

下一篇
开通oss服务