我试图设置Kafka Connect,目的是运行ElasticsearchSinkConnector
Kafka设置,由3个使用Kerberos、SSL和ACL进行安全保护的代理组成
到目前为止,我一直在尝试使用docker/docker compose(Confluent docker image 5.4 with Kafka 2.4(在本地运行连接框架和弹性服务器,连接到远程Kafka安装(Kafka 2.0.1-实际上是我们的生产环境(
KAFKA_OPTS: -Djava.security.krb5.conf=/etc/kafka-connect/secrets/krb5.conf
CONNECT_BOOTSTRAP_SERVERS: srv-kafka-1.XXX.com:9093,srv-kafka-2.XXX.com:9093,srv-kafka-3.XXX.com:9093
CONNECT_REST_ADVERTISED_HOST_NAME: kafka-connect
CONNECT_REST_PORT: 8083
CONNECT_GROUP_ID: user-grp
CONNECT_CONFIG_STORAGE_TOPIC: test.internal.connect.configs
CONNECT_OFFSET_STORAGE_TOPIC: test.internal.connect.offsets
CONNECT_STATUS_STORAGE_TOPIC: test.internal.connect.status
CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
CONNECT_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_INTERNAL_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_INTERNAL_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
CONNECT_ZOOKEEPER_CONNECT: srv-kafka-1.XXX.com:2181,srv-kafka-2.XXX.com:2181,srv-kafka-3.XXX.com:2181
CONNECT_SECURITY_PROTOCOL: SASL_SSL
CONNECT_SASL_KERBEROS_SERVICE_NAME: "kafka"
CONNECT_SASL_JAAS_CONFIG: com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
storeKey=true
keyTab="/etc/kafka-connect/secrets/kafka-connect.keytab"
principal="<principal>;
CONNECT_SASL_MECHANISM: GSSAPI
CONNECT_SSL_TRUSTSTORE_LOCATION: <path_to_truststore.jks>
CONNECT_SSL_TRUSTSTORE_PASSWORD: <PWD>
当启动连接框架时,一切似乎都很好,我可以看到日志声称kerberos身份验证成功等。
问题出现在我尝试使用curl启动连接作业时
curl -X POST -H "Content-Type: application/json" --data '{ "name": "kafka-connect", "config": { "connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector", "tasks.max": 1, "topics": "test.output.outage", "key.ignore": true, "connection.url": "http://elasticsearch1:9200", "type.name": "kafka-connect" } }' http://localhost:8083/connectors
这项工作似乎启动时没有问题,但当它即将开始消耗卡夫卡主题时,我得到了:
kafka-connect | [2020-04-06 10:35:33,482] WARN [Consumer clientId=connector-consumer-user-grp-2-0, groupId=connect-user-2] Bootstrap broker srv-kafka-1.XXX.com:9093 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
在所有代理的连接日志中重复
这个问题的性质是什么?与经纪人的沟通似乎很好——连接作业按预期传达回卡夫卡,当连接框架重新启动时,作业似乎按预期恢复(尽管仍然有故障(
有人知道是什么原因造成的吗?或者我应该如何调试它。
由于这是我们的生产环境,我更改服务器配置的可能性有限。但据我所知,日志中似乎没有任何内容表明出了问题
提前感谢
根据文档,您还需要为运行Kafka Connect的连接器在使用者/生产者上配置安全性。您可以通过添加consumer
/producer
前缀来完成此操作。因此,由于您正在使用Docker,并且错误表明您正在创建一个接收器连接器(即需要一个消费者(,请在您的配置中添加:
CONNECT_CONSUMER_SECURITY_PROTOCOL: SASL_SSL
CONNECT_CONSUMER_SASL_KERBEROS_SERVICE_NAME: "kafka"
CONNECT_CONSUMER_SASL_JAAS_CONFIG: com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
storeKey=true
keyTab="/etc/kafka-connect/secrets/kafka-connect.keytab"
principal="<principal>;
CONNECT_CONSUMER_SASL_MECHANISM: GSSAPI
CONNECT_CONSUMER_SSL_TRUSTSTORE_LOCATION: <path_to_truststore.jks>
CONNECT_CONSUMER_SSL_TRUSTSTORE_PASSWORD: <PWD>
如果你也在创建一个源连接器,你需要复制上面的内容,但对于PRODUCER_
也是