flume(1)

简介:

根据flume的架构可以我们可以看出构造很简单
source-->channel-->sink


从一个agent练手
定义conf文件

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
#这两句表示sources和sinks的连在同一channel c1上
flume-ng agent -c conf -f 上面写的配置文件 --name a1 -Dflume.root.logger=INFO,console

source 类型为netcat 启用netcat输入内容则相应的所启动的flume上也会输出内容

Source类型
Avro source
需要写的配置有
a1.sources.r1.type = avro
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141

Thrift Source
a1.sources.r1.type = thrift
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141

Exec Source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /var/log/secure

JMS Source
a1.sources.r1.type = jms
a1.sources.r1.initialContextFactory = org.apache.activemq.jndi.ActiveMQInitialContextFactory
a1.sources.r1.connectionFactory = GenericConnectionFactory
a1.sources.r1.providerURL = tcp://mqserver:61616
a1.sources.r1.destinationName = BUSINESS_DATA
a1.sources.r1.destinationType = QUEUE

Spooling Directory Source
a1.channels = ch-1
a1.sources = src-1

a1.sources.src-1.type = spooldir
a1.sources.src-1.channels = ch-1
a1.sources.src-1.spoolDir = /var/log/apache/flumeSpool
a1.sources.src-1.fileHeader = true

....

Sink

HDFS Sink

1.channels = c1
a1.sinks = k1
a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/%S
a1.sinks.k1.hdfs.filePrefix = events-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute

Hive Sink
a1.channels = c1
a1.channels.c1.type = memory
a1.sinks = k1
a1.sinks.k1.type = hive
a1.sinks.k1.channel = c1
a1.sinks.k1.hive.metastore = thrift://127.0.0.1:9083
a1.sinks.k1.hive.database = logsdb
a1.sinks.k1.hive.table = weblogs
a1.sinks.k1.hive.partition = asia,%{country},%y-%m-%d-%H-%M
a1.sinks.k1.useLocalTimeStamp = false
a1.sinks.k1.round = true
a1.sinks.k1.roundValue = 10
a1.sinks.k1.roundUnit = minute
a1.sinks.k1.serializer = DELIMITED
a1.sinks.k1.serializer.delimiter = "t"
a1.sinks.k1.serializer.serdeSeparator = 't'
a1.sinks.k1.serializer.fieldnames =id,,msg

Logger Sink

a1.channels = c1
a1.sinks = k1
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

Avro Sink
a1.channels = c1
a1.sinks = k1
a1.sinks.k1.type = avro
a1.sinks.k1.channel = c1
a1.sinks.k1.hostname = 10.10.10.10
a1.sinks.k1.port = 4545

.....

Flume Channels

Memory Channel

a1.channels = c1
a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 10000
a1.channels.c1.byteCapacityBufferPercentage = 20
a1.channels.c1.byteCapacity = 800000

JDBC Channel

a1.channels = c1
a1.channels.c1.type = jdbc

Kafka Channel
a1.channels.channel1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.channel1.kafka.bootstrap.servers = kafka-1:9092,kafka-2:9092,kafka-3:9092
a1.channels.channel1.kafka.topic = channel1
a1.channels.channel1.kafka.consumer.group.id = flume-consumer

相关文章
|
7月前
|
消息中间件 监控 网络协议
Flume系统
Flume是一个分布式、可靠、和高可用的海量日志采集、聚合和传输系统,起源于Cloudera。【2月更文挑战第8天】
75 4
|
6月前
|
消息中间件 存储 关系型数据库
Flume(二)【Flume 进阶使用】(4)
Flume(二)【Flume 进阶使用】
|
6月前
|
SQL 存储 负载均衡
Flume(二)【Flume 进阶使用】(1)
Flume(二)【Flume 进阶使用】
|
6月前
|
监控 负载均衡
Flume(二)【Flume 进阶使用】(2)
Flume(二)【Flume 进阶使用】
|
数据采集 负载均衡
什么是flume?
什么是flume?
60 0
|
7月前
|
SQL 分布式计算 监控
|
7月前
|
JSON 分布式计算 Hadoop
Avro(flume)
Avro(flume)
|
7月前
|
JSON 监控 负载均衡
Flume相关技术汇总
Flume相关技术汇总
|
7月前
|
存储 分布式计算 监控
Flume(一)【Flume 概述】
Flume(一)【Flume 概述】