- Go to https://kafka.apache.org/downloads to download the open-source software for Kafka. (Use the binary download link associated with Scala 2.12)
- Move the downloaded zip file:
mv Downloads/<file-name>.tgz ~/
- Uncompress the zip file as a directory:
tar -xvf <file-name>.tgz
- Check the current version of Java on your computer:
java -version
- Install version 8 using Homebrew:
brew tap caskroom/versions
brew cask install java8
Done with setup!
- List all commands in the
bin
directory:
cd kafka_2.12-<version>/bin
ls
- Try using a CLI command (list topics)
kafka-topics.sh
- Add the Kafka CLI commands to your
PATH
variable by appending the following line to the end of your~/.bash_profile
. To get an accurate path to your kafkabin
directory, executepwd
from that location.
export PATH="$PATH:Users/<user>/kafka_2.12-<version>/bin"
- Navigate to a different directory. Try out the command interface by typing
kafka-
followed by the tab. It should list all commands. Use arrow keys to navigate and type Enter to execute.
- Navigate to the
kafka_2.12-<version>
directory. Make sure you have aconfig/
directory. - Create your own data directory to store log data:
mkdir data
mkdir data/zookeeper
mkdir data/kafka
- Update your
config/zookeeper.properties
file with this edit (Usepwd
to get the full path).
dataDir=<full-path-kafka>/data/zookeeper
- Update your
config/server.properties
file too.
log.dirs=<full-path-kafka>/data/kafka
- Start a zookeeper server. Once it is started, you will get a message that it is binding to port 2181.
zookeeper-server-start config/zookeeper.properties
- Open a second terminal window and start a kafka server. It will be hosted on port 9092.
kafka-server-start config/server.properties