From the course: Complete Guide to Apache Kafka for Beginners

macOS X: Start Kafka in KRaft mode - Kafka Tutorial

From the course: Complete Guide to Apache Kafka for Beginners

macOS X: Start Kafka in KRaft mode

Hi, this is Stephane from Conduktor and in this lecture, we're going to see how to start one Kafka broker using KRaft mode. So, I mean, there is no zookeeper in this instance and which is something that you will have to do, starting with Kafka 4.0, because Zookeeper is going to be completely removed from Kafka 4.0. But as of Kafka 3.3.1 Kafka KRaft is production ready, and then we're going to be able to see how to actually start Kafka without Zookeeper. So for this two steps, we need to generate a cluster ID and then format the storage using the Kafka storage.sh command, and then we can start Kafka using the binaries very simply. Okay. So back here, I'm going to stop the commands that I have running already on my terminal, so I'll do Control C on Kafka to stop my Kafka server. So now my Kafka server is shut down. Okay. And I will clear my screen and then I'll do Control C to stop Zookeeper and then I will clear my screen. Okay. So now Zookeeper is shut down, Kafka is shut down, and I can actually close one terminal because I will only need one terminal for the rest of this course. Okay. So next on the Kafkademy website, I'm going to install Kafka without zookeeper in KRaft mode. And again, all the commands are for reference right here. So we don't have to reinstall Java 11. Of course, we don't have to read an old Kafka because we have it. But now we can start Kafka and first we need to generate a new ID for our cluster. So thankfully, the Kafka storage command is accessible to us and it's already in the path. So I can just copy this part. Kafka storage.sh and then random UUID. So this is going to generate a cluster ID for your cluster. Okay. Next we're going to format our storage directory and then we'll replace the UUID by whatever is obtained above. So this is the full command right here. So I'll just copy this part. So Kafka storage format, okay, let me paste this in. So Kafka storage format. Then we need to pass the UUID we obtained from before, so I will just copy this and paste it in. And then we need to pass the KRaft server.property file. So it is in the config. So if you go into your config folder already there is a KRaft directory and within it there is a server.property file that we'll be using. Okay. So what I'm going to do is just use this, but as you can see, the path is wrong. So this is not Kafka 300 I'm using, but it's Kafka 310 that I'm using. Okay. So let's press "Enter". And it has formatted a directory called temp slash KRaft combined logs. And this is where Kafka is going to store its data. So once this command is done, then I will be able to do a Kafka server start. Okay. And then I'm going to do a Kafka server start and pass in the right configuration file. So let's do Kafka server start. And then in here we have access to the config KRaft server.property. So I will just edit and put a one here to have the right path because if you don't, you're going to get a like file not found exception, you see, because something has not been found. So instead, make sure you pass in the right directory path. You press "Enter" and there you go. So Kafka is started, and as we can see, Kafka is running on its own. It was not using Zookeeper to get started, which I think is pretty awesome and cool. So either using Kafka KRaft mode or Kafka with Zookeeper, you should have Kafka started and you should be good to go for the rest of this course. All right, that's it for this lecture. I hope you liked it and I will see you in the next lecture.

Contents