Installation of Apache Kafka on Mac(OSx).
Installation and environment setup for Kafka on mac os.
To install Apache Kafka on Mac or any system, the prerequisite is the only Java(Java 8 ). First, we will look into the installation steps of Java and then we will proceed to set up Apache Kafka.
- Click on JDK, check the “Accept License Agreement” and download .dmg file for installation on Mac.
- Install the JDK on your system.
- Setup the Java path in your bash_profile.
You may verify the Java installation, by running the following command over a terminal.
Now you will come to know the Java version(the required version is Java8).
Install Apache Kafka using binary:-
- Download the latest Apache Kafka from https://kafka.apache.org/downloads under Binary downloads.
2. Click on any of the binary downloads, or choose a specific scala version if you have any dependency with scala in your development.
3. Go with the recommended mirror site and download.
4. Extract the downloaded file. Navigate to root of Apache Kafka folder and open a Terminal.
Now Kafka is ready to start.
Install Apache Kafka using Brew:-
Brew Cask, I am assuming you don’t have cask. Let us execute the below commands.
$ brew tap caskroom/cask
# install JDK 8 if you have already please skip this step
$ brew cask install java8
# now install Kafka along with zookeeper service
$ brew install Kafka
There are other ways but this is the two ways most of the people will follow.
Up & Running:-
Let us start zookeeper and Kafka locally. To start Kafka you must start with the first zookeeper. If you go to the extracted Kafka content you will get below picture. In the below directory structure you can get it in “bin” folder we have all binaries and in “config” we have all the configuration files to start Zookeeper and Kafka. To start with we need server.properties and zookeeper.properties.
By default, both Kafka and ZooKeeper send all data to /tmp/data.
You can change this default path to something different if you want from zookeeper.properties.
$ zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
Once zookeeper is up and running then go and start kafka server.
$ kafka-server-start /usr/local/etc/kafka/server.properties
Above configuration file path may change based on your installtion.