第一次接触flume,记录下下载与运行过程
- flume下载地址:http://www.apache.org/dyn/closer.lua/flume/1.7.0/apache-flume-1.7.0-bin.tar.gz
- 下载完毕后直接解压进入到配置文件夹apache-flume-1.7.0-bin\conf 下面创建一个文件test.conf输入以下内容:
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 = 50000
a1.sources.r1.channels = c1
# 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.sinks.k1.channel = c1
然后在apache-flume-1.7.0-bin\bin 目录下进入cmd界面输入:
flume-ng agent --conf ../conf --conf-file ../conf/test.conf --name a1 -property flume.root.logger=INFO,console
其中 flume.root.logger=INFO,console 仅为 测试开发环境 使用
-c/--conf 后跟配置目录,-f/--conf-file 后跟具体的配置文件,-n/--name 指定agent的名称
如果有弹出安全警告,输入R继续运行 最后结果如下
运行成功后在本地windows上开启远程登录功能Telnet 在控制面板—程序和功能—打开或关闭windows功能 当中勾选Telnet服务器和客户端
1)启动服务
打开一个cmd窗口(窗口-1),进入apache-flume-1.7.0-bin\bin文件夹,运行flume-ng.cmd命令启动Flume:
flume-ng agent --conf ../conf --conf-file ../conf/test.conf --name a1 -property flume.root.logger=INFO,console
2)发送消息
打开另一个命令行窗口(窗口-2),telnet连接到50000端口并发送信息Hello World!
telnet localhost 50000
在窗口-1可以看到接收到的消息:
注意事项:需要安装JDK 并配置jdk的环境变量。