Data streaming on MacOS: the easy way
Tags: tutorial, beginners, kafka, redpanda
Published: 2022-05-11 21:35:54

Redpanda makes it easy to create a streaming data environment, while also keeping you API-compatible with Apache Kafka®. If you’re one of the many developers who already have Homebrew and Docker Desktop installed on your Mac, you can get up and running with Redpanda very quickly. In this post, we’ll show you how to install Redpanda and its command line interface, rpk, in one minute or less.

If you prefer to use Kubernetes, you can find more information about [K8s options for Redpanda here](https://redpanda.com/blog/getting-started-with-redpanda-on-kubernetes/). For Linux, [kind](https://kind.sigs.k8s.io/) and [minikube](https://minikube.sigs.k8s.io/docs/) are the simplest ways to get running with Redpanda.

## The single fastest way to start streaming on MacOS
Most developers who use Mac already have Homebrew and Docker Desktop installed. In this case, you only need a single line of code to start using Redpanda:

```
brew install redpanda-data/tap/redpanda && rpk container start
```

This single command line will install both Redpanda, as well as its CLI, which is called `rpk`. When you paste the above command into your terminal, you’ll see something like this:


![install redpanda and rpk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ulex1rrsugy8i3qam2i.png)

Redpanda and `rpk` have been installed successfully, and you’ve created your first, single-node cluster! It’s that easy.

You can now use `rpk` to interact with the node. But, first, here’s how you can get to this point if you don’t already have Docker and Homebrew installed on your machine.

## If you don’t have Docker or Homebrew installed
If you don’t already have Docker Desktop and Homebrew on your machine, don’t worry. It’s still very easy to install these tools and start using Redpanda. Here’s how to get set up with these prerequisites:

### 1. Install Docker Desktop
To install Docker on your Mac, go to [this page](https://www.docker.com/products/docker-desktop) and select the architecture-appropriate version of Docker Desktop to download for your machine. Note that your `MacOS` must be V10.15 or newer (Catalina, Big Sur, or Monterey versions) in order to run Docker.

### 2. Install Homebrew
Install [Homebrew](https://brew.sh/) by copy the following script into your MacOS Terminal:

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

With these prerequisites installed, you can now use the single command line above to start using Redpanda on your machine.

## Have some fun with Redpanda and `rpk`
Now that you have a one-node cluster up and running, you can use our [list of `rpk` commands](https://docs.redpanda.com/docs/reference/rpk-commands/) to experiment and interact with Redpanda.

## Setting up a three-node cluster

To prepare your environment to start a new cluster, first purge your existing single-node cluster using `rpk container purge`.

Now you can use `rpk container start -n 3` to start a new, three-node cluster.

You will see something like this:

![3 node redpanda cluster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fetlo7f321417o8p4raz.png)

Be sure to note the brokers listed in this output. You will need them to run commands in `rpk`.

You can now further interact with the cluster. Use rpk to **create a topic**:

```
rpk topic create topic_name --brokers <broker_1><broker_2><broker_3>
```

Example:

![create a redpanda topic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhqjbylmp4dj6uuxiowe.png)

**Produce to your topic** using:

```
rpk topic produce topic_name --brokers <broker_1><broker_2><broker_3>
```

Type a test message you want produced to your topic. For example:

`hello world!`

If the message was produced correctly, you’ll get a message similar to the following:

`Produced to partition 0 at offset 0 with timestamp 1646948687487.`

Example:

![Produce message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vbao9u3y1xxnd24g8d70.png)

To **consume from the topic**, run:

```
rpk topic consume topic_name --brokers <broker_1><broker_2><broker_3>
```

If the message was consumed correctly, you’ll get an output similar to this:

![consuming from redpanda](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k75i04bwx5m82ibvj52v.png)

Congratulations! You just did your first bit of data streaming on Redpanda.

Follow [the `rpk` command documentation](https://docs.redpanda.com/docs/reference/rpk-commands/) for more commands you can use.

When you’re done working within your node or cluster, shut it down and delete the node(s) using `rpk container purge`. This will clean up your streaming data environment.

## Take the next step!
If you have any questions getting started with Redpanda and `rpk`, please [join our community Slack](https://join.slack.com/t/redpandacommunity/shared_invite/zt-ng2ze1uv-l5VMWSGQHB9gp47~kNnYGA/). You can always find our rpk command documentation [here](https://docs.redpanda.com/docs/reference/rpk-commands/), and our full, source-available [GitHub repository here](https://github.com/redpanda-data/redpanda).