flume 1.6.0 安装及配置

flume 是一个日志收集系统,它可以自定义数据的来源和目的地,具体的介绍百度有一大把

flume-ng 的ng 指的是 next generation 就是新一代的意思

对应的就有 flume-og 即老的版本




flume 如图所示,我们可以任意定义flume的节点然后最终将log 写入hdfs 或者kafka 或者随便你怎么搞

我这里演示一下基本的安装与配置


step 1 下载与安装


首先

http://flume.apache.org/FlumeUserGuide.html

从 官网下载 apache-flume-1.6.0-bin.tar.gz,

tar -zxvf apache-flume-1.6.0-bin.tar.gz 解压


然后

配置jdk

此处略过 jdk 的安装。。。。。100字


再然后

进入 apache-flume-1.6.0-bin/conf

复制一份 flume-env.sh.template 并改名 flume-env.sh

vim flume-env.sh 加上一句 export JAVA_HOME=/usr/local/jdk7/ (你自己的安装位置)


step 2 配置


好了,我这里配置了3个 flume 两个收集日志,另一个汇总

结构如下

z0┐

    ├ ── 汇总─── > z2

z1┘

将 apache-flume-1.6.0-bin 复制 为 flume-z0 flume-z1 flume-z2 

分别进入 conf  将flume-conf.properties.template 复制为 agent0.conf 、agent1.conf 、agent2.conf


agent0 /agent1 :

a0.sources = r1
a0.channels = c1
a0.sinks = k1

# Describe/configure the source
 a0.sources.r1.type = exec
# a0.sources.r1.bind = localhost
# a0.sources.r1.port = 44444
 a0.sources.r1.command = tail -f /usr/local/flume-z0/testlog/test.log

 # Describe the sink
 a0.sinks.k1.type = avro
 a0.sinks.k1.hostname = localhost
 a0.sinks.k1.port = 44444

 # Use a channel which buffers events in memory
 a0.channels.c1.type = memory
 a0.channels.c1.capacity = 1000
 a0.channels.c1.transactionCapacity = 100

 # Bind the source and sink to the channel
 a0.sources.r1.channels = c1
 a0.sinks.k1.channel = c1

上面三个 都定义了 source channel sink ,这里的 source 使用了 type = exec 及unix 命令

将会监控 test.log

source 常用的还有 spooldir ---监控新增文件


  1. a1.sources.r1.type = spooldir
  2. a1.sources.r1.channels = c1
  3. a1.sources.r1.spoolDir = /home/hadoop/flume-1.5.0-bin/logs
  4. a1.sources.r1.fileHeader = true

还有 Avro 等,

这里 sinks 使用了 avro ,avro 是一个序列化rpc 系统

这里的sinks 将会指向 agent2 的 sources


agent2:

a2.sources = r1
a2.channels = c1
a2.sinks = k1

# Describe/configure the source
 a2.sources.r1.type = avro
 a2.sources.r1.bind = localhost
 a2.sources.r1.port = 44444
 a2.sources.r1.interceptors = i1
 a2.sources.r1.interceptors.i1.type = timestamp
# a2.sources.r1.command = tail -f /usr/local/flume-z0/testlog/test.log

 # Describe the sink
 a2.sinks.k1.type = logger

 # Use a channel which buffers events in memory
 a2.channels.c1.type = memory
 a2.channels.c1.capacity = 1000
 a2.channels.c1.transactionCapacity = 100

 # Bind the source and sink to the channel
 a2.sources.r1.channels = c1
 a2.sinks.k1.channel = c1


上面是agent2 source = avro,sink 只是logger,实际情况中可能指向 hdfs 或者 kafka 等


这样配置以后,我追加 z0/z1下的 test.log 文件 z0/z1监测到了文件的变化,z0/z1将会将日志信息传送至 z2


下面启动 z0 z1 z2

