The [Apache ZooKeeper](https://zookeeper.apache.org/) component is a centralized service for providing distributed synchronization of data. You can install ZooKeeper when you create a Managed Service for Apache Spark cluster by using the [Optional components](https://docs.cloud.google.com/managed-spark/docs/concepts/components/overview.md.txt#available_optional_components) feature.

## Install the component

Install the component when you create a Managed Service for Apache Spark cluster.

See
[Supported image versions](https://docs.cloud.google.com/managed-spark/docs/concepts/versioning/dataproc-versions#supported_cloud_dataproc_versions)
for the component version included in each Managed Service for Apache Spark image release.

### Google Cloud console

1. In the Google Cloud console, open [**Create cluster**](https://console.cloud.google.com/dataproc/clusters/create) page.
2. Click **Additional configuration** to expand that section.
3. Edit **Optional components**.
4. In the panel that opens, select the checkbox for **ZooKeeper** , then click **Save**.

### gcloud CLI

To create a Managed Service for Apache Spark cluster that includes the ZooKeeper component,
use the
[gcloud dataproc clusters create](https://docs.cloud.google.com/sdk/gcloud/reference/dataproc/clusters/create.md.txt) <var translate="no">cluster-name</var>
command with the `--optional-components` flag (using image version
1.0 or later).

```
gcloud dataproc clusters create cluster-name \
    --optional-components=ZOOKEEPER \
    --region=region \
    ... other flags
```

### REST API

The ZooKeeper component can be specified through the Dataproc API using [SoftwareConfig.Component](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/ClusterConfig.md.txt#Component) as part of a [clusters.create](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/projects.regions.clusters/create.md.txt) request.