I’m getting this error on zookeeper
2024-09-06 12:46:07 [2024-09-06 15:46:07,990] ERROR cnxn.saslServer is null: cnxn object did not initialize its saslServer properly. (org.apache.zookeeper.server.ZooKeeperServer)
2024-09-06 12:46:08 [2024-09-06 15:46:08,383] WARN Unable to read additional data from client sessionid 0x100005f45720000, likely client has closed socket (org.apache.zookeeper.server.NIOServerCnxn)
2024-09-06 12:46:49 [2024-09-06 15:46:49,536] INFO Expiring session 0x100005f45720000, timeout of 40000ms exceeded (org.apache.zookeeper.server.ZooKeeperServer)
I’m getting this error on kafka
NFO SASL config status: Will attempt to SASL-authenticate using Login Context section 'Client' (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:05 [2024-09-06 15:46:05,744] WARN Session 0x0 for server zookeeper/172.18.0.2:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:05 java.net.ConnectException: Connection refused
2024-09-06 12:46:05 at java.base/sun.nio.ch.Net.pollConnect(Native Method)
2024-09-06 12:46:05 at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
2024-09-06 12:46:05 at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
2024-09-06 12:46:05 at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
2024-09-06 12:46:05 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1289)
2024-09-06 12:46:06 [2024-09-06 15:46:06,848] INFO Client will use DIGEST-MD5 as SASL mechanism. (org.apache.zookeeper.client.ZooKeeperSaslClient)
2024-09-06 12:46:06 [2024-09-06 15:46:06,848] INFO Opening socket connection to server zookeeper/172.18.0.2:2181. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:06 [2024-09-06 15:46:06,848] INFO SASL config status: Will attempt to SASL-authenticate using Login Context section 'Client' (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:06 [2024-09-06 15:46:06,849] WARN Session 0x0 for server zookeeper/172.18.0.2:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:06 java.net.ConnectException: Connection refused
2024-09-06 12:46:06 at java.base/sun.nio.ch.Net.pollConnect(Native Method)
2024-09-06 12:46:06 at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
2024-09-06 12:46:06 at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
2024-09-06 12:46:06 at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
2024-09-06 12:46:06 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1289)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO Client will use DIGEST-MD5 as SASL mechanism. (org.apache.zookeeper.client.ZooKeeperSaslClient)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO Opening socket connection to server zookeeper/172.18.0.2:2181. (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO SASL config status: Will attempt to SASL-authenticate using Login Context section 'Client' (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,957] INFO Socket connection established, initiating session, client: /172.18.0.3:51600, server: zookeeper/172.18.0.2:2181 (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,987] INFO Session establishment complete on server zookeeper/172.18.0.2:2181, session id = 0x100005f45720000, negotiated timeout = 40000 (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,991] ERROR SASL authentication failed using login context 'Client'. (org.apache.zookeeper.client.ZooKeeperSaslClient)
2024-09-06 12:46:07 javax.security.sasl.SaslException: Error in authenticating with a Zookeeper Quorum member: the quorum member's saslToken is null.
2024-09-06 12:46:07 at org.apache.zookeeper.client.ZooKeeperSaslClient.createSaslToken(ZooKeeperSaslClient.java:310)
2024-09-06 12:46:07 at org.apache.zookeeper.client.ZooKeeperSaslClient.respondToServer(ZooKeeperSaslClient.java:270)
2024-09-06 12:46:07 at org.apache.zookeeper.ClientCnxn$SendThread.readResponse(ClientCnxn.java:936)
2024-09-06 12:46:07 at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:98)
2024-09-06 12:46:07 at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
2024-09-06 12:46:07 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1289)
2024-09-06 12:46:07 [2024-09-06 15:46:07,991] INFO EventThread shut down for session: 0x100005f45720000 (org.apache.zookeeper.ClientCnxn)
2024-09-06 12:46:07 [2024-09-06 15:46:07,991] ERROR Error occurred while connecting to Zookeeper server[zookeeper:2181]. Authentication failed. (io.confluent.admin.utils.ClusterStatus)
2024-09-06 12:46:08 Using log4j config /etc/kafka/log4j.properties
Follow my code:
docker-compose.yml
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.1.4
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS: 'true'
ZOOKEEPER_SASL_ENABLED: "true"
JVMFLAGS: "-Djava.security.auth.login.config=/etc/zookeeper/zookeeper_jaas.conf"
volumes:
- ./zookeeper_jaas.conf:/etc/zookeeper/zookeeper_jaas.conf
ports:
- "2181:2181"
kafka:
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- "9092:9092"
- "9093:9093" # SASL/PLAIN port
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ZOOKEEPER_SET_ACL: true
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092, SASL_PLAINTEXT://localhost:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT, SASL_PLAINTEXT:SASL_PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
KAFKA_SASL_ENABLED_MECHANISMS: PLAIN
KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN
KAFKA_OPTS: "-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf"
volumes:
- ./kafka_server_jaas.conf:/etc/kafka/kafka_server_jaas.conf
kafka-ui:
image: provectuslabs/kafka-ui:latest
depends_on:
- kafka
ports:
- "8080:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9093
KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SASL_PLAINTEXT
KAFKA_CLUSTERS_0_PROPERTIES_SASL_MECHANISM: PLAIN
KAFKA_CLUSTERS_0_PROPERTIES_SASL_JAAS_CONFIG: "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='admin-secret';"
kafka_server_jaas.conf
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_user="user-secret";
};
Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="kafka"
password="kafka-secret";
};
Server {
org.apache.zookeeper.server.auth.DigestLoginModule required
user_kafka="kafka-secret";
};
zookeeper_jaas.conf
Server {
org.apache.zookeeper.server.auth.DigestLoginModule required
user_kafka="kafka-secret";
};
I need assistance with configuring a Docker image using docker-compose where I’m implementing SASL authentication. Specifically, I’m encountering issues during the setup process. The problem seems to be related to integrating SASL authentication correctly with the Docker containers. Can someone guide me through the steps to resolve this issue or provide insight into common pitfalls when using SASL authentication in a Docker environment?
1