2. 使用 Avro 數據源測試 Flume
Avro 可以發送一個給定的文件給 Flume,Avro 源使用 AVRO RPC 機制。請對 Flume
的相關配置文件進行設置,從而可以實現如下功能:在一個終端中新建一個文件
helloworld.txt(里面包含一行文本“Hello World”),在另外一個終端中啟動 Flume 以后,
可以把 helloworld.txt 中的文本內容顯示出來。
cd /usr/local/flume sudo vim ./conf/avro.conf
添加如下:
a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = avro a1.sources.r1.channels = c1 a1.sources.r1.bind = 0.0.0.0 a1.sources.r1.port = 4141 # 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
將helloworld.txt放在flume的主目錄路徑下。

啟動agent
./bin/flume-ng agent agent -c conf -f ./conf/avro.conf -n a1 -Dflume.root.logger=INFO,console
在同目錄下新建一個命令終端,使用avro-client發送文件
./bin/flume-ng avro-client -H localhost -p 4141 -F ./helloworld.txt
這是就可以在第一個命令終端中看到輸出的“hello world!”了

