Flume小案例札记

Ø 应用场景(一):

采集发往某个端口的所有数据、、、

 

#example.comf: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.transactioinCapacity = 100

 

#Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

 

说明:

以上为flume-ng小案例的配置文件,具体如下:

l sources

l sinks

l channels

 

启动命令,

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

说明:

1、这种是直接启动在前台,主要是便于查看

2、在实际生产环境中建议以后台方式启动

 

然后,可以使用telnet进行数据测试

->telnet localhost 44444

 

Ø 应用场景(二):

监视文件夹、、、

配置文件详见spool-loggger.conf

 

启动命令:

bin/flume-ng agent -c ./conf -f

./conf/spool-logger.conf -n al -Dflume.root.logger=INFO,console

 

测试:

/root/flumespool放文件

mv xx/xxxfile /root/flumespool,但是不要在里面生成文件

 

另外,

Flume安装问题:

1、下载、解压

2、ln

3、找到conf,根据应用场景写相应的配置文件,比如spool-logger.conf

4、使用bin/flume-ng agent -c ...启动即可

5、测试,[根据具体的应用场景使用不同的测试方式]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值