为什么我可以读取 ksqldb 流但不能读取 ksql 客户端中的主题?

Why can I read ksqldb streams but not topics within ksql client?

我正在最新版本(confluent 5.5.1)中的 AWS EC2 实例上测试 ksqldb,但有一个我无法解决的访问问题。

我有一个安全的 Kafka 服务器(SASL_SSSL,SASL 模式 PLAIN),一个不安全的 Schema Registry(Avro 序列化程序的另一个问题,但目前没问题),以及一个安全的 KSQL 服务器和客户端。

ksql-kafka.log 因

等重复条目而疯狂
[2020-09-02 18:52:46,246] WARN [Consumer clientId=consumer-2, groupId=null] Bootstrap broker ip-10-1-2-10.eu-central-1.compute.internal:9093 (id: -3 rack: null) disconnected (org.apache.kafka.clients.NetworkClient:1037)

对应broker日志显示

Sep  2 18:52:44 ip-10-1-6-11 kafka-server-start: [2020-09-02 18:52:44,704] INFO [SocketServer brokerId=1002] Failed authentication with ip-10-1-2-231.eu-central-1.compute.internal/10.1.2.231 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)

这是我的 ksql-server.properties 文件:

ksql.service.id= hf_kafka_ksql_001
bootstrap.servers=ip-10-1-11-229.eu-central-1.compute.internal:9093,ip-10-1-6-11.eu-central-1.compute.internal:9093,ip-10-1-2-10.eu-central-1.compute.internal:9093
ksql.streams.state.dir=/var/data/ksqldb
ksql.schema.registry.url=http://ip-10-1-1-22.eu-central-1.compute.internal:8081
ksql.output.topic.name.prefix=ksql-interactive-
ksql.internal.topic.replicas=3
confluent.support.metrics.enable=false

# currently the keystore contains only the ksql server and the certificate chain to the CA
ssl.keystore.location=/var/kafka-ssl/ksql.keystore.jks
ssl.keystore.password=kspassword
ssl.key.password=kspassword
ssl.client.auth=true
# Need to set this to empty, otherwise the REST API is not accessible with the client key.
ssl.endpoint.identification.algorithm=

# currently the truststore contains only the CA certificate
ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
ssl.truststore.password=ctpassword

security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
    username="ksql" \
    password="ksqlsecret";
listeners=https://0.0.0.0:8088
advertised.listener=https://ip-10-1-2-231.eu-central-1.compute.internal:8088

authentication.method=BASIC
authentication.roles=admin,ksql,cli
authentication.realm=KsqlServerProps

# authentication for producers, needed for ksql commands like "Create Stream"
producer.ssl.endpoint.identification.algorithm=HTTPS
producer.security.protocol=SASL_SSL
producer.sasl.mechanism=PLAIN
producer.ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
producer.ssl.truststore.password=ctpassword
producer.sasl.mechanism=PLAIN
producer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
    username="ksql" \
    password="ksqlsecret";

# authentication for consumers, needed for ksql commands like "Create Stream"
consumer.ssl.endpoint.identification.algorithm=HTTPS
consumer.security.protocol=SASL_SSL
consumer.ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
consumer.ssl.truststore.password=ctpassword
consumer.sasl.mechanism=PLAIN
consumer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
    username="ksql" \
    password="ksqlsecret";

我用

调用ksql
ksql --user cli --password test --config-file /var/kafka-ssl/ksql_cli.properties https://ip-10-1-2-231.eu-central-1.compute.internal:8088'

这是我的ksql客户端配置ksql_cli.properties:

security.protocol=SSL
#ssl.client.auth=true
ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
ssl.truststore.password=ctpassword
ssl.keystore.location=/var/kafka-ssl/ksql.keystore.jks
ssl.keystore.password=kspassword
ssl.key.password=kspassword

JAAS 配置,作为服务启动时的参数包含在内

KsqlServerProps {
  org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required
  file="/var/kafka-ssl/cli.password"
  debug="false";
};

其中 cli.password 包含 ksql 客户端的身份验证用户和密码。

我用

调用ksql
ksql --user cli --password test --config-file /var/kafka-ssl/ksql_cli.properties https://ip-10-1-2-231.eu-central-1.compute.internal:8088'

我可能已经尝试过对键、设置等进行任何排列,但都无济于事。显然,密钥管理存在问题。对我来说,令人惊讶的是,usings streams 可以,但低级别的主题却不行。

有人找到解决该问题的方法了吗?我真的 运行 ou 的想法在这里。谢谢。

找到了!这很容易被忽视——当然是客户的配置需求。 SASL 设置...

security.protocol=SASL_SSL