kafak 到 hdfs 通过flumes elector.type = replicating 副本发送

94 篇文章 2 订阅
26 篇文章 1 订阅

#example.conf: A single-node Flume configuration

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

#Describe/configure the source
a1.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.r1.kafka.bootstrap.servers = hdp4:6667,hdp5:6667,hdp6:6667
a1.sources.r1.kafka.consumer.group.id = flume1
# 定义kafka所在zk的地址
a1.sources.r1.zookeeperConnect = hdp1.hdp:2181,hdp2.hdp:2181,hdp3.hdp:2181
a1.sources.r1.kafka.topics = IOT_DS_DATA_BACK2
# 消费超时时间
a1.sources.r1.kafka.consumer.timeout.ms = 10000
#向channel写入消息的最多条数
a1.sources.r1.batchSize = 50000
#向channel书写的最大时间 (毫秒)
a1.sources.r1.batchDurationMillis = 2000
#9.7mb
a1.sources.r1.kafka.consumer.max.partition.fetch.bytes = 10240000

# Describe the sink1
a1.sinks.k1.type = hdfs
# hdfs://hdp1.hdp:8020/IOT/*/%y-%m-%d/%H-%M
a1.sinks.k1.hdfs.path = hdfs://hdp1.hdp:8020/IOT/111/20%y/%m/%d-%H-%M
#用本地时间格式化目录
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#下沉后, 生成的文件类型,默认是Sequencefile,可用DataStream,则为普通文本  a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat = Text
a1.sinks.k1.hdfs.fileType = DataStream
#fileType: 默认值为SequenceFile,文件格式主要包括:SequenceFile, DataStream, CompressedStream;
#当使用DataStream时,文件不会被压缩,则不需要设置hdfs.codeC; 当使用CompressedStream时,则必须设置一个正确的hdfs.codeC值
#a1.sinks.k1.hdfs.fileType = CompressedStream
#codeC: 文件压缩格式,包括:gzip, bzip2, lzo, lzop, snappy;
#a1.sinks.k1.hdfs.codeC = lzop
#前缀
a1.sinks.k1.hdfs.filePrefix = data
#后缀
a1.sinks.k1.hdfs.fileSuffix=.json
#文件回滚之前等待的时时间单位 秒
a1.sinks.k1.hdfs.rollInterval = 100
#文件滚动大的大小限制(bytes)8000000  /1024/1024
a1.sinks.k1.hdfs.rollSize =  90000000
#写入多少个 event 数据后滚动文件(事件个数)
a1.sinks.k1.hdfs.rollCount = 70000
#hdfs sink启动的操作HDFS的线程数。
a1.sinks.k1.hdfs.threadsPoolSize = 100
#默认值:1,hdfs sink 启动的根据时间滚动文件的线程数。
a1.sinks.k1.hdfs.rollTimerPoolSize = 10
# 事件就往里面写入
a1.sinks.k1.hdfs.batchSize = 100000
a1.sinks.k1.hdfs.txnEventMax = 100000


# 10 分钟就创建文件
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
#默认值为0, 当目前被打开的临时文件在该参数指定的时间(秒)内,没有任何数据写入,则将该临时文件关闭并重命名成目标文件
#a1.sinks.k1.hdfs.idleTimeout=300
#默认值为HDFS副本数;写入HDFS文件块的最小副本数,该参数会影响文件的滚动配置,一般将该参数配置成1,才可以按照配置正确滚动文件;
a1.sinks.k1.hdfs.minBlockReplicas=1
#默认值5000,最大允许打开的HDFS文件数,当打开的文件数达到该值,最早打开的文件将会被关闭;
a1.sinks.k1.hdfs.maxOpenFiles=5000
#默认值:10000,执行HDFS操作的超时时间(单位:毫秒);
a1.sinks.k1.hdfs.callTimeout=100000

