By default, Kafka does not allow remote JMX connections over RMI. To enable them, you need to:
-
Define the connection when running Kafka broker.
Windows example:
set JMX_PORT=9999 bin/kafka-server-start.bat config/server-1.properties set JMX_PORT=10000 bin/kafka-server-start.bat config/server-2.properties
- Define the connection within the run script
kafka-server-start.sh
.
Unix/Linux example:
Add following options in the startup script for each Kafka server:
export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote=true - Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=KAFKA-SERVER1" export JMX_PORT=9999 export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote=true - Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=KAFKA-SERVER2" export JMX_PORT=9999
As per the Confluent article below, each component uses its own variable - https://docs.confluent.io/platform/current/kafka/monitoring.html
Confluent Control Center | CONTROL_CENTER_JMX_OPTS |
REST Proxy | KAFKAREST_JMX_OPTS |
ksqlDB | KSQL_JMX_OPTS |
Rebalancer | REBALANCER_JMX_OPTS |
Schema Registry | SCHEMA_REGISTRY_JMX_OPTS |