[flume]$1_flume使用

从网络端口采集数据输出到控制台

vi conf/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

flume-ng agent --name a1 --conf $FLUME_HOME/conf --conf-file $FLUME_HOME/conf/example.conf -Dflume.root.logger=INFO,console

监控一个文件实时采集新增的数据输出到控制台

vi conf/example2.conf

# exec-memory-log
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /usr/data/data.log
a1.sources.r1.shell = /bin/sh -c

# 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

flume-ng agent --name a1 --conf $FLUME_HOME/conf --conf-file $FLUME_HOME/conf/example2.conf -Dflume.root.logger=INFO,console

将a服务器日志实时采集到b服务器

vi conf/example3a.conf

# exec source + memory channel +avro sink     

# Name the components on this agent
a1.sources = exec-source
a1.sinks = avro-sink
a1.channels = memory-channel

# Describe/configure the source
a1.sources.exec-source.type = exec
a1.sources.exec-source.command = tail -F /usr/data/data.log
a1.sources.exec-source.shell = /bin/sh -c

# Describe the sink
a1.sinks.avro-sink.type = avro
a1.sinks.avro-sink.hostname = localhost
a1.sinks.avro-sink.port = 44444


# Use a channel which buffers events in memory
a1.channels.memory-channel.type = memory


# Bind the source and sink to the channel
a1.sources.exec-source.channels = memory-channel
a1.sinks.avro-sink.channel = memory-channel

vi conf/example3b.conf

# avro source + memory channel + logger sink

# Name the components on this agent
b1.sources = avro-source
b1.sinks = logger-sink
b1.channels = memory-channel

# Describe/configure the source
b1.sources.avro-source.type = avro
b1.sources.avro-source.bind = localhost
b1.sources.avro-source.port = 44444

# Describe the sink
b1.sinks.logger-sink.type = logger



# Use a channel which buffers events in memory
b1.channels.memory-channel.type = memory


# Bind the source and sink to the channel
b1.sources.avro-source.channels = memory-channel
b1.sinks.logger-sink.channel = memory-channel

flume-ng agent --name b1 --conf $FLUME_HOME/conf --conf-file $FLUME_HOME/conf/example3b.conf -Dflume.root.logger=INFO,console

flume-ng agent --name a1 --conf $FLUME_HOME/conf --conf-file $FLUME_HOME/conf/example3a.conf -Dflume.root.logger=INFO,console

日志收集过程:

  • a监控一个文件,有用户行为日志记录到data.log中
  • avro sink -> avro source -> b的控制台
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值