

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# MSK Serverless 集群的配置属性
<a name="serverless-config"></a>

Amazon MSK 会为无服务器集群设置代理配置属性。您无法更改这些代理配置属性设置。但是，您可以设置或修改以下主题级别的配置属性。所有其他主题级别的配置属性均不可配置。


****  

| 配置属性 | 默认 | 可编辑 | 允许的最大值 | 
| --- | --- | --- | --- | 
| [cleanup.policy](https://kafka.apache.org/documentation/#topicconfigs_cleanup.policy) | Delete | 是，但仅限于主题创建时 |  | 
|  [compression.type](https://kafka.apache.org/documentation/#topicconfigs_compression.type)  | Producer | 是 |  | 
|  [max.message.bytes](https://kafka.apache.org/documentation/#topicconfigs_max.message.bytes)  | 1048588 | 是 | 8388608 (8MiB) | 
|  [message.timestamp.difference.max.ms](https://kafka.apache.org/documentation/#topicconfigs_message.timestamp.difference.max.ms)  | long.max | 是 |  | 
|  [message.timestamp.type](https://kafka.apache.org/documentation/#topicconfigs_message.timestamp.type)  | CreateTime | 是 |  | 
|  [retention.bytes](https://kafka.apache.org/documentation/#topicconfigs_retention.bytes)  | 250GiB | 是 | 无限制；设置为 -1 可实现无限制保留 | 
|  [retention.ms](https://kafka.apache.org/documentation/#topicconfigs_retention.ms)  | 7 days | 是 | 无限制；设置为 -1 可实现无限制保留 | 

要设置或修改这些主题级别的配置属性，您可以使用 Apache Kafka 命令行工具。有关更多信息和如何设置它们的示例，请参阅官方 Apache Kafka 文档中的 [3.2 主题级配置](https://kafka.apache.org/documentation/#topicconfigs)。

**注意**  
在 MSK Serverless 中无法修改主题的 seg.bytes 配置。但是，Kafka Streams 应用程序可能会尝试创建一个 segment.bytes 配置值与 MSK Serverless 许可值不同的内部主题。有关使用 MSK Serverless 配置 Kafka Streams 的信息，请参阅[Kafka Streams 与 MSK 快速代理和 MSK Serverless 结合使用](use-kafka-streams-express-brokers-msk-serverless.md)。

将 Apache Kafka 命令行工具与 Amazon MSK Serverless 结合使用时，请确保已完成 [Amazon MSK Serverless 入门文档](https://docs.aws.amazon.com/msk/latest/developerguide/create-serverless-cluster-client.html)的*在客户端计算机上设置 Apache Kafka 客户端工具*部分中的步骤 1-4。此外，您必须在命令中包含 `--command-config client.properties` 参数。

例如，以下命令可用于修改r etention.bytes 主题配置属性以设置无限制保留：

```
<path-to-your-kafka-client-installation>/bin/kafka-configs.sh —bootstrap-server <bootstrap_server_string> —command-config client.properties --entity-type topics --entity-name <topic_name> --alter --add-config retention.bytes=-1
```

在此示例中，*<bootstrap server string>*替换为您的 Amazon MSK Serverless 集群的引导服务器终端节点，以及*<topic\$1name>*您要修改的主题名称。

`--command-config client.properties` 参数确保 Kafka 命令行工具使用适当的配置设置与您的 Amazon MSK Serverless 集群进行通信。