为什么 Debezium Connector 无法连接到 SASL 激活的代理?

问题描述 投票:0回答:1

我正在尝试为我的 Kafka 系统启用 SASL/PLAIN。它实际上有效,我已经针对架构注册表和 Java 生产者测试了它。问题是 Kafka Connect 在启用 SASL 时无法建立连接(至少我首先是这么想的)。我给出了必要的配置,但看起来根本没有影响。我已将

connect-avro-distributed.properties
文件编辑为:

sasl.mechanism=PLAIN
security.protocol=SASL_PLAINTEXT
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
  username="admin" \
  password="secret";

producer.sasl.mechanism=PLAIN
producer.security.protocol=SASL_PLAINTEXT
producer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
  username="admin" \
  password="secret";

consumer.sasl.mechanism=PLAIN
consumer.security.protocol=SASL_PLAINTEXT
consumer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
  username="admin" \
  password="secret";

但是日志中写着:

[2022-01-07 12:21:28,645] INFO ProducerConfig values:
        sasl.mechanism = GSSAPI
        security.protocol = PLAINTEXT

应该是这样的:

[2022-01-07 12:21:28,645] INFO ProducerConfig values:
        sasl.mechanism = PLAIN
        security.protocol = SASL_PLAINTEXT

消费者配置相同。我需要做什么?为什么它使用默认值?我已经重启服务很多次了。预先感谢。

编辑:还有另一个连接器运行没有任何问题,并且它具有正确的 SASL 配置。

Edit2:看起来 Debezium 连接器需要在连接器端进行更多配置。

apache-kafka apache-kafka-connect sasl
1个回答
5
投票

使用不同的连接器进行尝试可以清楚地表明存在 Debezium 特定问题。由于 Debezium 使用历史主题,因此在启用安全性时需要一些额外的配置。

"database.history.consumer.security.protocol": "SASL_PLAINTEXT",
"database.history.consumer.sasl.mechanism": "PLAIN",
"database.history.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"secret\";",
"database.history.producer.security.protocol": "SASL_PLAINTEXT",
"database.history.producer.sasl.mechanism": "PLAIN",
"database.history.producer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"secret\";"

您需要覆盖 Debezium 连接器的生产者和消费者配置的默认值。如果您使用 SSL,则需要添加几行。欲了解更多信息:https://docs.confluence.io/debezium-connect-sqlserver-source/current/sqlserver_source_connector_config.html

编辑:对于较新版本的 debezium 源连接器,应该是这样的:

"schema.history.internal.consumer.security.protocol": "SASL_PLAINTEXT",
"schema.history.internal.consumer.sasl.mechanism": "PLAIN",
"schema.history.internal.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"secret\";",
"schema.history.internal.producer.security.protocol": "SASL_PLAINTEXT",
"schema.history.internal.producer.sasl.mechanism": "PLAIN",
"schema.history.internal.producer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"secret\";"
© www.soinside.com 2019 - 2024. All rights reserved.