1.如果沒有安裝過Java環境,則需首先安裝JDK。
可參考《Windows上搭建Kafka運行環境》中的搭建環境安裝JDK部分
2.官方下載Flume(當前為apache-flume-1.8.0-bin.tar.gz)
3.根據官方用戶手冊,創建一個簡單例子監聽44444端口的輸入並在console中輸出。
①進入apache-flume-1.8.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
②使用cmd,進入apache-flume-1.8.0-bin/bin,運行下面命令啟動Flume。
flume-ng agent --conf ../conf --conf-file ../conf/example.conf --name a1 -property flume.root.logger=INFO,console
在console最后能看到下面這個端口監聽提示表示Flume進程正常啟動了。
③啟動另外一個cmd,使用telnet連接到44444端口並發送信息Hello World!
telnet localhost 44444
④在Flume的console中可以看到如下提示
PS:當你發送的數據超過16字節時,在console的界面上也只能最多顯示16字節,其實數據是能完全接收完全的!
如果發送數據真的超過最大長度,會出現Client sent event exceeding the maximum length錯誤。
可參考《flume-ng 測試過程中event丟失部分body數據》
以上。