@@ -175,18 +175,39 @@ services:
175175 volumes :
176176 - " ${DATA_DIR}/components/kafka:/bitnami/kafka"
177177 environment :
178+ # KAFKA_HEAP_OPTS: "-Xms128m -Xmx256m"
178179 TZ : Asia/Shanghai
180+ # Unique identifier for the Kafka node (required in controller mode)
179181 KAFKA_CFG_NODE_ID : 0
182+ # Defines the roles this Kafka node plays: broker, controller, or both
180183 KAFKA_CFG_PROCESS_ROLES : controller,broker
184+ # Specifies which nodes are controller nodes for quorum voting.
185+ # The syntax follows the KRaft mode (no ZooKeeper): node.id@host:port
186+ # The controller listener endpoint here is kafka:9093
181187 KAFKA_CFG_CONTROLLER_QUORUM_VOTERS : 0@kafka:9093
188+ # Specifies which listener is used for controller-to-controller communication
182189 KAFKA_CFG_CONTROLLER_LISTENER_NAMES : CONTROLLER
190+ # Default number of partitions for new topics
183191 KAFKA_NUM_PARTITIONS : 8
192+ # Whether to enable automatic topic creation
184193 KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE : " true"
185-
186- KAFKA_CFG_LISTENERS : " PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
187- KAFKA_CFG_ADVERTISED_LISTENERS : " PLAINTEXT://kafka:9092,EXTERNAL://kafka:9094"
188- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP : " CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT"
189- KAFKA_CFG_INTER_BROKER_LISTENER_NAME : " PLAINTEXT"
194+ # Kafka internal listeners; Kafka supports multiple ports with different protocols
195+ # Each port is used for a specific purpose: INTERNAL for internal broker communication,
196+ # CONTROLLER for controller communication, EXTERNAL for external client connections.
197+ # These logical listener names are mapped to actual protocols via KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
198+ # In short, Kafka is listening on three logical ports: 9092 for internal communication,
199+ # 9093 for controller traffic, and 9094 for external access.
200+ KAFKA_CFG_LISTENERS : " INTERNAL://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
201+ # Addresses advertised to clients. INTERNAL://kafka:9092 uses the internal Docker service name 'kafka',
202+ # so other containers can access Kafka via kafka:9092.
203+ # EXTERNAL://localhost:19094 is the address external clients (e.g., in the LAN) should use to connect.
204+ # If Kafka is deployed on a different machine than IM, 'localhost'(or 'kafka') should be replaced with the LAN IP.
205+ KAFKA_CFG_ADVERTISED_LISTENERS : " INTERNAL://kafka:9092,EXTERNAL://kafka:9094"
206+ # Maps logical listener names to actual protocols.
207+ # Supported protocols include: PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL
208+ KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP : " CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT"
209+ # Defines which listener is used for inter-broker communication within the Kafka cluster
210+ KAFKA_CFG_INTER_BROKER_LISTENER_NAME : " INTERNAL"
190211
191212 # Authentication configuration variables - comment out to disable auth
192213 # KAFKA_USERNAME: "openIM"
@@ -199,7 +220,7 @@ services:
199220
200221 # Set environment variables for SASL authentication
201222 export KAFKA_CFG_LISTENERS="SASL_PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
202- export KAFKA_CFG_ADVERTISED_LISTENERS="SASL_PLAINTEXT://kafka:9092,EXTERNAL://localhost:19094 "
223+ export KAFKA_CFG_ADVERTISED_LISTENERS="SASL_PLAINTEXT://kafka:9092,EXTERNAL://kafka:9094 "
203224 export KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP="CONTROLLER:PLAINTEXT,EXTERNAL:SASL_PLAINTEXT,SASL_PLAINTEXT:SASL_PLAINTEXT"
204225 export KAFKA_CFG_SASL_ENABLED_MECHANISMS="PLAIN"
205226 export KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL="PLAIN"
0 commit comments