./bin/flume-ng agent --conf conf --conf-file ./conf/agent0.conf --name a0 -Dflume.root.logger=INFO,console
./bin/flume-ng agent --conf conf --conf-file ./conf/agent1.conf --name a1 -Dflume.root.logger=INFO,console
./bin/flume-ng agent --conf conf --conf-file ./conf/agent2.conf --name a2 -Dflume.root.logger=INFO,console


追加 z0 下面的文件 echo "asdasdasdasd000102002102102" >>/usr/local/flume-z0/testlog/test.log

z2中控制台输出




实验成功


sources channels sinks 汇总


*= org.apache.flume

Component InterfaceType AliasImplementation Class
*.Channelmemory*.channel.MemoryChannel
*.Channeljdbc*.channel.jdbc.JdbcChannel
*.Channelfile*.channel.file.FileChannel
*.Channel*.channel.PseudoTxnMemoryChannel
*.Channelorg.example.MyChannel
*.Sourceavro*.source.AvroSource
*.Sourcenetcat*.source.NetcatSource
*.Sourceseq*.source.SequenceGeneratorSource
*.Sourceexec*.source.ExecSource
*.Sourcesyslogtcp*.source.SyslogTcpSource
*.Sourcemultiport_syslogtcp*.source.MultiportSyslogTCPSource
*.Sourcesyslogudp*.source.SyslogUDPSource
*.Sourcespooldir*.source.SpoolDirectorySource
*.Sourcehttp*.source.http.HTTPSource
*.Sourcethrift*.source.ThriftSource
*.Sourcejms*.source.jms.JMSSource
*.Source*.source.avroLegacy.AvroLegacySource
*.Source*.source.thriftLegacy.ThriftLegacySource
*.Sourceorg.example.MySource
*.Sinknull*.sink.NullSink
*.Sinklogger*.sink.LoggerSink
*.Sinkavro*.sink.AvroSink
*.Sinkhdfs*.sink.hdfs.HDFSEventSink
*.Sinkhbase*.sink.hbase.HBaseSink
*.Sinkasynchbase*.sink.hbase.AsyncHBaseSink
*.Sinkelasticsearch*.sink.elasticsearch.ElasticSearchSink
*.Sinkfile_roll*.sink.RollingFileSink
*.Sinkirc*.sink.irc.IRCSink
*.Sinkthrift*.sink.ThriftSink
*.Sinkorg.example.MySink
*.ChannelSelectorreplicating*.channel.ReplicatingChannelSelector
*.ChannelSelectormultiplexing*.channel.MultiplexingChannelSelector
*.ChannelSelectororg.example.MyChannelSelector
*.SinkProcessordefault*.sink.DefaultSinkProcessor
*.SinkProcessorfailover*.sink.FailoverSinkProcessor
*.SinkProcessorload_balance*.sink.LoadBalancingSinkProcessor
*.SinkProcessor 
*.interceptor.Interceptortimestamp*.interceptor.TimestampInterceptor$Builder
*.interceptor.Interceptorhost*.interceptor.HostInterceptor$Builder
*.interceptor.Interceptorstatic*.interceptor.StaticInterceptor$Builder
*.interceptor.Interceptorregex_filter*.interceptor.RegexFilteringInterceptor$Builder
*.interceptor.Interceptorregex_extractor*.interceptor.RegexFilteringInterceptor$Builder
*.channel.file.encryption.
KeyProvider$Builder
jceksfile*.channel.file.encryption.JCEFileKeyProvider
*.channel.file.encryption.
KeyProvider$Builder
org.example.MyKeyProvider
*.channel.file.encryption.CipherProvideraesctrnopadding*.channel.file.encryption.AESCTRNoPaddingProvider
*.channel.file.encryption.CipherProviderorg.example.MyCipherProvider
*.serialization.EventSerializer$Buildertext*.serialization.BodyTextEventSerializer$Builder
*.serialization.EventSerializer$Builderavro_event*.serialization.FlumeEventAvroEventSerializer$Builder
*.serialization.EventSerializer$Builderorg.example.MyEventSerializer$Builder











评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值