- 適用於在 VM 上執行 AlloyDB Omni 的環境的 - postgresql.conf檔案。
- 在Kubernetes 叢集上執行 AlloyDB Omni 的環境適用的資料庫叢集資訊清單。 
更新容器化 AlloyDB Omni 中的參數
在 VM 上執行的 AlloyDB Omni 中,您可以編輯 postgresql.conf 檔案來更新參數,如下所示:
- 找出 AlloyDB Omni 安裝作業的 - postgresql.conf設定檔。
- 使用文字編輯器在 - postgresql.conf中新增或更新資料庫旗標。- 舉例來說,如要強制執行密碼到期,請在 - postgresql.conf檔案中設定下列旗標:- password.enforce_expiration = ON
- 新增或編輯資料庫標記後,請重新載入 - postgresql.conf檔案,變更才會生效。舉例來說,如果您使用 Docker 安裝 AlloyDB Omni,請執行下列指令重新啟動 Docker 執行個體,並重新載入- postgresql.conf:- docker restart CONTAINER-NAME
詳情請參閱 PostgreSQL 說明文件中的「設定參數」。
在 Kubernetes 叢集上更新 AlloyDB Omni 中的參數
您可以使用資料庫叢集資訊清單的 primarySpec 區段中的 parameters 欄位,設定資料庫參數:
spec:
  primarySpec:
    parameters:
      "PARAMETER_NAME": "PARAMETER_VALUE"
      ...
更改下列內容:
- PARAMETER_NAME:參數名稱,例如- autovacuum。
- PARAMETER_VALUE:參數的值,例如- off。
部分參數需要重新啟動叢集,變更才會生效。您可以從 pg_catalog.pg_settings 取得需要重新啟動的參數清單。任何含有 pg_catalog.pg_settings.context = 'postmaster' 的參數都需要重新啟動。
如要更新資料庫參數,請執行下列指令:
kubectl patch dbclusters.alloydbomni.dbadmin.goog dbcluster-sample -p '{"spec":{"primarySpec":{"parameters": {"PARAMETER_NAME": "PARAMETER_VALUE"}}}}' --type=merge參數設定位於 currentParameters 欄位的 status 部分。
如要查看資料庫參數,請執行下列指令:
kubectl get dbclusters.alloydbomni.dbadmin.goog dbcluster-sample -o jsonpath={.status.primary.currentParameters}輸出看起來類似以下內容:
{"autovacuum":"off","max_connections":"3000"}
如果 AlloyDB Omni 無法套用您在資料庫叢集資訊清單中要求使用的參數,則 currentParameters 欄位的值可能會與資訊清單中 parameters 欄位的值不同。舉例來說,您套用了不存在的參數,或是將字串值設為整數參數。