配置ssl acl时,kafka使用者无法连接到服务器:{test topic=leader\u not\u available}

kzmpq1sx  于 2021-06-07  发布在  Kafka
关注(0)|答案(0)|浏览(283)

我有一个kafka clustor,在没有启用ssl的情况下可以正常工作,在启用ssl的情况下也可以正常工作。但配置acl时,它不起作用。
客户端使用者无法连接到服务器,报告了以下故障:

[2018-12-21 15:07:38,930] WARN [Consumer clientId=consumer-1, groupId=console-consumer-86611]
Error while fetching metadata with correlation id 1 :
{test-topic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

萨拉玛日志上写着:

[sarama] 2018/12/22 09:15:21 client/metadata fetching metadata for [test-topic] from broker kafka1.oneorg.example.com:9093
[sarama] 2018/12/22 09:15:21 client/metadata found some partitions to be leaderless

但事实并非如此,如果我们使用“kafka-topics.sh--describe”命令,确实有一个leader节点。
我的Kafka版本是:Kafka2.11-1.0.0.jar
当我们回顾kafka服务器时,主题测试主题就存在于此:

/opt/kafka/bin/kafka-topics.sh --describe \
--zookeeper zookeeper1.example.com:2181 \
--topic test-topic
Topic:test-topic    PartitionCount:1    ReplicationFactor:3 Configs:
    Topic: test-topic   Partition: 0    Leader: 3   Replicas: 4,2,3 Isr: 3

而且,当没有配置acl时,它可以正常工作。我为acl采取了以下操作:1。为服务器端启用acl

- KAFKA_AUTHORIZER_CLASS_NAME=kafka.security.auth.SimpleAclAuthorizer
    - KAFKA_SUPER_USERS=User:Bob;User:Alice

2添加acl配置项

/opt/kafka/bin/kafka-acls.sh \
--authorizer-properties zookeeper.connect=zookeeper1.example.com:2181 \
--add \
--allow-principal User:"C=cn,O=mycomp,OU=myorg,CN=client" \
--operation All \
--topic "test-topic" \
--group "*" \
--cluster

命令成功了

/opt/kafka/bin/kafka-acls.sh \
--authorizer-properties zookeeper.connect=zookeeper1.oneorg.example.com:2181 \
--list --topic test-topic
Current ACLs for resource `Topic:test-topic`: 
User:C=cn,O=mycomp,OU=myorg,CN=client has Allow permission for operations: All from hosts: *

三。启动消费者客户端

/opt/kafka/bin/kafka-console-consumer.sh
--bootstrap-server kafka1.example.com:9093
--topic test-topic --partition 0
--consumer.config kafka-client-ssl.properties

kafka-client-ssl.properties内容:

ootstrap.servers=kafka1.example.com:9093
security.protocol=SSL
ssl.truststore.location=/work/truststore.jks
ssl.truststore.password=test1234
ssl.keystore.location=/work/client.keystore.jks
ssl.keystore.password=test1234
ssl.key.password=test1234

我不知道我是否错过了什么,有什么出口可以帮我吗?谢谢。
$/opt/kafka/bin/kafka-topics.sh—描述—zookeeper zookeeper1.oneorg.example。com:2181 --topic 测试主题
topic:test-topic partitioncount:1个副本ionfactor:1 configs:topic:测试主题分区:0引线:1副本:1 isr:1

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题