> ## 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.

# interserver_http_* 服务器设置

> 属于 interserver_http_* 生成分组的 ClickHouse 服务器设置。

这些设置用于配置 ClickHouse 服务器，并由 ClickHouse 源代码自动生成。

## interserver\_http\_credentials

在[复制](https://clickhouse.com/docs/zh/reference/engines/table-engines/mergetree-family/replication.md)期间，用于连接其他服务器的用户名和密码。此外，服务器也会使用这些凭据对其他副本进行身份验证。
因此，集群中所有副本的 `interserver_http_credentials` 必须保持一致。

> [!NOTE]
>
> * 默认情况下，如果省略 `interserver_http_credentials` 部分，则复制期间不使用身份验证。
> * `interserver_http_credentials` 设置与 ClickHouse 客户端凭据[配置](https://clickhouse.com/docs/zh/concepts/features/interfaces/client.md#configuration_files)无关。
> * 这些凭据同时适用于通过 `HTTP` 和 `HTTPS` 进行的复制。

以下设置可通过子标签配置：

* `user` — 用户名。
* `password` — 密码。
* `allow_empty` — 如果为 `true`，则即使已设置凭据，也允许其他副本在不进行身份验证的情况下连接。如果为 `false`，则会拒绝未经过身份验证的连接。默认值：`false`。
* `old` — 包含凭据轮换期间使用的旧 `user` 和 `password`。可以指定多个 `old` 部分。

**凭据轮换**

ClickHouse 支持动态轮换 interserver 凭据，无需为更新配置而同时停止所有副本。凭据可分多个步骤进行更改。

要启用身份验证，请将 `interserver_http_credentials.allow_empty` 设置为 `true` 并添加凭据。这样既允许经过身份验证的连接，也允许未经过身份验证的连接。

```xml theme={null}
<interserver_http_credentials>
    <user>admin</user>
    <password>111</password>
    <allow_empty>true</allow_empty>
</interserver_http_credentials>
```

在所有副本都配置完成后，将 `allow_empty` 设为 `false`，或删除此设置。这会强制使用新凭据进行身份验证。

如需更改现有凭据，请将用户名和密码移至 `interserver_http_credentials.old` 部分，并将 `user` 和 `password` 更新为新值。此时，服务器会使用新凭据连接其他副本，并接受使用新旧任一凭据建立的连接。

```xml theme={null}
<interserver_http_credentials>
    <user>admin</user>
    <password>222</password>
    <old>
        <user>admin</user>
        <password>111</password>
    </old>
    <old>
        <user>temp</user>
        <password>000</password>
    </old>
</interserver_http_credentials>
```

当所有副本都已应用新的凭据后，即可移除旧凭据。

## interserver\_http\_host

类型

String

默认值

无需重启即可更改

No

其他服务器可用于访问此服务器的主机名。

如果省略，则其定义方式与 `<hostname -f>` 命令相同。

可用于避免绑定到特定网络接口。

**示例**

```xml theme={null}
<interserver_http_host>example.clickhouse.com</interserver_http_host>
```

## interserver\_http\_port

类型

UInt64

默认值

0

无需重启即可更改

No

用于在 ClickHouse 服务器之间交换数据的端口。

**示例**

```xml theme={null}
<interserver_http_port>9009</interserver_http_port>
```
