修改kafka的partition分区 bin/kafka-topics.sh --zookeeper datacollect-2:2181 --alter --partitions 3 --topic client-agent-1 修改kafka副本数 官网解释如下: Increasing replication factor Increasing the replication factor of an existing partition is easy. Just specify the
消息在经过拦截器.序列化后,就需要确定它发往哪个分区,如果在ProducerRecord中指定了partition字段,那么就不再需要partitioner分区器进行分区了,如果没有指定,那么会根据key来将数据进行分区,如果partitioner和key都没有指定,那么就会采用默认的方式进行数据分区. 有没有指定partition可以从源码中看出: public ProducerRecord(String topic, Integer partition, K key, V value) {}
1 问题背景 Flume向kafka发布数据时,发现kafka接收到的数据总是在一个partition中,而我们希望发布来的数据在所有的partition平均分布 2 解决办法 Flume的官方文档是这么说的: Kafka Sink uses the topic and key properties from the FlumeEvent headers to send events to Kafka. If topic exists in the headers, the event wil