Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-14164

Enabling JMX on one Service Breaks kafka-run-class Shell Script for All

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.2.1
    • None
    • packaging
    • None

    Description

      Step 1: On a server running kafka using the kafka-server-start script and KAFKA_JMX_OPTS populated to turn on JMX.  Kafka broker starts with a jmx listener.

      Step 2: Use another script like bin/kafka-topics, the shell script always fails because the call to kafka-run-class always triggers starting a jmx listener on the same port in the environment variables.

      Expected behavior: Be able to use a script like kafka-topics without error on a host that already has JMX environment variables and a process listening on the defined port.

      Actual behavior: bin/kafka-topics errors out trying to start another jmx listener on the same port in KAFKA_JMX_OPTS.

      When kafka-topics shell script pass arguments to kafka-run-class, kafka-run-class tries and fails to initialize a jmx listener because, in this example, the kafka-server-start already started one and $JMX_OPTS is always defined/used at the end of kafka-run-class.sh

      A proposed solution is editing the kafka-run-class file.

      1. add a variable declaration NO_JMX="true"
      2. Add the following to the case statement in kafka-run-class.sh kafka.Kafka|org.apache.kafka.connect.cli.ConnectDistributed)
        NO_JMX="false"
        shift;;
      3. Add an elif at the end of kafka-run-class.sh 

      elif [ "$NO_JMX" = "true" ] ; then
      exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_LOG4J_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@"

      The workaround is every time you run a script like kafka-topics.sh or kafka-configs.sh, run it like this JMX_PORT='' KAFKA_JMX_OPTS='' bin/kafka-topics ....

      Attachments

        Activity

          People

            Unassigned Unassigned
            prime_minister_funhavistan Prime Minister of Funhavistan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: