2018-12-13 14:47:20 -05:00
---
2019-08-21 00:48:59 -04:00
id: zookeeper
2018-12-13 14:47:20 -05:00
title: "ZooKeeper"
---
2018-11-13 12:38:37 -05:00
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
2018-12-12 23:42:12 -05:00
2021-05-25 15:49:49 -04:00
Apache Druid uses [Apache ZooKeeper ](http://zookeeper.apache.org/ ) (ZK) for management of current cluster state.
## Minimum ZooKeeper versions
Apache Druid supports ZooKeeper versions 3.5.x and above.
2023-08-16 22:01:21 -04:00
:::info
Note: Starting with Apache Druid 0.22.0, support for ZooKeeper 3.4.x has been removed
2024-04-30 22:36:00 -04:00
Starting with Apache Druid 31.0.0, support for Zookeeper-based segment loading has been removed.
2023-08-16 22:01:21 -04:00
:::
2021-05-25 15:49:49 -04:00
## ZooKeeper Operations
The operations that happen over ZK are
2015-05-05 17:07:32 -04:00
2019-08-21 00:48:59 -04:00
1. [Coordinator ](../design/coordinator.md ) leader election
2. Segment "publishing" protocol from [Historical ](../design/historical.md )
2024-04-30 22:36:00 -04:00
3. [Overlord ](../design/overlord.md ) leader election
2024-09-05 13:25:30 -04:00
4. [Overlord ](../design/overlord.md ) and [Middle Manager ](../design/middlemanager.md ) task management
2015-05-05 17:07:32 -04:00
2019-10-24 14:17:39 -04:00
## Coordinator Leader Election
2015-05-05 17:07:32 -04:00
2021-11-22 14:58:42 -05:00
We use the Curator [LeaderLatch ](https://curator.apache.org/curator-recipes/leader-latch.html ) recipe to perform leader election at path
2015-05-05 17:07:32 -04:00
```
${druid.zk.paths.coordinatorPath}/_COORDINATOR
```
2019-10-24 14:17:39 -04:00
## Segment "publishing" protocol from Historical and Realtime
2015-05-05 17:07:32 -04:00
2024-08-06 09:59:13 -04:00
The `announcementsPath` and `liveSegmentsPath` are used for this.
2015-05-05 17:07:32 -04:00
2019-08-21 00:48:59 -04:00
All [Historical ](../design/historical.md ) processes publish themselves on the `announcementsPath` , specifically, they will create an ephemeral znode at
2015-05-05 17:07:32 -04:00
```
${druid.zk.paths.announcementsPath}/${druid.host}
```
Which signifies that they exist. They will also subsequently create a permanent znode at
```
2024-08-06 09:59:13 -04:00
${druid.zk.paths.liveSegmentsPath}/${druid.host}
2015-05-05 17:07:32 -04:00
```
And as they load up segments, they will attach ephemeral znodes that look like
```
2024-08-06 09:59:13 -04:00
${druid.zk.paths.liveSegmentsPath}/${druid.host}/_segment_identifier_
2015-05-05 17:07:32 -04:00
```
2019-08-21 00:48:59 -04:00
Processes like the [Coordinator ](../design/coordinator.md ) and [Broker ](../design/broker.md ) can then watch these paths to see which processes are currently serving which segments.