Flume_Test

Flume

官网地址:http://flume.apache.org/FlumeUserGuide.html

1.解压文件

2.修改配置文件 flume-env.sh

​ JAVA_HOME=

3.修改path变量

4.查看版本 flume-ng version

eg:配置一个单机版的flume

​ source–>channels–>sink

vi conf/flume-conf01

# 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 = node01
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

启动一个agent

$ bin/flume-ng agent -n a1  -f conf/flume-conf01 -Dflume.root.logger=INFO,console

装一个小插件

yum install   telnet -y
telnet node01 44444 


搭建分布式的flume

source–>channel---->sink— —avro(rpc调用) — ----->source---->channel---->sink

node02:解压 环境变量 配置

vi conf/flume-conf02

# 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 = node03
a1.sources.r1.port = 10086

# Describe the sink
a1.sink.k1.type = avro
#a1.sink.k1.channels = c1   //和下面重复 可以删掉
a1.sink.k1.bind = 0.0.0.0
a1.sink.k1.port = 4545

# 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

node03:解压 环境变量 配置

vi conf/flume-conf03

# 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 = avro
a1.sources.r1.bind = node03
a1.sources.r1.port = 10086

# 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
$ bin/flume-ng agent -n a1  -f conf/flume-conf03 -Dflume.root.logger=INFO,console
$ bin/flume-ng agent -n a1  -f conf/flume-conf02 -Dflume.root.logger=INFO,console

测试:

telnet node2 44444 

source: avro netcat exec thrift spooling(目录要提前创建好) jms kafka netcat tcp …

sink: hdfs hive hbase EsSink (hdfs sink:http://flume.apache.org/FlumeUserGuide.html#hdfs-sink)


Caution:1g 最多有10万个文件

案例:

vi project

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

# Describe/ configure the source
a1.sources.rl.type = exec
a1.sources.r1.command = tail -F /opt/data/access.log

# Describe the sink
al.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /log/%y-%m-%d
al.sinks.kl.hdfs.filePrefix = events-
#文件控制
al.sinks.kl.hdfs.rollInterval = 0
al.sinks.kl.hdfs.rollSize = 10240000
al.sinks.kl.hdfs.rollCount = 0
al.sinks.k1.hdfs.callTimeout = 60000
al.sinks.kl.hdfs.fileType = DataStream
al.sinks.k1.hdfs.idleTimeout = 10
al.sinks.k1.hdfs.useLocalTimeStamp = true


# Use a channel which buffers events in memory
al.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.sink.k1.channel=c1


$ bin/flume-ng agent -n a1  -f conf/project -Dflume.root.logger=INFO,console

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值