Switching Kafka

Humio uses Kafka for queuing incoming messages and for storing shared state when running Humio in a cluster setup. It’s possible for Humio to snapshot its state and continue running using a new Kafka cluster. This can be useful in situations where you want to change infrastructure or if there are problems with the current Kafka/Zookeeper cluster. One example could be if all Zookeeper machines have written the disk full and afterwards Zookeeper will not start because of file inconsistencies. This section describes the procedure for doing a Kafka switch.

Stop Sending Data to Humio

If it is possible, stop sending data to Humio, then wait for Humio to process all data on the ingest queue. The Humio Stats dashboard in the Humio repository have an Events Processed After Ingest Queue graph by host per second and an Ingest Latency graph. If there is data on the ingest queue after closing Humio it will be lost as the queue is reset or another queue will be used.

You’ll need to stop all Humio processes on all machines. You’ll also need to stop all Kafka processes and all Zookeeper processes on all machines.

Switch Kafka and Zookeeper

There are three options for switching Kafka and Zookeeper. The first is to set up a new Kafka/Zookeeper cluster and configure Humio to use that. This is the simplest method. The other two methods are to delete the the Kafka and Zookeeper data, or to create new Kafka queues and topics with new names in the Kafka cluster.

Delete Kafka & Zookeeper Data and Re-Use Cluster

You could reset the current Kafka and Zookeeper cluster by deleting their data directories on the filesystem on each node. This is the same as starting up a new and empty Kafka/Zookeeper cluster. Another option is to spin up new Zookeeper/Kafka clusters. To do this, delete everything inside Kafka’s data directory. Then delete the folder version-2 inside Zookeeper’s data directory.

It’s important that you not delete the Zookeeper file myid in Zookeeper’s data directory. The myid is a configuration file that contains the id of the Zookeeper node in the Zookeeper cluster and must be there at startup.

After doing this, you will have created completely new Zookeeper and Kafka clusters.

Create New Kafka Queues/Topics with New Names in Kafka Cluster

Instead of resetting Kafka Zookeeper as described above, you can let Humio use a new set of queues in the existing Kafka cluster. When reusing the same Kafka cluster, Humio must be configured with a new HUMIO_KAFKA_TOPIC_PREFIX to detect the changes.

It’s important to note that it will not work to delete and recreate topics with the same names. In that case Humio cannot detect the Kafka switch. If Kafka is managed by Humio (KAFKA_MANAGED_BY_HUMIO), the new topics will be created automatically when Humio starts up. Otherwise you must create topics externally before you start Humio.

Start Kafka, Zookeeper and Humio

Now you’re ready to get the Kafka/Zookeper cluster started. This is typically done by starting the Zookeeper nodes. Wait for all nodes to be running and verify the Zookeeper cluster. Then start all Kafka nodes, wait for them to be running and verify the Kafka cluster.

Once Kafka and Zookeeper have started, start the Humio nodes. It’s important to start one Humio node first. This node will detect the Kafka switch and create a new epoch in Humio. If you’re running multiple Humio processes on one machine (with multiple CPUs), make sure to only start one Humio process.

To verify that the Kafka switch was detected and handled, look for this logline:

Switching epoch to=${epochKey} from=${latestEpoch.kafkaClusterId}
   - I'm the first cluster member to get here
     for this kafka. newEpoch=${newEpoch}

When the first node is up and running and the above logline confirms a new epoch has been created, the rest of the Humio nodes can be started.

At that point, the Humio cluster should be running again. Check the cluster nodes in the administrative section of the Humio user interface: http://$HUMIOHOST/system/administration/partitions/ingest

Recap

It’s worth reviewing the steps above again. In short, to do a Kafka switch you’ll need to do the following steps:

  • Stop all Humio processes on all nodes.
  • Stop all Kafka processes on all nodes.
  • Stop all Zookeeper processes on all nodes.
  • Delete Zookeeper and Kafka data (or use new Kafka queues).
  • Start all Zookeeper processes on all nodes.
  • Verify the Zookeeper cluster.
  • Start all Kafka processes on all nodes.
  • Verify the Kafka cluster.
  • Start one Humio node and let it change epoch.
  • Verify the epoch has changed.
  • Start the other Humio processes on all nodes.