flume练习记录

4 篇文章 0 订阅

flume-1监控日志,flume-1的数据传送给flume-2,flume-2将数据追加到本地文件,同时将数据传输到flume-3

flume-work1-1.conf

# Name the components on this agent
a1.sources = r1
a1.channels = c1 c2
a1.sinks = k1 k2

# copy duohe
a1.sources.r1.selector.type = replicating
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /opt/modules/hive/logs/hive.log
a1.sources.r1.shell = /bin/bash -c

# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = liangzelei002
a1.sinks.k1.port = 9527

a1.sinks.k2.type =avro
a1.sinks.k2.hostname = liangzelei002
a1.sinks.k2.port = 9528

# Describe the channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

a1.channels.c2.type = memory
a1.channels.c2.capacity = 1000
a1.channels.c2.transactionCapacity = 100

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

flume-work1-2.conf

# Name the components on this agent
a2.sources = r2
a2.channels = c2
a2.sinks = k2

# Describe/configure the source
a2.sources.r2.type = avro
a2.sources.r2.bind = liangzelei002
a2.sources.r2.port = 9527

# Describe the sink
a2.sinks.k2.type = file_roll
a2.sinks.k2.sink.rollInterval = 5
a2.sinks.k2.batchSize = 50
a2.sinks.k2.sink.directory = /opt/tmp/flume_work1

# Describe the channel
a2.channels.c2.type = memory
a2.channels.c2.capacity = 1000
a2.channels.c2.transactionCapacity = 100

# Bind the source and sink to the channel
a2.sources.r2.channels = c2
a2.sinks.k2.channel = c2

flume-work1-3.conf

# Name the components on this agent
a3.sources = r2
a3.channels = c2
a3.sinks = k2

# Describe/configure the source
a3.sources.r2.type = avro
a3.sources.r2.bind = liangzelei002
a3.sources.r2.port = 9528

# Describe the sink
a3.sinks.k2.type = logger

# Describe the channel
a3.channels.c2.type = memory
a3.channels.c2.capacity = 1000
a3.channels.c2.transactionCapacity = 100

# Bind the source and sink to the channel
a3.sources.r2.channels = c2
a3.sinks.k2.channel = c2

启动顺序为
bin/flume-ng agent
  --conf conf/
  --name a2
  --conf-file works/flume-work1-2.conf
  -Dflume.root.logger==INFO,console
bin/flume-ng agent 
  --conf conf/ 
  --name a3 
  --conf-file works/flume-work1-3.conf 
  -Dflume.root.logger==INFO,console
bin/flume-ng agent 
  --conf conf/ 
  --name a1 
  --conf-file works/flume-work1-1.conf 

  -Dflume.root.logger==INFO,console

原因是需要先占用9527和9528的端口,才能向这两个端口发送数据

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值