> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# zookeeper_* server settings

> ClickHouse server settings in the zookeeper_* generated group.

These settings configure the ClickHouse server and are autogenerated from ClickHouse source.

<h2 id="zookeeper">
  zookeeper
</h2>

Contains settings that allow ClickHouse to interact with a [ZooKeeper](http://zookeeper.apache.org/) cluster. ClickHouse uses ZooKeeper for storing metadata of replicas when using replicated tables. If replicated tables are not used, this section of parameters can be omitted.

The following settings can be configured by sub-tags:

| Setting | Description |
| - | - |
| `node` | ZooKeeper endpoint. You can set multiple endpoints. Eg. `<node index="1"><host>example_host</host><port>2181</port></node>`. The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster. |
| `operation_timeout_ms` | Maximum timeout for one operation in milliseconds. |
| `session_timeout_ms` | Maximum timeout for the client session in milliseconds. |
| `root` (optional) | The znode that is used as the root for znodes used by the ClickHouse server. |
| `fallback_session_lifetime.min` (optional) | Minimum limit for the lifetime of a zookeeper session to the fallback node when primary is unavailable (load-balancing). Set in seconds. Default: 3 hours. |
| `fallback_session_lifetime.max` (optional) | Maximum limit for the lifetime of a zookeeper session to the fallback node when primary is unavailable (load-balancing). Set in seconds. Default: 6 hours. |
| `identity` (optional) | User and password required by ZooKeeper to access requested znodes. |
| `use_compression` (optional) | Enables compression in Keeper protocol if set to true. |
| `use_xid_64` (optional) | Enables 64-bit transaction IDs. Set to `true` to enable extended transaction ID format. Default: `false`. |
| `pass_opentelemetry_tracing_context` (optional) | Enables propagation of OpenTelemetry tracing context to Keeper requests. When enabled, tracing spans will be created for Keeper operations, allowing distributed tracing across ClickHouse and Keeper. See [Tracing ClickHouse Keeper Requests](/docs/guides/oss/deployment-and-scaling/monitoring/opentelemetry#tracing-clickhouse-keeper-requests) for more details. Default: `false`. |

There is also the `zookeeper_load_balancing` setting (optional) which lets you select the algorithm for ZooKeeper node selection:

| Algorithm Name | Description |
| - | - |
| `random` | randomly selects one of ZooKeeper nodes. |
| `in_order` | selects the first ZooKeeper node, if it's not available then the second, and so on. |
| `nearest_hostname` | selects a ZooKeeper node with a hostname that is most similar to the server's hostname, hostname is compared with name prefix. |
| `hostname_levenshtein_distance` | just like nearest\_hostname, but it compares hostname in a levenshtein distance manner. |
| `first_or_random` | selects the first ZooKeeper node, if it's not available then randomly selects one of remaining ZooKeeper nodes. |
| `round_robin` | selects the first ZooKeeper node, if reconnection happens selects the next. |

**Example configuration**

```xml theme={null}
<zookeeper>
    <node>
        <host>example1</host>
        <port>2181</port>
    </node>
    <node>
        <host>example2</host>
        <port>2181</port>
    </node>
    <session_timeout_ms>30000</session_timeout_ms>
    <operation_timeout_ms>10000</operation_timeout_ms>
    <!-- Optional. Chroot suffix. Should exist. -->
    <root>/path/to/zookeeper/node</root>
    <!-- Optional. Zookeeper digest ACL string. -->
    <identity>user:password</identity>
    <!--<zookeeper_load_balancing>random / in_order / nearest_hostname / hostname_levenshtein_distance / first_or_random / round_robin</zookeeper_load_balancing>-->
    <zookeeper_load_balancing>random</zookeeper_load_balancing>
    <!-- Optional. Enable 64-bit transaction IDs. -->
    <use_xid_64>false</use_xid_64>
    <!-- Optional. Enable OpenTelemetry tracing context propagation. -->
    <pass_opentelemetry_tracing_context>false</pass_opentelemetry_tracing_context>
</zookeeper>
```

**See Also**

* [Replication](/docs/reference/engines/table-engines/mergetree-family/replication)
* [ZooKeeper Programmer's Guide](http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html)
* [Optional secured communication between ClickHouse and Zookeeper](/docs/guides/oss/deployment-and-scaling/keeper/ssl-zookeeper)

<h2 id="zookeeper_log">
  zookeeper\_log
</h2>

Settings for the [`zookeeper_log`](/docs/reference/system-tables/zookeeper_log) system table.

The following settings can be configured by sub-tags:

The following settings can be configured by sub-tags:

| Setting | Description | Default | Note |
| - | - | - | - |
| `database` | Name of the database. | | |
| `table` | Name of the system table. | | |
| `engine` | [MergeTree Engine Definition](/docs/reference/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-creating-a-table) for a system table. | | Cannot be used if `partition_by` or `order_by` defined. If not specified `MergeTree` is selected by default |
| `partition_by` | [Custom partitioning key](/docs/reference/engines/table-engines/mergetree-family/custom-partitioning-key) for a system table. | | If `engine` is specified for system table, `partition_by` parameter should be specified directly inside 'engine' |
| `ttl` | Specifies the table [TTL](/docs/reference/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-ttl). | | If `engine` is specified for system table, `ttl` parameter should be specified directly inside 'engine' |
| `order_by` | [Custom sorting key](/docs/reference/engines/table-engines/mergetree-family/mergetree#order_by) for a system table. Can't be used if `engine` defined. | | If `engine` is specified for system table, `order_by` parameter should be specified directly inside 'engine' |
| `storage_policy` | Name of the storage policy to use for the table (optional). | | If `engine` is specified for system table, `storage_policy` parameter should be specified directly inside 'engine' |
| `settings` | [Additional parameters](/docs/reference/engines/table-engines/mergetree-family/mergetree#settings) that control the behavior of the MergeTree (optional). | | If `engine` is specified for system table, `settings` parameter should be specified directly inside 'engine' |
| `flush_interval_milliseconds` | Interval for flushing data from the buffer in memory to the table. | `7500` | |
| `max_size_rows` | Maximal size in lines for the logs. When the amount of non-flushed logs reaches the max\_size, logs are dumped to the disk. | `1048576` | |
| `reserved_size_rows` | Pre-allocated memory size in lines for the logs. | `8192` | |
| `buffer_size_rows_flush_threshold` | Threshold for amount of lines. If the threshold is reached, flushing logs to the disk is launched in background. | `max_size_rows / 2` | |
| `flush_on_crash` | Sets whether logs should be dumped to the disk in case of a crash. | `false` | |

Additionally, the following server-level setting controls the default flush policy for all system log tables:

```xml theme={null}
<default_system_log_flush_policy>
    <skip_alias_columns>true</skip_alias_columns>
</default_system_log_flush_policy>
```

| Setting | Description | Default |
| - | - | - |
| `skip_alias_columns` | When `true`, ALIAS columns are omitted from system log table schemas. Required for S3-backed system logs. | `false` |

**Example**

```xml theme={null}
<clickhouse>
    <zookeeper_log>
        <database>system</database>
        <table>zookeeper_log</table>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
        <ttl>event_date + INTERVAL 1 WEEK DELETE</ttl>
    </zookeeper_log>
</clickhouse>
```
