Installation
Verify Java Version
You must have java version 8 on your machine. You can verify this using.
$ java -version
If java is successfully installed on your machine, you could see the version of the installed Java.
If Java is not available, please download the latest version of JDK for your operating system.
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_122/bin/java 100
ZooKeeper Installation
Download ZooKeeper
Zookeeper is included with Kafka download
Extract tar file
Extract tar file using the following command
$ cd /opt/appbin
$ tar -zxf zookeeper-3.4.6.tar.gz
$ cd zookeeper-3.4.6
$ mkdir data
Update Configuration File
Open Configuration File named conf/zoo.cfg using the command vi “conf/zoo.cfg” and all the following parameters to set as starting point.
$ vi conf/zoo.cfg
tickTime=2000
dataDir=/path/to/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
Once the configuration file has been saved successfully and return to terminal again, you can start the zookeeper server.
Start ZooKeeper Server
$ bin/zkServer.sh start
After executing this command, you will see output similar to the one shown below−
$ JMX enabled by default
$ Using config: /Users/../zookeeper-3.4.6/bin/../conf/zoo.cfg
$ Starting zookeeper ... STARTED
Start Zookeeper CLI
$ bin/zkCli.sh
After typing the above command, you will be connected to the zookeeper server and will get the below response.
Connecting to localhost:2181
................
................
................
Welcome to ZooKeeper!
................
................
WATCHER::
WatchedEvent state:SyncConnected type: None path:null
[zk: localhost:2181(CONNECTED) 0]
Stop Zookeeper Server
After connecting the server and performing all the operations, you can stop the zookeeper server with the following command −
$ bin/zkServer.sh stop
Apache Kafka Installation
Let us continue with the following steps to install Kafka on your machine.
Download Kafka
To install Kafka, download a compatible binary version.
In this document, we are working with the 1.1.1 version – kafka_2.11_1.1.1.tgz
Extract the tar file
Extract the tar file using the following command −
$ cd /opt/appbin
$ tar -zxf kafka_2.11_1.1.1.tar.gz
$ cd kafka_2.11_1.1.1
Now you have downloaded the latest version of Kafka on your machine.
Start Kafka Server
Start the zookeeper server as shown earlier. Next start the Kafka server using
$ bin/kafka-server-start.sh config/server.properties
Once the server starts, you will see output similar to shown below
$ bin/kafka-server-start.sh config/server.properties
[2019-12-12 10:15:30,550] INFO KafkaConfig values:
request.timeout.ms = 30000
log.roll.hours = 168
inter.broker.protocol.version = 1.1.1.X
log.preallocate = false
…………………………………………….
…………………………………………….
Stop Kafka Server
After performing all the operations, you can stop the server using the following command −
$ bin/kafka-server-stop.sh config/server.properties
This completes Kafka Server installation from the tar.
Last updated