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放入到該目錄下,則
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章