# Describe the sink2
a1.sinks.k2.type = hdfs
# hdfs://hdp1.hdp:8020/IOT/*/%y-%m-%d/%H-%M
a1.sinks.k2.hdfs.path = hdfs://hdp1.hdp:8020/IOT/112/20%y/%m/%d-%H-%M
#用本地时间格式化目录
a1.sinks.k2.hdfs.useLocalTimeStamp = true
#下沉后, 生成的文件类型,默认是Sequencefile,可用DataStream,则为普通文本  a1.sinks.k2.hdfs.fileType = DataStream
a1.sinks.k2.hdfs.writeFormat = Text
a1.sinks.k2.hdfs.fileType = DataStream
#fileType: 默认值为SequenceFile,文件格式主要包括:SequenceFile, DataStream, CompressedStream;
#当使用DataStream时,文件不会被压缩,则不需要设置hdfs.codeC; 当使用CompressedStream时,则必须设置一个正确的hdfs.codeC值
#a1.sinks.k2.hdfs.fileType = CompressedStream
#codeC: 文件压缩格式,包括:gzip, bzip2, lzo, lzop, snappy;
#a1.sinks.k2.hdfs.codeC = lzop
#前缀
a1.sinks.k2.hdfs.filePrefix = data
#后缀
a1.sinks.k2.hdfs.fileSuffix=.json
#文件回滚之前等待的时时间单位 秒
a1.sinks.k2.hdfs.rollInterval = 100
#文件滚动大的大小限制(bytes)8000000  /1024/1024
a1.sinks.k2.hdfs.rollSize =  90000000
#写入多少个 event 数据后滚动文件(事件个数)
a1.sinks.k2.hdfs.rollCount = 70000
#hdfs sink启动的操作HDFS的线程数。
a1.sinks.k2.hdfs.threadsPoolSize = 100
#默认值:1,hdfs sink 启动的根据时间滚动文件的线程数。
a1.sinks.k2.hdfs.rollTimerPoolSize = 10
# 事件就往里面写入
a1.sinks.k2.hdfs.batchSize = 100000
a1.sinks.k2.hdfs.txnEventMax = 100000


# 10 分钟就创建文件
a1.sinks.k2.hdfs.round = true
a1.sinks.k2.hdfs.roundValue = 10
a1.sinks.k2.hdfs.roundUnit = minute
#默认值为0, 当目前被打开的临时文件在该参数指定的时间(秒)内,没有任何数据写入,则将该临时文件关闭并重命名成目标文件
#a1.sinks.k2.hdfs.idleTimeout=300
#默认值为HDFS副本数;写入HDFS文件块的最小副本数,该参数会影响文件的滚动配置,一般将该参数配置成1,才可以按照配置正确滚动文件;
a1.sinks.k2.hdfs.minBlockReplicas=1
#默认值5000,最大允许打开的HDFS文件数,当打开的文件数达到该值,最早打开的文件将会被关闭;
a1.sinks.k2.hdfs.maxOpenFiles=5000
#默认值:10000,执行HDFS操作的超时时间(单位:毫秒);
a1.sinks.k2.hdfs.callTimeout=100000


# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 800000000
a1.channels.c1.transactionCapacity = 500000
a1.channels.c1.keep-alive = 50

