flume的kafka到hdfs的配置

1.htrace-core-3.0.jar

2.commons-configuration-1.6.jar

3.hadoop-auth-2.6.0.jar

4.hadoop-common-2.6.0.jar

5.hadoop-hdfs-2.6.0.jar

6.hadoop-mapreduce-client-core-2.6.0.jar

遇到这些错误时,添加以上包就可以解决:

java.lang.NoClassDefFoundError: org/htrace/Trace

java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration

java.lang.NoClassDefFoundError: org/apache/hadoop/util/PlatformName

java.io.IOException: No FileSystem for scheme: hdfs

java.io.IOException: Incomplete HDFS URI, no host: hdfs://


flume的conf配置:

agent.sources=r1
agent.sinks=k1
agent.channels=c1


agent.sources.r1.type= org.apache.flume.source.kafka.KafkaSource
agent.sources.r1.kafka.bootstrap.servers=192.168.0.1:9092
agent.sources.r1.kafka.topics=TEST-TOPIC
#agent.sources.r1.serializer.class=kafka.serializer.StringEncoder
agent.sources.r1.kafka.consumer.group.id = flumetest
auto.commit.enable = true
agent.sources.r1.flumeBatchSize=1000
agent.sources.r1.useFlumeEventFormat=false
agent.sources.r1.restart=true
agent.sources.r1.batchSize=1000
agent.sources.r1.batchTimeout=3000
agent.sources.r1.channels=c1


agent.channels.c1.type=memory
agent.channels.c1.capacity=102400
agent.channels.c1.transactionCapacity=1000
agent.channels.c1.byteCapacity=134217728
agent.channels.c1.byteCapacityBufferPercentage=80

agent.sinks.k1.channel=c1
agent.sinks.k1.type=hdfs
agent.sinks.k1.hdfs.path=hdfs://master02:8020/tmp/flume/ds=%Y%m%d
agent.sinks.k1.hdfs.rollSize=0
agent.sinks.k1.hdfs.rollCount=0
agent.sinks.k1.hdfs.rollInterval=3600
agent.sinks.k1.hdfs.threadsPoolSize=30
agent.sinks.k1.hdfs.fileType=DataStream
agent.sinks.k1.hdfs.writeFormat=Text


## source 拦截器
agent.sources.r1.interceptors = i1
agent.sources.r1.interceptors.i1.type = org.com.flume.MyInterceptor$Builder




  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的Flume配置文件,用于从Kafka读取消息并将其写入HDFS: ``` # Name the components on this agent agent.sources = kafka-source agent.sinks = hdfs-sink agent.channels = memory-channel # Configure the Kafka source agent.sources.kafka-source.type = org.apache.flume.source.kafka.KafkaSource agent.sources.kafka-source.kafka.bootstrap.servers = localhost:9092 agent.sources.kafka-source.kafka.topics = my_topic agent.sources.kafka-source.kafka.consumer.group.id = flume # Configure the HDFS sink agent.sinks.hdfs-sink.type = hdfs agent.sinks.hdfs-sink.hdfs.path = /path/to/hdfs/directory/ agent.sinks.hdfs-sink.hdfs.fileType = DataStream agent.sinks.hdfs-sink.hdfs.writeFormat = Text # Use a memory channel to buffer events agent.channels.memory-channel.type = memory # Bind the source and sink to the channel agent.sources.kafka-source.channels = memory-channel agent.sinks.hdfs-sink.channel = memory-channel ``` 在上面的配置文件中,我们指定了Kafka source的类型为 `org.apache.flume.source.kafka.KafkaSource`。我们还指定了Kafka broker的地址、要消费的Kafka topic以及消费者组的ID。 我们将HDFS sink的类型指定为 `hdfs`,并指定要写入的HDFS目录的路径、文件类型和写入格式。 最后,我们使用内存通道来缓冲事件,并将Kafka source和HDFS sink绑定到通道上。 您可以使用以下命令来启动Flume代理: ``` $ bin/flume-ng agent -n agent -c conf -f /path/to/flume-conf.properties ``` 这里,`/path/to/flume-conf.properties`是您的Flume配置文件的路径。请确保Kafka和Hadoop集群在运行并可访问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值