为什么我可以读取ksqldb流而不是ksql客户机中的主题?

uqxowvwt  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(293)

我正在最新版本(confluent 5.5.1)的aws ec2示例上测试ksqldb,有一个访问问题我无法解决。
我有一个安全的kafka服务器(sasl\u sssl,sasl mode plain),一个不安全的模式注册表(avro序列化程序的另一个问题,但目前还可以),以及一个安全的ksql服务器和客户端。
主题正确地填充了来自jdbc源连接器的avro数据(仅值,无键)。
我可以使用ksql访问ksql服务器而不会出现问题
我可以毫无问题地访问ksql rest api
当我在ksql中列出主题时,我得到了正确的列表。
当我选择一个推送流时,当我将某个内容推送到主题中时,就会收到消息(在我的例子中,使用kafka connect)。
但是:当我调用“print topic”时,我在客户机中得到一个~60秒的块,然后是“获取主题元数据时超时过期”。
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)

相应的代理日志显示

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\ u 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 config,在服务启动时作为参数包含

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'

我可能试过任何按键、设置等的排列,但都没有用。很明显,关键管理有问题。对我来说,令人惊讶的是,使用流是可以的,但低层次的主题不是。
有人找到解决这个问题的办法了吗?我真的有很多想法。谢谢。

inn6fuwd

inn6fuwd1#

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

security.protocol=SASL_SSL

相关问题