Monday, June 22, 2020

How to Install Apache Kafka on Linux Ubuntu

In order to install Apache Kafka you should have Java installed and JAVA_HOME environment variable set; if not follow the first instructions of this article.
1- Download Zookeeper:
wget http://apache.mirror.anlx.net/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz
view raw sh hosted with ❤ by GitHub

2- Extract the archive content:
tar -xvzf apache-zookeeper-3.6.1-bin.tar.gz
view raw sh hosted with ❤ by GitHub

3- Create Zookeeper configuration file from the sample provided:
cp apache-zookeeper-3.6.1-bin/conf/zoo_sample.cfg apache-zookeeper-3.6.1-bin/conf/zoo.cfg
view raw sh hosted with ❤ by GitHub

4- Open the startup script file vim ~/.bashrc and add the following content:
export ZOOKEEPER_HOME=/home/ubuntu/apache-zookeeper-3.6.1-bin
export PATH="$PATH:${ZOOKEEPER_HOME}/bin"
view raw .bashrc hosted with ❤ by GitHub

5- activate the new path settings:
source ~/.bashrc
view raw sh hosted with ❤ by GitHub

6- Start zookeeper service:
zkServer.sh start
view raw sh hosted with ❤ by GitHub

7- Download Kafka:
wget http://apache.mirror.anlx.net/kafka/2.5.0/kafka_2.12-2.5.0.tgz
view raw sh hosted with ❤ by GitHub

8- Create an installation folder for Kafka:
sudo mkdir /opt/kafka
view raw sh hosted with ❤ by GitHub

9- Extract the archive content:
sudo tar -xvzf kafka_2.12-2.5.0.tgz -C /opt/kafka
view raw sh hosted with ❤ by GitHub

10- Open the startup script file vim ~/.bashrc and add the following content:
export KAFKA_HOME=/opt/kafka/kafka_2.12-2.5.0
export PATH="$PATH:${KAFKA_HOME}/bin"
view raw .bashrc hosted with ❤ by GitHub

11- activate the new path settings:
source ~/.bashrc
view raw sh hosted with ❤ by GitHub

12- Create a shortcut to Kafka configuration file:
sudo ln -s /opt/kafka/kafka_2.12-2.5.0/config/server.properties /etc/kafka.properties
view raw sh hosted with ❤ by GitHub

13- Edit listners parameter within Kafka configuration file i.e.:
listeners=PLAINTEXT://thedevopsnerdworld.com:9092
14- Start Kafka service:
kafka-server-start.sh /etc/kafka.properties
view raw sh hosted with ❤ by GitHub

No comments:

Post a Comment