现在位置: 首页 > 博客文章 > 电脑相关 > IT开发 > 大数据 > Flume > 正文
大数据学习初级入门教程(十四) —— Flume 1.9.x 单节点的安装、配置、启动和测试
2022年10月05日 11:22:05 Flume ⁄ 共 3589字 评论数 1 ⁄ 被围观 1,455次

官网介绍如下:

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 是一种分布式的、可靠的且可用的服务,可以高效地收集、聚合和移动大量日志数据。它具有基于流数据流的简单灵活的体系结构。它具有健壮性和容错性,具有可调的可靠性机制和许多故障转移和恢复机制。它使用一个简单的可扩展数据模型,允许在线分析应用。

本篇主要简单介绍下 Flume 的安装、配置、启动和测试。

第一步:上传安装包

上传 flume 包到测试服务器,这里测试直接上传到 home 目录下。

第二步:解压安装包

# cd /home

# tar -zxvf apache-flume-1.9.0-bin.tar.gz

第三步:重命名目录

由于解压的 flume 安装包目录名较长,这里修改短一些(强迫症)

# mv apache-flume-1.9.0-bin flume-1.9.0

第四步:配置环境变量

修改当期用户配置文件.bash_profile

# vi ~/.bash_profile

在配置最后添加如下配置:

export FLUME_HOME=/home/flume-1.9.0
export PATH=$PATH:$FLUME/bin

执行命令使得配置立刻生效:

# source ~/.bash_profile

第五步,创建自定义配置

在 Flume 的安装目录下,创建个自定义配置文件目录 defconf

# cd /home/flume-1.9.0

# mkdir defconf

创建自定义配置文件 netcat2logger,配置如下:

# example.conf: A single-node Flume configuration

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

# Describe/configure the source
a1.sources.r1.type = netcat
#a1.sources.r1.bind = localhost

a1.sources.r1.bind = node19
a1.sources.r1.port = 44444

# 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

第六步:启动 Flume

# flume-ng agent --conf conf --conf-file defconf/netcat2logger --name a1 -Dflume.root.logger=INFO,console

可以看到输出日志如下:

第七步:测试

在安装 flume 的节点机器上,使用下面命令发送信息:

# telnet node19 44444

可以看到 flume 监听的端口收到了发送的信息,并打印到了控制台:

第八步:停止 Flume

按 Ctrl+C 或者 Ctrl+Z 即可停止。

常见错误:

错误一:在查看 Flume 版本时,提示“Unsupported major.minor version 52.0”。

[root@node19 flume-1.9.0]# flume-ng version
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/flume/tools/GetJavaProperty : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Error: Could not find or load main class org.apache.flume.tools.GetJavaProperty
Flume 1.9.0
Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git
Revision: d4fcab4f501d41597bc616921329a4339f73585e
Compiled by fszabo on Mon Dec 17 20:45:25 CET 2018
From source with checksum 35db629a3bda49d23e9b3690c80737f9

解决方法:说明 JDK 版本太低导致,可以把 hbase 和 hadoop 中的 export JAVA_HOME 修改,一般都需要升高 JDK 版本。

错误二:Error: Could not find or load main class org.apache.flume.tools.GetJavaProperty

找不到或无法加载主类 org.apache.flume.tools.GetJavaProperty。如果系统里安装了 hbase,会出现错误:找不到或无法加载主类 org.apache.flume.tools.GetJavaProperty。如果没有安装hbase,这一步可以略过。

解决方法:

方法一:将 hbase 的 hbase.env.sh 的这一行配置注释掉,即在 export 前加一个#。

#export HBASE_CLASSPATH=/home/hadoop/hbase/conf

方法二:将 HBASE_CLASSPATH 改为 JAVA_CLASSPATH,配置如下:

export JAVA_CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Flume 环境简单的操作写到这里,Good Luck! ​

原文链接:https://blog.csdn.net/tzhuwb/article/details/127170336

目前有 1 条留言 其中:访客:0 条, 博主:0 条

  1. Avatar photo 10lotoline : 2023年04月15日03:52:07  -9楼 @回复 回复
    Thank you for the information

给我留言

留言无头像?