Kafka制作人无法发送消息

bsxbgnwa  于 2021-06-08  发布在  Kafka
关注(0)|答案(3)|浏览(393)

我对Kafka很陌生。
使用Kafka0.11
活动代理的数目“1”不符合偏移量主题所需的复制因子“3”(通过“offsets.topic.replication.factor”配置)
我在发送主题消息时遇到上述错误

kafka-topics --zookeeper localhost:2181 --topic test --describe
Topic:test1 PartitionCount:1    ReplicationFactor:1 Configs:
Topic: test1    Partition: 0    Leader: 0   Replicas: 0 Isr: 0
cbeh67ev

cbeh67ev1#

这意味着您的群集将默认复制因子设置为某些数字,若要覆盖此设置,您需要编辑server.properties并使用您的选择值添加复制因子参数

offsets.topic.replication.factor=1

在我的例子中,我想用单节点zookeeper运行单节点kafka,在这种情况下,您需要用复制因子1创建主题,否则会出现错误

mansoor@c2dkb05-usea1d:~$ ./bin/kafka-topics.sh --create --zookeeper zookeeper-svc:2181 --replication-factor 2 --partitions 2 --topic mqttDeviceEvents

Error while executing topic command : Replication factor: 2 larger than available brokers: 1.
[2020-06-18 14:39:46,533] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 2 larger than available brokers: 1.

创建主题的正确方法是使用单节点kafka

mansoor@c2dkb05-usea1d:$ ./bin/kafka-topics.sh --create --zookeeper zookeeper-svc:2181 --replication-factor 1 --partitions 2 --topic mqttDeviceEvents
Created topic mqttDeviceEvents.
ahy6op9u

ahy6op9u2#

你怎么开始做经纪人的?server.properties文件是什么。随下载包一起提供的程序应具有以下行:

offsets.topic.replication.factor=1

只是想澄清一下,您看到的错误与您要发布的主题无关。如今,Kafka不再在zookeeper中为消费者保存主题偏移量,而是在名为\uu consumer\u offset的“内部主题”中保存。当然,如果您有一个代理,那么复制因子就不能是3。所以我想看看你的server.properties。如果缺少上述属性,则默认值为3。

kadbb459

kadbb4593#

就我而言,我的错误也是类似的。 ERROR [KafkaApi-2] Number of alive brokers '0' does not meet the required replication factor '1' for the offsets topic (configured via 'offsets.topic.replication.factor'). This error can be ignored if the cluster is starting up and not all brokers are up yet. (kafka.server.KafkaApis) 集群: 2 Brokers (ID=1,ID=2)hostname-1 以及 hostname-2 Kafka版本:
1.0.1 listeners=PLAINTEXT://:9090,SSL://:9091,PLAINTEXT_EXT://:9092,SSL_EXT://:9093,SASL_SSL://:9094,SASL_PLAINTEXT://:9095 而且都是经纪人 server.properties 设置为 offsets.topic.replication.factor=1 但我将播发的主机名配置为 hostname-1 在这两种代理协议中,用于代理间通信的代理协议(以及 ID=2 继续给出上述错误。 advertised.listeners=PLAINTEXT://hostname-2:9090,SSL://hostname-2:9091,PLAINTEXT_EXT://<EXTERNAL_IP>:9092,SSL_EXT://<EXTERNAL_IP>:9093,SASL_SSL://hostname-1:9094,SASL_PLAINTEXT://hostname-1:9095 修正 SASL_SSL 以及 SASL_PLAINTEXT 已修复此错误。
附言: SASL_PLAINTEXTsecurity.inter.broker.protocol 在这个集群中。这个错误似乎也与端口可用性有关。

相关问题