Spring Boot + Apache Kafka Tutorial - #3 - Install and Setup Apache Kafka


Welcome to Spring Boot + Apache Kafka Tutorial series. In this lecture, we will take a look at how to install and set up Apache Kafka on the local machine.

Lecture - #3 - Install and Setup Apache Kafka


Transcript:

Hi. Welcome back. In this lecture, we will install and set up Apache Kafka locally. Well, it's pretty simple to install and set up Apache Kafka locally. Just follow the steps that I am going to implement in this lecture. Well, head over to the browser and in a new tab, just type Apache Kafka download and hit enter. So go ahead and click on this first link that is download Apache Kafka. So this will navigate to the Apache Kafka downloads page. Well, here you can see it get started tab and within that, here you can see Quickstart link. So go ahead and click on this link over here. Well, in this course, we are going to use Apache Kafka quick start page a lot. Okay. So just scroll down and here you can see the steps. So these are the steps that are pretty useful to install and set up the Kafka locally. Well, let's take a look under the step one. Step one is get Kafka. It means we need to download the latest Kafka release locally and then we need to extract it. So go ahead and click on this download link over here. We'll go ahead and click on this link to download Apache Kafka as a tar file locally. Well, I'm going to click on this link Kafka downloading, you know, file system. So it will take a couple of seconds as per the internet speed. Apache Kafka downloaded as a zip file or a tar file and go ahead and open in a folder and just go-ahead and extract this file. So I'm going to extract it. Now let's go and let's rename to this folder. So I am going to rename as Kafka. So just remove the version from here. Let's keep Kafka. All right. Now, let's see the second step. So let me go back here. And the second step is, that we need to start the Kafka environment. Well before starting the Kafka environment make sure that you have installed 8+ on your machine. All right. Next, we need to start the zookeeper. Well, you might be wondering what is zookeeper, right? So here you can see the diagram, Kafka ecosystem diagram over here. So this Kafka system has a Kafka cluster. And within a Kafka cluster, we have three Kafka brokers. One, two, three. All right. And here we have one zookeeper. So zookeeper is basically a service that will manage the state of all the Kafka brokers within a Kafka cluster. And it will also manage the configuration of the topic and producer and consumer as well. All right. So just remember, we need to start the zookeeper so that it will start managing the state of Kafka brokers in a Kafka cluster. Well, in our case, we have only one Kafka broker that we are going to install locally. So first we need to start the zookeeper so that it will manage the state of the Kafka broker. Well, in order to start the Zookeeper service, we need to execute this ssh file that is zookeeper-server-start.sh. Well, this sh file is located within a bin folder. If you go to Kafka, just expand the Kafka and here we have a bin within bin folder you can see all these sh files. So these sh files will support for Mac and Linux. If you are using Windows, then make sure that you will use these bat files. Okay. So I am using Mac, so I am going to execute sh files. All right. So just search for zookeeper-server-start.sh file over here And there we go. So here you can see zookeeper- server-start.sh So this is the sh file we are going to run in order to start the zookeeper service. So just go back to browser and let me copy this command and let me execute in a terminal. So let me copy it and let me open the terminal over here and let me zoom this terminal and let me be paste here. So before executing this command, we need to move into the Kafka folder right? So just go ahead and type cd and then we need to go to the Downloads folder right. Downloads and hit enter, within Downloads folder we have the Kafka folder right cd kafka and then we need to enter this command. So within the Kafka folder, we have a bin folder. Within the bin folder, we have this sh file and then config /zookeeper.properties. Well, this sh file will refer to all the properties from this properties file. Hit enter there we go. You can see zookeeper service has started. Well, once Zookeeper Service has started, then we can go ahead and run the Kafka broker service. Well, just open a new terminal session and run this command. Well, let me copy this command. Well, if we can see this command, we're here in order to start the service, we're going to run this sh file that is kafka-server-start.sh file. So this sh is located within the bin folder. Well, let me go to kafka again and within bin folder you can see a bunch of, you know, as sh files. So if you are using windows, then you should use a bat file. Okay, so let me search for kafka-server-start.sh so this is the attachment that we are going to run in order to start the Kafka broker's service. Well, let me go back to the steps. Let me copy this command and let me go to the terminal. So if you are using windows, then make sure that you use command prompt. Well, let me open the new cell. Okay, so let me do a little bit. So if you are using Windows, then you can go ahead and open a new command prompt. So let me go into the Downloads folder, cd Downloads, cd kafka Right. So go to the Kafka folder and then run this command that is kafka-server-start.sh file make sure that you provide this server.properties file. Okay. Because this message file basically refers to all the properties from this server.properties file. So let me hit enter. So this will run the Apache Kafka service. Well, let me maximize this. Well, Apache Kafka's broken service will run on localhost 9092. So let me just search for 9092 port and let me show you the log it states the Apache broker service has started. Let me search for 9092. And there we go. So this is the log statement. You can see recorded new controller from now on will use a broker service localhost 9092 which means our Apache Kafka broker service is started on port 9092. All right. And this localhost colon 9092. We are going to use it in our Spring Boot application in order to interact with the Kafka Okay, great. Now let me go back to the steps. Once all services have successfully launched, you will have a basic Kafka environment running and ready to use. Well, we have started a zookeeper service as well as a Kafka service. Now we are good to use a Kafka broker service on our local machine. Well, let me recap what we have done in this lecture. We have downloaded the latest version of Kafka from the official website, and then we have installed in our local machine. And then we started the zookeeper service as well as the Kafka broker service. Now we are going to use a Kafka environment in our Spring Boot application.

Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours


Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course

Comments