

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# MSK Serverless 叢集的組態屬性
<a name="serverless-config"></a>

Amazon MSK 會為無伺服器叢集設定代理程式組態屬性。您無法變更這些代理程式組態屬性設定。不過，您可以設定或修改下列主題層級組態屬性。所有其他主題層級組態屬性都無法設定。


****  

| 組態屬性 | 預設 | 是否可編輯 | 允許值上限 | 
| --- | --- | --- | --- | 
| [cleanup.policy](https://kafka.apache.org/documentation/#topicconfigs_cleanup.policy) | 刪除 | 可以，但僅限於主題建立時 |  | 
|  [compression.type](https://kafka.apache.org/documentation/#topicconfigs_compression.type)  | 生產者 | 是 |  | 
|  [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)  | 250 GiB | 是 | 無限制；將其設定為 -1 可無限制保留 | 
|  [retention.ms](https://kafka.apache.org/documentation/#topicconfigs_retention.ms)  | 7 天 | 是 | 無限制；將其設定為 -1 可無限制保留 | 

若要設定或修改這些主題層級組態屬性，您可以使用 Apache Kafka 命令列工具。如需如何設定主題的詳細資訊和範例，請參閱官方 Apache Kafka 文件中的 [3.2 主題層級組態](https://kafka.apache.org/documentation/#topicconfigs)。

**注意**  
您無法修改 MSK Serverless 中主題的 segment.bytes 組態。不過，Kafka Streams 應用程式可能會嘗試使用 segment.bytes 組態值建立內部主題，這與 MSK Serverless 允許的內容不同。如需使用 MSK Serverless 設定 Kafka 串流的詳細資訊，請參閱 [搭配 MSK Express 代理程式和 MSK Serverless 使用 Kafka Streams](use-kafka-streams-express-brokers-msk-serverless.md)。

搭配 Amazon MSK Serverless 使用 Apache Kafka 命令列工具時，請確定您已完成 [Amazon MSK Serverless 入門文件](https://docs.aws.amazon.com/msk/latest/developerguide/create-serverless-cluster-client.html)的*在用戶端機器上設定 Apache Kafka 用戶端工具*一節中的步驟 1-4。此外，您必須在命令中包含 `--command-config client.properties` 參數。

例如，下列命令可用來修改 retention.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 伺服器字串>* 取代為 Amazon MSK Serverless 叢集的引導伺服器端點，並將 *<topic\$1name>* 取代為您要修改的主題名稱。

`--command-config client.properties` 參數可確保 Kafka 命令列工具使用適當的組態設定來與 Amazon MSK Serverless 叢集通訊。