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!”了
# 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
启动一个agent:
./bin/flume-ng agent --conf conf --conf-file conf/flume-conf.properties.example --name a1 -Dflume.root.logger=INFO,console
新打开一个终端(Tenlent终端),输入命令:
telnet localhost 44444
终端响应:
telnet localhost 44444 Trying 127.0.0.1... Connected to localhost. Escape character is ‘^]‘. Hello world! OK
输入“Hello world!”后tenlent终端输出ok,同时在Flume终端也会显示Hello world!
http://dblab.xmu.edu.cn/blog/1357-2/
原文:https://www.cnblogs.com/xhj1074376195/p/14261124.html