Project: Flink (App Definition and Development / Streaming & Messaging)
File: zookeeper_ha.md

title: ZooKeeper HA Services weight: 2 type: docs aliases: /deployment/ha/zookeeper_ha.html <!-- 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. --> Flink's ZooKeeper HA services use for high availability services. Flink leverages for distributed coordination between all running JobManager instances. ZooKeeper is a separate service from Flink, which provides highly reliable distributed coordination via leader election and light-weight consistent state storage. Check out for more information about ZooKeeper. Flink includes scripts to installation. In order to start an HA-cluster you have to configure the following configuration keys: (required): The `high-availability.type` option has to be set to `zookeeper`. <pre>high-availability.type: zookeeper</pre> (required): JobManager metadata is persisted in the file system `high-availability.storageDir` and only a pointer to this state is stored in ZooKeeper. <pre>high-availability.storageDir: hdfs:///flink/recovery</pre> The `storageDir` stores all metadata needed to recover a JobManager failure. (required): A ZooKeeper quorum is a replicated group of ZooKeeper servers, which provide the distributed coordination service. <pre>high-availability.zookeeper.quorum: address1:2181[,...],addressX:2181</pre> Each `addressX:port` refers to a ZooKeeper server, which is reachable by Flink at the given address and port. (recommended): The root ZooKeeper node, under which all cluster nodes are placed. <pre>high-availability.zookeeper.path.root: /flink</pre> (recommended): The cluster-id ZooKeeper node, under which all required coordination data for a cluster is placed. <pre>high-availability.cluster-id:

# important: customize per cluster</pre> Important: You should not set this value manually when running on YARN, native Kubernetes or on another cluster manager. In those cases a cluster-id is being automatically generated. If you are running multiple Flink HA clusters on bare metal, you have to manually configure separate cluster-ids for each cluster. Configure high availability mode and ZooKeeper quorum in : ```bash high-availability.type: zookeeper high-availability.zookeeper.quorum: localhost:2181 high-availability.zookeeper.path.root: /flink high-availability.cluster-id: /cluster_one # important: customize per cluster high-availability.storageDir: hdfs:///flink/recovery ``` {{< top >}} If ZooKeeper is running in secure mode with Kerberos, you can override the following configurations in as necessary: ```bash zookeeper.sasl.service-name: zookeeper zookeeper.sasl.login-context-name: Client ``` For more information on Flink configuration for Kerberos security, please refer to the . You can also find further details on . {{< top >}} Per default, Flink's ZooKeeper client treats suspended ZooKeeper connections as an error. This means that Flink will invalidate all leaderships of its components and thereby triggering a failover if a connection is suspended. This behaviour might be too disruptive in some cases (e.g., unstable network environment). If you are willing to take a more aggressive approach, then you can tolerate suspended ZooKeeper connections and only treat lost connections as an error via . Enabling this feature will make Flink more resilient against temporary connection problems but also increase the risk of running into ZooKeeper timing problems. For more information take a look at . If you don't have a running ZooKeeper installation, you can use the helper scripts, which ship with Flink. There is a ZooKeeper configuration template in `conf/zoo.cfg`. You can configure the hosts to run ZooKeeper on with the `server.X` entries, where X is a unique ID of each server: ```bash server.X=addressX:peerPort:leaderPort [...] server.Y=addressY:peerPort:leaderPort ``` The script `bin/start-zookeeper-quorum.sh` will start a ZooKeeper server on each of the configured hosts. The started processes start ZooKeeper servers via a Flink wrapper, which reads the configuration from `conf/zoo.cfg` and makes sure to set some required configuration values for convenience. In production setups, it is recommended to manage your own ZooKeeper installation. {{< top >}}