From the course: Complete Guide to Apache Kafka for Beginners

CLI introduction

Hi, this is Stephane from Conduktor and welcome to this section on the Kafka CLI. So we are going to use the Kafka CLI to practice in this section. And as we saw, the CLI comes bundled with the Kafka binaries. And so if you have set up the path variable correctly from the Kafka setup, as I showed you, then you should be able to invoke the CCLI commands anywhere on your computer. Okay. So you can do something like Kafka topics, and then it will reply with the command results. So if you have using, if you have installed Kafka using the binaries, then your command should be ending in .sh, for example, Kafka topics.sh. So this is if you're using Linux or Mac or if you have downloaded the Kafka binaries on Windows WSL2, then it's Kafka topics .bat for Windows non-WSL2 and then Kafka topics without anything with Homebrew and APT or something like this. So if you follow the last video, you already know if you should use .sh, .bat or nothing and I will be using one way. Of course you have to adapt the commands based on your operating system. Now also we're going to use the bootstrap server option everywhere, not the minus minus zookeeper option because Zookeeper is going away and all the commands starting at Kafka three are updated to use Kafka. So that means that the Kafka topics command should be using the bootstrap server localhost 9092, for example, instead of using the zookeeper option, even though the zookeeper may still be available to you. Okay. So in case you're having errors with the CLI, okay, that means that maybe the path wasn't set up correctly. And if you still don't manage to set the path correctly, then what I suggest is for you to use this full path to the Kafka binaries. So you invoke the Kafka topics directly from the full path to it, and then the command should work. So let me show you in an instance. Okay. So I am in my root directory, as you can see. And what I can do is that I can do, for example, Kafka topics and then press "Enter". And this is because I set up Kafka using brew and therefore my command is working. Okay. Maybe on your system is going to be Kafka topics.sh. For me doesn't work because obviously it's not registered as is. And for Windows is going to be maybe Windows without WSL2 is going to be Kafka topics.bat of course doesn't work on my Mac. Okay. So if you do type Kafka topics.sh and you expect to be right, for example, and you get a command not found, then don't stress, okay? Find your Kafka directory. So it's Kafka 213 310, for example, then bin, and then in the bin directory you're going to get the full path to your executable. So Kafka topic.sh. And then if you press "Enter", then this command is going to work and you're good to go. Okay. So if you did not set up the path correctly, you try to go back maybe to the previous videos to set it up correctly. If not, then just use the full path and you're good to go for this course. Okay. So that's it for this lecture. Now let's get started with the CLI. I will see you in the next lecture.

Contents