# How to install Apache Kafka on Mac

*Install and run Kafka on macOS*

This guide walks you through installing Apache Kafka with ZooKeeper on macOS. By the end, you'll have a working single-node Kafka cluster for development.

**What you'll learn:**
- How to install Java 11 (required dependency)
- How to download and configure Kafka
- How to start ZooKeeper and Kafka
- How to set up your PATH for CLI access

> **ZooKeeper vs KRaft**
> This guide uses ZooKeeper mode for maximum compatibility. For KRaft mode (without ZooKeeper), see the [Mac KRaft installation guide](https://www.conduktor.io/kafka/how-to-install-apache-kafka-on-mac-without-zookeeper-kraft-mode).

## Installation overview

![Mac Kafka install flow: install Java 11, download Kafka, start ZooKeeper, start Kafka, configure PATH](https://www.conduktor.io/assets/kafka/diagrams/how-to-install-apache-kafka-on-mac.svg)

```mermaid
flowchart LR
    A[Install Java 11] --> B[Download Kafka]
    B --> C[Start ZooKeeper]
    C --> D[Start Kafka]
    D --> E[Configure PATH]
```

## Step 1: Install Java JDK 11

Kafka requires Java 11 or later.

1. Download [Amazon Corretto 11](https://corretto.aws/downloads/latest/amazon-corretto-11-x64-macos-jdk.pkg) (free OpenJDK distribution)
2. Double-click the downloaded `.pkg` file
3. Follow the installation wizard

Verify the installation:

```bash
java -version
```

Expected output:
```
openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment Corretto-11.0.10.9.1 (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.10.9.1 (build 11.0.10+9-LTS, mixed mode)
```

> If you have multiple Java versions installed, see [how to set the default Java version on Mac](https://stackoverflow.com/a/24657630).

## Step 2: Download and extract Kafka

1. Download Kafka from [kafka.apache.org/downloads](https://kafka.apache.org/downloads) (choose the latest binary with Scala 2.13)
2. Extract the archive to your home directory

```bash
cd ~/Downloads
tar -xzf kafka_2.13-3.0.0.tgz
mv kafka_2.13-3.0.0 ~/
```

## Step 3: Start ZooKeeper

ZooKeeper has to be running before Kafka starts.

Open a terminal and run:

```bash
~/kafka_2.13-3.0.0/bin/zookeeper-server-start.sh ~/kafka_2.13-3.0.0/config/zookeeper.properties
```

> Add the `-daemon` flag to run ZooKeeper in the background.

Keep this terminal window open.

## Step 4: Start Kafka

Open a **new terminal window** and run:

```bash
~/kafka_2.13-3.0.0/bin/kafka-server-start.sh ~/kafka_2.13-3.0.0/config/server.properties
```

Keep this terminal window open. Kafka is now running at `localhost:9092`.

## Step 5: Configure PATH

Add Kafka binaries to your PATH for convenient access.

Edit your shell configuration file (`~/.zshrc` for zsh or `~/.bashrc` for bash):

```bash
export PATH="$PATH:$HOME/kafka_2.13-3.0.0/bin"
```

Reload your shell:

```bash
source ~/.zshrc
```

Verify the setup:

```bash
kafka-topics.sh --version
```

## Optional: Change data directories

By default, Kafka stores data in `/tmp`, which may be cleared on restart.

**Change ZooKeeper data directory:**

Edit `~/kafka_2.13-3.0.0/config/zookeeper.properties`:
```
dataDir=/your/path/to/data/zookeeper
```

**Change Kafka data directory:**

Edit `~/kafka_2.13-3.0.0/config/server.properties`:
```
log.dirs=/your/path/to/data/kafka
```

> **See it in practice with Conduktor**
> [Conduktor Console](https://docs.conduktor.io/guide/conduktor-in-production/admin/configure-clusters) can connect to your local Kafka cluster at `localhost:9092` for visual topic management.

## Next steps

- [Mac KRaft installation](https://www.conduktor.io/kafka/how-to-install-apache-kafka-on-mac-without-zookeeper-kraft-mode) for a ZooKeeper-free setup
- [CLI tutorials](https://www.conduktor.io/kafka/kafka-cli-tutorial) to create topics and produce messages
- [Mac Homebrew installation](https://www.conduktor.io/kafka/how-to-install-apache-kafka-on-mac-with-homebrew) for an alternative setup
