Flume数据采集案例(一)单数据源多出口(选择器)

准备工作:

  • 三台已经安装好的虚拟机(weekend110、weekend01、weekend02)
  • 三台虚拟机上都已安装 JDK1.8 和 Flume1.7.0
  • 虚拟机weekend110上已安装 Hadoop2.7 和 Hive

需求:
使用在机器weekend110上部署的Flume-a1准实时监控日志文件 /tmp/hadoop/hive.log 的变动,Flume-a1将变动的内容传递给在weekend01上部署的Flume-a2,Flume-a2负责存储到HDFS。同时Flume-a1将变动内容传递给在weekend02上部署的Flume-a3,Flume-a3再负责输出到Local FileSystem的指定目录flume3下。

实现:

  1. 分别在三台机器上的 /home/hadoop/app/flume-1.7.0-bin/ 下创建一个job目录,用来专门存放要配置的conf配置文件。另外单独在机器weekend02的 /home/hadoop/datas/ 下创建自定义的输出目录flume3

  2. 分别在三台机器的 /home/hadoop/app/flume-1.7.0-bin/job 目录下配置各自的conf文件,如下:

在weekend110上,配置1个接收日志文件的source和两个channel、两个sink ,配置文件 flume-file-flume.conf 的内容如下:

# Name the components on this agent
a1.sources = r1
a1.sinks = k1 k2
a1.channels = c1 c2
# 将数据流复制给所有channel
a1.sources.r1.selector.type = replicating

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /tmp/hadoop/hive.log
a1.sources.r1.shell = /bin/bash -c

# Describe the sink
# sink端的avro是一个数据发送者
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = weekend01
a1.sinks.k1.port = 4141

a1.sinks.k2.type = avro
a1.sinks.k2.hostname = weekend02
a1.sinks.k2.port = 4142

# Describe the channel
a1.
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flume是Apache下的一个分布式、可靠且高可用的海量日志采集、聚合和传输的系统。它可以将多个数据源数据采集Hadoop系统中进行处理和分析。 一个简Flume采集方案案例如下: 1. 配置Flume Agent 在Flume的conf目录中,新建一个配置文件flume.conf,并添加以下内容: ``` # Name the components on this agent agent.sources = source1 agent.sinks = sink1 agent.channels = channel1 # Describe/configure the source agent.sources.source1.type = netcat agent.sources.source1.bind = localhost agent.sources.source1.port = 44444 # Describe the sink agent.sinks.sink1.type = logger # Use a channel which buffers events in memory agent.channels.channel1.type = memory agent.channels.channel1.capacity = 1000 agent.channels.channel1.transactionCapacity = 100 # Bind the source and sink to the channel agent.sources.source1.channels = channel1 agent.sinks.sink1.channel = channel1 ``` 2. 启动Flume Agent 在Flume的bin目录中,执行以下命令启动Flume Agent: ``` ./flume-ng agent --conf-file ../conf/flume.conf --name agent -Dflume.root.logger=INFO,console ``` 3. 发送数据 在终端中,执行以下命令向Flume Agent发送数据: ``` nc localhost 44444 ``` 4. 查看结果 在终端中,可以看到Flume Agent接收到了数据,并将数据输出到日志中。 以上就是一个简Flume采集方案案例。通过配置Flume Agent,可以方便地采集多个数据源的数据,并将数据传输到Hadoop系统中进行处理和分析。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值