Search code examples
command-line-interfaceapache-kafkaapache-zookeepermesospheredcos

Kafka CLI in DC/OS Mesosphere


I have very recently started playing around with DC/OS Mesosphere. I installed Kafka as a service on my cluster. I had a very simple question:

To list topics, can I still use this command: kafka-topics --zookeeper zookeeper-host:2181 --list or would I have to use the dcos command: dcos kafka --name=kafka topic list

Thanks!


Solution

  • You'd be able to run kafka-topics directly if you like, but you'd want to provide a zookeeper path which matches the name of the Kafka service instance (default kafka).

    You can get this path by running dcos kafka --name=kafka connection and looking at the zookeeper entry in the returned data:

    $ dcos kafka --name=kafka connection
    {
      "address": [
        "10.0.0.58:9603",
        "10.0.0.56:9805",
        "10.0.0.55:9556"
      ],
      "zookeeper": "master.mesos:2181/dcos-service-kafka",
      "dns": [
        "broker-0.kafka.mesos:9603",
        "broker-1.kafka.mesos:9805",
        "broker-2.kafka.mesos:9556"
      ],
      "vip": "broker.kafka.l4lb.thisdcos.directory:9092"
    }
    

    In this example the --zookeeper value passed to kafka-topics should be master.mesos:2181/dcos-service-kafka. This assumes that the master.mesos host is reachable from wherever you're running the kafka-topics command.