ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【Kafka】Kafka生产者开启幂等性后报错:Cluster authorization failed. [打印本页]

作者: 卖不甜枣    时间: 2024-11-19 18:33
标题: 【Kafka】Kafka生产者开启幂等性后报错:Cluster authorization failed.
背景

办理

服务端设置

检察Kafka源码,发现生产者这个设置(enable.idempotence)有一个说明:
   When set to 'true', the producer will ensure that exactly one copy of each message is written in the stream. If 'false', producer retries due to broker failures, etc., may write duplicates of the retried message in the stream. Note that enabling idempotence requires <code>max.in.flight.requests.per.connection</code> to be less than or equal to 5, <code>retries</code> to be greater than 0 and <code>acks</code> must be 'all'. If these values are not explicitly set by the user, suitable values will be chosen. If incompatible values are set, a <code>ConfigException</code> will be thrown.
  检察Kafka官网,对改设置也有雷同的说明:

总结一下,服务端要支持生产幂等性的话,需要保证以下几个设置:

以下是为什么需要这么设置的缘故原由:
这些设置的组合可以确保在各种故障情况下,消息的顺序、可靠性和一致性都能得到保证。
ACL增长授权

因为集群开启了ACL认证,所以还需要开启幂等写的权限,执行以下命令进行开启:
  1. ./kafka-acls.sh --bootstrap-server kafka-m2wi5kig-headless.kafka-pro.svc.xadd.staff.xdf.cn:29092 --command-config m2wi5kig.properties --add --allow-principal
  2. User:kafka-m2wi5kig.plain1 --topic 'cdata_flink_kafka_test' --producer --idempotent
复制代码
–command-config 需要指定该集群的admin账号及密码,格式如下:
  1. security.protocol = SASL_PLAINTEXT
  2. sasl.mechanism = SCRAM-SHA-512
  3. sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="xxxx" password="xxxx";
复制代码
执行完之后,可以看到权限中已经包罗IDEMPOTENT_WRITE了:

用户重试了,不在报错,标题办理。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4