-
Hey Guys, Each broker is exposing broker1:
image: confluentinc/cp-kafka
hostname: broker1
container_name: broker1
ports:
- "9092:9092"
- "9997:9997"
restart: always
environment:
KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://broker1:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
KAFKA_BROKER_ID: 1
KAFKA_NODE_ID: 1
KAFKA_JMX_PORT: 9997
KAFKA_JMX_HOSTNAME: localhost
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
volumes:
- ./logs/broker1/data:/var/lib/kafka/data
depends_on:
- zoo1
broker2:
image: confluentinc/cp-kafka
hostname: broker2
container_name: broker2
ports:
- "9093:9093"
- "9998:9997"
restart: always
environment:
KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://broker2:19093,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
KAFKA_BROKER_ID: 2
KAFKA_NODE_ID: 2
KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
KAFKA_JMX_PORT: 9997
KAFKA_JMX_HOSTNAME: localhost
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
volumes:
- ./logs/broker2/data:/var/lib/kafka/data
depends_on:
- zoo1
broker3:
image: confluentinc/cp-kafka
container_name: broker3
hostname: broker3
ports:
- "9094:9094"
- "9999:9997"
restart: always
environment:
KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://broker3:19094,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9094
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
KAFKA_BROKER_ID: 3
KAFKA_NODE_ID: 3
KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
KAFKA_JMX_PORT: 9997
KAFKA_JMX_HOSTNAME: localhost
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
volumes:
- ./logs/broker3/data:/var/lib/kafka/data
depends_on:
- zoo1
Because my Kafka ui configuration is searching for 9997, the rest two brokers are not reachable for kafka-ui kafka:
clusters:
-
name: local
bootstrapServers: broker1:19092
schemaRegistry: http://schema-registry:8081
# schemaRegistryAuth:
# username: username
# password: password
# schemaNameTemplate: "%s-value"
metrics:
port: 9997
type: JMX Error: ollection JMX metrics for service:jmx:rmi:///jndi/rmi://broker2:9997/jmxrmi |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, the solution is simple: don't expose JMX ports for each container, and specify container hostnames in k-ui's bootstrapServers. |
Beta Was this translation helpful? Give feedback.
Hi, the solution is simple: don't expose JMX ports for each container, and specify container hostnames in k-ui's bootstrapServers.