Skip to main content
In this recipe we’ll learn how to remove a server from a Pinot cluster.

Prerequisites

To follow the code examples in this guide, you must install Docker locally and download recipes.
  1. If you haven’t already, download recipes.
  2. In terminal, go to the recipe by running the following command:

Launching Pinot Cluster

Create Kubernetes cluster:
You can spin up a Pinot Cluster by running the following command:
Port Forward Pinot UI on port 9000
Port forward Kafka on port 9090
Add following line to /etc/hosts
Next, we’re going to deploy a Kafka pod and connect to it:
We’re going to create the events topic with 5 partitions, by running the following command:

Generating data

This recipe contains a data generator that creates events with a timestamp, count, and UUID. You can generate data by running the following command:
Output is shown below:

Ingesting data into Kafka

We’re going to ingest this data into an Apache Kafka topic using the kcat command line tool. We’ll also use jq to structure the data in the key:payload structure that Kafka expects:

Adding Pinot Schema and Table

Now let’s create a Pinot Schema and Table. First, the schema:
schema.json Now for the table config:
table.json

Checking segment assignment

As soon as this config has been applied, Pinot will start ingesting the data from Kafka. We’ll let it run for a little while and then run the following script to check segment assignment:
Output
We can see that the partitions are spread across servers 0-3.

Removing server from cluster

Next, we’re going to remove a server from the Pinot cluster:
After we’ve done this, be should see one ‘dead’ server on the Pinot UI: List of Pinot servers with one dead List of Pinot servers with one dead In this example server 3 has been removed, but your mileage may vary. So, the underlying server has been removed, but Pinot still thinks its there. Pinot has an API that lets us remove instances, so let’s try that out: Try to remove the instance:
Output (shortened for brevity)
It didn’t work because the server is still part of the ideal state for the table.

Removing tags from server

To fix this, we need to first remove all the tags from that server, by running the following:
Output
This will prevent any new segments being assigned to this server, but we still have one more step to do.

Rebalancing segments

The next is to rebalanae the segments so that any assigned to server 3 will be moved elsewhere. The API that does this takes in a lot of parameters, so we’ve wrapped it in the rebalance.py script, which you can download from GitHub. The contents are shown below:
rebalance.py Adjust those parameters accordingly before you run the script. You can run the script like this:
If you then wait a few seconds or maybe longer depending on how many segments you have, the segments will be rebalanced. At the time we’re writing this guide there isn’t an API to check on the progress of rebalancing, but this will be added in Pinot 0.13. You can manually check if it’s completed by running the following script again:
Once rebalancing has completed, you shouldn’t see server 3 in the output: Output

Removing instance from Pinot

And once that’s the case, we can retry the API that removes the instance from Pinot:
Output