flume-ng 1.4的安装
flume-ng是一个分布式、高可靠和高效的日志收集系统,具体说明参看flume-ng使用指南:http://blog.csdn.net/zhu_xun/article/details/16859645
flume-ng是flume的新版本的意思,其中“ng”意为new generate(新一代),目前来说,flume-ng 1.4是最新的版本
1.下载安装包
可以到官网http://www.apache.org/dist/flume/stable/网站下载安装包:apache-flume-1.4.0-bin.tar.gz
2.解压安装包
tar -zxvf apache-flume-1.4.0-bin.tar.gz
3.将解压后的文件夹移至指定目录下:
这里,我放置的位置是个人目录下。
mv apache-flume-1.4.0-bin ~/
4.将目录重命名
这里看你个人爱好吧,我觉得把名字改了,看着舒服一点,毕竟那么长。
mv apache-flume-1.4.0-bin flume-1.4.0
5.添加环境变量
使配置生效:
source /etc/profile
6.写一个简单的测试案例
(1).在conf目录下新建一个文件,example-conf.properties,内容如下:
- # Describe the source
- a1.sources = r1
- a1.sinks = k1
- a1.channels = c1
- # Describe/configure the source
- a1.sources.r1.type = avro
- 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
(2).在conf目录下新建一个源文件file01并向其中写入数据
touch file01;
echo "hello world" > file01
(3).启动agent代理
flume-ng agent -n a1 -f example-conf.properties
启动结果如下:
注:如果出现下面的异常,可以不用管它:
(4).启动avro-client客户端向agent代理发送数据:
flume-ng avro-client -H localhost -p 44444 -F file01
注:要新打开一个console端口进行操作。
(5).这时可以看到agen代理端输出如下: