一:flume是什么
flume是一个分布式、高可靠、高可用的服务,能够有效的收集、聚合、移动大量的日志数据。
1、它有一个简单、灵活的基于流的数据流结构。
2、具有故障转移机制和负载均衡机制。
3、使用了一个简单的可扩展的数据模型(source、channel、sink)。
flume-ng处理数据有两种方式:avro-client、agent。
avro-client:一次性将数据传输到指定的avro服务的客户端。
agent:一个持续传输数据的服务。
Agent主要组件包含:Source 、Channel、Sink
数据在组件传输的单位是Event
二:部署agent
1:搭建
解压缩:apache-flume-1.6.0-bin.tar.gz
tar zvxf apache-flume-1.6.0-bin.tar.gz
cp conf/flume-env.sh.template conf/flume-env.sh
在conf/flume-env.sh配置
JAVA_HOME
创建配置文件example.conf
参考 conf/flume-conf.properties.template
注意:export JAVA_OPTS
2:启动agent
bin/flume-ng agent --conf conf/ --conf-file conf/example.conf --name a1 -Dflume.monitoring.type=http -Dflume.monitoring.port=34343 -Dflume.root.logger=INFO,console &
3:测试
netstat -an | grep 44444
1、windows下 telnet 需要安装telnet客户端功能。
2、linux下需要 yum install telnet
Telnet后 :ctrl + ] 回车 到telnet界面然后quit【q】退出
可以在[hostname:xxxx]/metrics 上看到监控信息
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