# Use a channel which buffers events in memory
a1.channels.c2.type = memory
a1.channels.c2.capacity = 800000000
a1.channels.c2.transactionCapacity = 500000
a1.channels.c2.keep-alive = 50


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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个flume的conf文件,请帮我逐行解释一下代码:“#定义三大组件的名称 a.sources = r a.sinks = k1 k2 k3 a.channels = c1 c2 c3 #将数据流复制给所有channel a.sources.r.selector.type = replicating  # 配置Source组件 a.sources.r.type = exec a.sources.r.command = cat /home/bit/novel/novel.csv # kafka a.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink a.sinks.k1.kafka.topic = data a.sinks.k1.kafka.bootstrap.servers = localhost:9092 a.sinks.k1.kafka.flumeBatchSize = 20 a.sinks.k1.kafka.producer.acks = 1 a.sinks.k1.kafka.producer.linger.ms = 1 a.sinks.k1.kafka.producer.compression.type = snappy a.channels.c1.type = memory a.channels.c1.capacity = 100000 a.channels.c1.transactionCapacity = 100 # mysql a.sinks.k2.type =com.us.flume.MysqlSink a.sinks.k2.hostname=localhost a.sinks.k2.port=3306 a.sinks.k2.databaseName=novel a.sinks.k2.tableName=table1 a.sinks.k2.user=bit a.sinks.k2.password=123456 a.channels.c2.type = memory a.channels.c2.capacity = 100000 a.channels.c2.transactionCapactiy = 2000 # hdfs a.sinks.k3.type = hdfs a.sinks.k3.hdfs.path = hdfs://localhost:9000/user/bit/novel #积攒多少个Event才flush到HDFS一次 a.sinks.k3.hdfs.batchSize = 100 #设置文件类型,可支持压缩 a.sinks.k3.hdfs.fileType = DataStream #多久生成一个新的文件 a.sinks.k3.hdfs.rollInterval = 5 a.channels.c3.type = memory a.channels.c3.capacity =100000 a.channels.c3.transactionCapacity = 100 # Bind the source and sink to the channel a.sources.r.channels = c1 c2 c3 a.sinks.k1.channel = c1 a.sinks.k2.channel = c2 a.sinks.k3.channel = c3”
05-24
这个conf文件是用来配置Apache Flume进行数据采集、传输和存储的。下面是每一行代码的解释: ``` #定义三大组件的名称 a.sources = r a.sinks = k1 k2 k3 a.channels = c1 c2 c3 ``` 这三行代码定义了三个组件的名称,分别是源(source)、汇(sink)和通道(channel),这些名称将在接下来的配置中被用到。 ``` #将数据流复制给所有channel a.sources.r.selector.type = replicating ``` 这行代码配置了源组件的复制策略,即数据流将会被复制到所有的通道中。 ``` # 配置Source组件 a.sources.r.type = exec a.sources.r.command = cat /home/bit/novel/novel.csv ``` 这两行代码配置了源组件的类型和命令。这里使用的是exec类型的源组件,它会执行一个命令,这个命令将会输出一些数据,这些数据将会被Flume采集并传输到汇组件。 ``` # kafka a.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink a.sinks.k1.kafka.topic = data a.sinks.k1.kafka.bootstrap.servers = localhost:9092 a.sinks.k1.kafka.flumeBatchSize = 20 a.sinks.k1.kafka.producer.acks = 1 a.sinks.k1.kafka.producer.linger.ms = 1 a.sinks.k1.kafka.producer.compression.type = snappy ``` 这些代码配置了一个Kafka的汇组件,它将数据发送到一个名为"data"的Kafka主题中。其中kafka.bootstrap.servers指定了Kafka的服务器地址和端口,kafka.flumeBatchSize指定了每个批次发送的事件数量,producer.acks指定了要求的确认级别,producer.linger.ms指定了等待确认的时间,producer.compression.type指定了压缩方式。 ``` a.channels.c1.type = memory a.channels.c1.capacity = 100000 a.channels.c1.transactionCapacity = 100 ``` 这些代码配置了一个类型为内存的通道,它的容量为100000个事件,事务容量为100个事件。 ``` # mysql a.sinks.k2.type =com.us.flume.MysqlSink a.sinks.k2.hostname=localhost a.sinks.k2.port=3306 a.sinks.k2.databaseName=novel a.sinks.k2.tableName=table1 a.sinks.k2.user=bit a.sinks.k2.password=123456 a.channels.c2.type = memory a.channels.c2.capacity = 100000 a.channels.c2.transactionCapactiy = 2000 ``` 这些代码配置了一个MySQL的汇组件,它将数据写入到一个名为"table1"的表中。其中hostname指定了MySQL服务器的地址,port指定了端口号,databaseName指定了数据库名称,user和password指定了登录信息。 ``` # hdfs a.sinks.k3.type = hdfs a.sinks.k3.hdfs.path = hdfs://localhost:9000/user/bit/novel a.sinks.k3.hdfs.batchSize = 100 a.sinks.k3.hdfs.fileType = DataStream a.sinks.k3.hdfs.rollInterval = 5 a.channels.c3.type = memory a.channels.c3.capacity =100000 a.channels.c3.transactionCapacity = 100 ``` 这些代码配置了一个HDFS的汇组件,它将数据写入到HDFS中的一个目录中。其中hdfs.path指定了HDFS的地址和目录,hdfs.batchSize指定了每个批次发送的事件数量,hdfs.fileType指定了文件类型,hdfs.rollInterval指定了多久生成一个新的文件。 ``` # Bind the source and sink to the channel a.sources.r.channels = c1 c2 c3 a.sinks.k1.channel = c1 a.sinks.k2.channel = c2 a.sinks.k3.channel = c3 ``` 这些代码将源组件和汇组件分别绑定到相应的通道上。也就是说,源组件从c1、c2、c3中采集数据,并将数据发送到k1、k2、k3中去。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值