内容简介:将 kafka 中的数据转存到 HDFS 中, 用作离线计算, flume 已经帮我们实现了, 添加配置文件, 直接启动 flume-ng 即可.
将 kafka 中的数据转存到 HDFS 中, 用作离线计算, flume 已经帮我们实现了, 添加配置文件, 直接启动 flume-ng 即可.
The Kafka channel can be used for multiple scenarios:
- With Flume source and sink - it provides a reliable and highly available channel for events
- With Flume source and interceptor but no sink - it allows writing Flume events into a Kafka topic, for use by other apps
- With Flume sink, but no source - it is a low-latency, fault tolerant way to send events from Kafka to Flume sinks such as HDFS, HBase or Solr
- $FLUME_HOME/conf/kafka-hdfs.conf
# kafka Channel + HDFS sink(without sources) a1.channels = c1 a1.sinks = k1 # 定义 KafkaChannel a1.channels.c1.type = org.apache.flume.channel.kafka.KafkaChannel a1.channels.c1.parseAsFlumeEvent = false a1.channels.c1.kafka.bootstrap.servers = kafka-1:9092,kafka-2:9092,kafka-3:9092 a1.channels.c1.kafka.topic = user a1.channels.c1.kafka.consumer.group.id = g1 # 定义 HDFS sink a1.sinks.k1.channel = c1 a1.sinks.k1.type = hdfs a1.sinks.k1.hdfs.path = hdfs://hadoop-1:9000/flume/%Y%m%d/%H a1.sinks.k1.hdfs.useLocalTimeStamp = true a1.sinks.k1.hdfs.filePrefix = log a1.sinks.k1.hdfs.fileType = DataStream # 不按照条数生成文件 a1.sinks.k1.hdfs.rollCount = 0 # HDFS 上的文件达到128M 生成一个文件 a1.sinks.k1.hdfs.rollSize = 134217728 # HDFS 上的文件达到10分钟生成一个文件 a1.sinks.k1.hdfs.rollInterval = 600 复制代码
记得配 hosts
- 添加 HDFS 相关jar包和配置文件
commons-configuration-1.6.jar commons-io-2.4.jar hadoop-auth-2.8.3.jar hadoop-common-2.8.3.jar hadoop-hdfs-2.8.3.jar hadoop-hdfs-client-2.8.3.jar htrace-core4-4.0.1-incubating.jar core-site.xml hdfs-site.xml 复制代码
-
flume-1.8 kafka客户端默认版本0.9 但是向上兼容(别用这个 有巨坑 ~_~#)
kafka-clients-2.0.0.jar kafka_2.11-2.0.0.jar -
先启动 zookeeper kafka 和 HDFS(否则会各种报错,)
-
进入
$FLUME_HOME启动 flumeroot@common:/usr/local/flume# ./bin/flume-ng agent -c conf/ -f conf/kafka-hdfs.conf -n a1 -Dflume.root.logger=INFO,console
以上所述就是小编给大家介绍的《Flume将 kafka 中的数据转存到 HDFS 中》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 使用Spark进行数据统计并将结果转存至MSSQL
- 使用 Qemu 虚拟 ARM64 平台演示 kdump 崩溃转存
- 4 万字全面掌握数据库、数据仓库、数据集市、数据湖、数据中台
- 数据映射如何支持数据转换和数据集成?
- 大数据产品经理必备的数据挖掘知识概述(一)认识数据之数据可视化
- 避免“数据湖”成为“数据沼泽”,流动的“数据河”是关键
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Sovereign Individual
James Dale Davidson、William Rees-Mogg / Free Press / 1999-08-26 / USD 16.00
Two renowned investment advisors and authors of the bestseller The Great Reckoning bring to light both currents of disaster and the potential for prosperity and renewal in the face of radical changes ......一起来看看 《The Sovereign Individual》 这本书的介绍吧!