Windows10安装apache-flume-1.9.0-bin

1、flume1.9下载地址:http://mirror.bit.edu.cn/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
2、然后找到1.9版本下载解压到指定路径(安装路径名称不能有空格)即可。
3、使用cmd,进入apache-flume-1.9.0-bin/bin,检查安装是否成功:flume-ng.cmd version
在这里插入图片描述
可能会遇到如下错误:

C:\Users\jk\Desktop\apache-flume-1.9.0-bin\bin>bin\flume-ng.cmd version
 
C:\Users\jk\Desktop\apache-flume-1.9.0-bin\bin>powershell.exe -NoProfile -InputFormat none -ExecutionPolicy unrestricted -File C:\Users\jk\Desktop\apache-flume-1.9.0-bin\bin>\flume-ng.ps1 version
 
WARN: Config directory not set. Defaulting to C:\Users\jk\Desktop\apache-flume-1.9.0-bin\conf
Sourcing environment configuration script C:\Users\jk\Desktop\apache-flume-1.9.0-bin\conf\flume-env.ps1
Test-Path : 路径中具有非法字符。
所在位置 C:\Users\jk\Desktop\apache-flume-1.9.0-bin\bin\flume-ng.ps1:106 字符: 56
+ ...                               ? { "$_" -ne "" -and (Test-Path $_ )} |
+                                                         ~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (C:\Users\jk\Desktop\apache-flume-1.9.0-bin\":String) [Test-Path],ArgumentExceptio
    n
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand

解决:conf/flume-env.ps1下的Test-Path字符非法,在该文件中ctrl+F,发现Test-Path共出现在三个地方:GetHadoopHome、GetHbaseHome、GetHiveHome。这可能与本机没有安装这三个服务有关吧,尝试注释掉这些代码行(339-405),再次运行后发现flume可以正常显示version了。
4、进入apache-flume-1.9.0-bin\conf文件夹中创建一个example.conf文件。

# 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.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

5、使用cmd,进入apache-flume-1.9.0-bin/bin,运行下面命令启动Flume。

flume-ng agent --conf ../conf --conf-file ../conf/example.conf --name a1 -property flume.root.logger=INFO,console

6、启动另外一个cmd,使用telnet连接到44444端口并发送信息Hello World!

telnet localhost 44444

在这里插入图片描述
如果执行telnet命令报这个错则说明没有Windows没有开启telnet功能,需要开启
在这里插入图片描述
在这里插入图片描述
PS:当你发送的数据超过16字节时,在console的界面上也只能最多显示16字节,其实数据是能完全接收完全的!

7、sources使用spooldir
监控目录为C:\Users\jk\Desktop\logs,修改example.conf文件为:

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

# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.channels = c1
a1.sources.r1.spoolDir = /Users/jk/Desktop/logs
a1.sources.r1.fileHeader = true

# 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

重新执行上面的第5步,将写入Hello world!的hehe.txt放入到该目录下,则
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_37739193/article/details/103668027
今日推荐