您可以使用 GDC 控制台或 gdcloud CLI 變更下列資料庫叢集屬性:
- 管理員使用者的資料庫密碼
- 外部連線 (啟用/停用)
- 可用性層級
- 備份功能已啟用,以及備份保留天數
- 資料庫旗標
- 分配給資料庫叢集的 CPU、記憶體或儲存空間
如要瞭解如何修改屬性,請參閱與您要更新的屬性類型對應的工作流程:
控制台
高可用性
啟用或停用相同可用區高可用性。詳情請參閱「設定高可用性」一節。
資料保護
您可以啟用或停用所有資料庫叢集類型的資料保護功能:
- 前往「資料保護」,然後按一下「編輯」圖示 ,開啟資料保護設定表單。如果啟用自動備份功能,您也可以設定備份的保留時間。
- 變更完成後,按一下「Save」(儲存),即可將更新套用至資料庫叢集。
連線能力
無論資料庫叢集類型為何,您都可以選擇是否只允許從 GDC 專案內部存取資料庫叢集,或是否允許從專案外部存取:
- 前往「連線」,然後按一下「編輯」。
- 更新連線設定。
按一下 [Save] (儲存) 套用您的變更。
執行個體
所有資料庫叢集類型的主要執行個體屬性,都可以編輯:
- 前往「主要執行個體」,然後點選「編輯」圖示 。
選擇「高效能」、「標準」、「最低」或「自訂」設定。「自訂」選項可讓您選擇主要執行個體的 CPU 數量、記憶體和儲存空間。
更新主要執行個體的 CPU、記憶體或儲存空間時,必須重新啟動。選取「儲存並重新啟動」,套用變更。
無論資料庫叢集類型為何,您都可以透過這份表單新增、修改或移除資料庫旗標。可用的旗標組合由 GDC 預先決定。詳情請參閱「設定資料庫旗標」一節。
gdcloud
使用下列指令更新資料庫叢集:
gdcloud database clusters update CLUSTER_NAME [options]
將 CLUSTER_NAME 替換為要更新的資料庫叢集名稱。
如需完整選項清單,請參閱指令參考資料,或執行:
gdcloud database clusters update --help
API
資料保護
無論資料庫叢集類型為何,只要為該資料庫叢集建立 BackupPlan 資源,即可啟用資料保護功能。
apiVersion: postgresql.dbadmin.gdc.goog/v1
kind: BackupPlan
metadata:
name: DBCLUSTER_NAME-backupplan
namespace: USER_PROJECT
spec:
dbclusterRef: DBCLUSTER_NAME
backupRetainDays: RETENTION_DAYS
請替換下列變數:
DBCLUSTER_NAME:要啟用資料保護功能的資料庫叢集名稱。USER_PROJECT:要建立資料庫叢集的使用者專案名稱。RETENTION_DAYS:運算子保留這項備份的天數。必須是介於 1 至 90 之間的整數。
您也可以編輯對應的 BackupPlan 資源,設定資料保護設定,例如保留天數。
如要停用資料庫叢集的資料保護功能,請刪除先前建立的對應 BackupPlan 資源。
重設管理員使用者密碼
無論資料庫叢集類型為何,您都可以重設管理員使用者的資料庫密碼。
建立密碼 Secret。
apiVersion: v1 kind: Secret metadata: name: db-pw-DBCLUSTER_NAME namespace: USER_PROJECT type: Opaque data: DBCLUSTER_NAME: "BASE64_PASSWORD"修補 DBCluster。
kubectl patch dbcluster.postgresql.dbadmin.gdc.goog DBCLUSTER_NAME -p '{"spec":{"primarySpec": {"adminUser": {"passwordRef": {"name": "db-pw-DBCLUSTER_NAME"}}}}}' --type=merge -n USER_PROJECT
請替換下列變數:
DBCLUSTER_NAME:資料庫叢集的名稱。USER_PROJECT:要更新資料庫叢集的使用者專案名稱。BASE64_PASSWORD:資料庫管理員密碼的 base64 編碼。
新密碼約一分鐘後生效。
設定資料庫旗標
GDC 隨附的資料庫映像檔會採用預設設定。不過,您可以自訂預設資料庫引擎,滿足應用程式的需求。資料庫叢集提供預先定義的旗標,您可以使用 GDC 控制台或 gdcloud CLI 設定:
控制台
在導覽選單中,選取「Database Service」。
在資料庫叢集清單中,按一下要設定資料庫旗標的資料庫叢集。
在「資料庫叢集中的執行個體」部分,點選「編輯主要節點」。

在「旗標」部分,點選「新增資料庫旗標」。
選擇旗標並輸入值。如果輸入的值無效,GDC 控制台會提供操作說明,協助您滿足必要範圍或值類型。
按一下「完成」。
如要設定,請按一下「儲存」。部分旗標必須重新啟動資料庫叢集才會生效。在本案例中,請按一下「Save and Restart」(儲存並重新啟動)。
如要確認新旗標已設定,請返回資料庫叢集的「Instances in your database cluster」(資料庫叢集中的執行個體) 區段,確認新旗標和值是否顯示。
如要編輯資料庫旗標,請返回「Flags」(旗標) 專區,然後修改現有旗標。將滑鼠游標懸停在旗標元件上,然後按一下 「Delete」(刪除) 圖示,即可移除資料庫旗標。
gdcloud
您可以為叢集設定新的資料庫旗標,或將所有現有旗標重設為預設值:
如要為資料庫叢集設定資料庫旗標,請執行下列指令:
gdcloud database clusters update CLUSTER_NAME \ --database-flags DB_FLAGS更改下列內容:
CLUSTER_NAME:資料庫叢集的名稱。DB_FLAGS:以半形逗號分隔的資料庫旗標清單,用於在資料庫叢集中執行的資料庫上設定。每個資料庫旗標和值都會設為鍵/值組合。如要定義沒有值的旗標,可以在=字元後方不加上字串。
舉例來說,下列指令會為
test-db-cluster設定多個資料庫旗標:gdcloud database clusters update test-db-cluster \ --database-flags max_allowed_packet=55555,skip_grant_tables=,log_output=1如需可用資料庫旗標清單,請參閱「可用資料庫旗標」。
如要將所有資料庫旗標重設為預設設定,請執行下列指令:
gdcloud database clusters update CLUSTER_NAME --clear-database-flags將
CLUSTER_NAME替換為資料庫叢集名稱。
API
如要設定資料庫叢集的資料庫旗標,請執行下列指令:
kubectl patch dbcluster.postgresql.dbadmin.gdc.goog DBCLUSTER_NAME -p '{"spec":{"primarySpec": {"parameters": DB_FLAGS}}}' --type=merge -n USER_PROJECT請替換下列變數:
DBCLUSTER_NAME:資料庫叢集的名稱。USER_PROJECT:建立資料庫叢集的使用者專案名稱。DB_FLAGS:要新增或更新的資料庫設定參數。這應為 JSON 格式的鍵/值組合,其中鍵為資料庫參數名稱,值則為對應的設定。例如,下列指令會設定多個資料庫旗標:
"autovacuum": "on", "autovacuum_analyze_threshold": "2147483647", "dbs.enable_anon": "on"如需可用資料庫旗標清單,請參閱「可用資料庫旗標」。
如要將所有資料庫旗標重設為預設設定,請執行下列指令:
kubectl patch dbcluster.postgresql.dbadmin.gdc.goog DBCLUSTER_NAME --type=json -p='[{"op": "remove", "path": "/spec/primarySpec/parameters"}]' -n USER_PROJECT請替換下列變數:
DBCLUSTER_NAME:資料庫叢集的名稱。USER_PROJECT:建立資料庫叢集的使用者專案名稱。
可用的資料庫旗標
| 標記 | 範圍 | 類型 | 需要重新啟動 |
|---|---|---|---|
| cpu_tuple_cost | [0, 2147483647] | 浮點值 | FALSE |
| max_connections | [1, 262143] | 整數 | TRUE |
| temp_file_limit | [1048576, 2147483647] | 整數 | FALSE |
| log_min_duration_statement | [-1, 2147483647] | 整數 | FALSE |
| log_connections | on, off | 布林值 | FALSE |
| log_lock_waits | on, off | 布林值 | FALSE |
| log_disconnections | on, off | 布林值 | FALSE |
| log_checkpoints | on, off | 布林值 | FALSE |
| log_temp_files | [-1, 2147483647] | 整數 | FALSE |
| log_statement | none、ddl、mod、all | 列舉 | FALSE |
| pgaudit.log | read、write、function、role、ddl、misc、misc_set、all、none、-read、-write、-function、-role、-ddl、-misc、-misc_set、-all、-none | 重複的字串 | FALSE |
| work_mem | [64, 2147483647] | 整數 | FALSE |
| autovacuum | on, off | 布林值 | FALSE |
| maintenance_work_mem | [1024, 2147483647] | 整數 | FALSE |
| random_page_cost | [0, 2147483647] | 浮點值 | FALSE |
| log_min_messages | debug5、debug4、debug3、debug2、debug1、info、notice、warning、error、log、fatal、panic | 列舉 | FALSE |
| idle_in_transaction_session_timeout | [0, 2147483647] | 整數 | FALSE |
| max_wal_size | [2, 2147483647] | 整數 | FALSE |
| autovacuum_vacuum_scale_factor | [0, 100] | 浮點值 | FALSE |
| log_autovacuum_min_duration | [-1, 2147483647] | 整數 | FALSE |
| autovacuum_vacuum_cost_limit | [-1, 10000] | 整數 | FALSE |
| autovacuum_max_workers | [1, 262143] | 整數 | TRUE |
| autovacuum_analyze_scale_factor | [0, 100] | 浮點值 | FALSE |
| track_activity_query_size | [100, 1048576] | 整數 | TRUE |
| log_duration | on, off | 布林值 | FALSE |
| autovacuum_vacuum_cost_delay | [-1, 100] | 整數 | FALSE |
| checkpoint_completion_target | [0, 1] | 浮點值 | FALSE |
| log_statement_stats | on, off | 布林值 | FALSE |
| max_parallel_maintenance_workers | [0, 1024] | 整數 | FALSE |
| max_parallel_workers | [0, 1024] | 整數 | FALSE |
| max_parallel_workers_per_gather | [0, 1024] | 整數 | FALSE |
| max_worker_processes | [8, 4096] | 整數 | TRUE |
| log_min_error_statement | debug5、debug4、debug3、debug2、debug1、info、notice、warning、error、log、fatal、panic | 列舉 | FALSE |
| default_statistics_target | [1, 10000] | 整數 | FALSE |
| checkpoint_timeout | [30, 86400] | 整數 | FALSE |
| wal_buffers | [-1, 262143] | 整數 | TRUE |
| effective_cache_size | [1, 2147483647] | 整數 | FALSE |
| autovacuum_work_mem | [1, 2147483647] | 整數 | FALSE |
| log_hostname | on, off | 布林值 | FALSE |
| autovacuum_vacuum_threshold | [0, 2147483647] | 整數 | FALSE |
| autovacuum_naptime | [1, 2147483] | 整數 | FALSE |
| autovacuum_analyze_threshold | [0, 2147483647] | 整數 | FALSE |
| pgaudit.log_client | on, off | 布林值 | FALSE |
| pgaudit.log_parameter | on, off | 布林值 | FALSE |
| pgaudit.log_level | debug5、debug4、debug3、debug2、debug1、info、notice、warning、error、log | 列舉 | FALSE |
| pgaudit.log_relation | on, off | 布林值 | FALSE |
| pgaudit.log_catalog | on, off | 布林值 | FALSE |
| pgaudit.role | 字串 | FALSE | |
| autovacuum_freeze_max_age | [100000, 2000000000] | 整數 | TRUE |
| autovacuum_multixact_freeze_max_age | [100000, 2000000000] | 整數 | TRUE |
| pgaudit.log_statement_once | on, off | 布林值 | FALSE |
| anon.algorithm | 字串 | FALSE | |
| anon.maskschema | 字串 | FALSE | |
| anon.restrict_to_trusted_schemas | on, off | 布林值 | FALSE |
| anon.salt | 字串 | FALSE | |
| anon.sourceschema | 字串 | FALSE | |
| dbs.enable_anon | 布林值 | TRUE | |
| dbs.enable_pg_bigm | 布林值 | TRUE | |
| dbs.enable_pg_cron | 布林值 | TRUE | |
| dbs.enable_pg_hint_plan | 布林值 | TRUE | |
| dbs.enable_pg_wait_sampling | 布林值 | TRUE | |
| pg_bigm.enable_recheck | on, off | 布林值 | FALSE |
| pg_bigm.gin_key_limit | [0, 2147483647] | 整數 | FALSE |
| pg_bigm.similarity_limit | [0, 1] | 浮點值 | FALSE |
| pg_hint_plan.debug_print | off、on、detailed、verbose、0、1、2、3、no、yes、false、true | 列舉 | TRUE |
| pg_hint_plan.enable_hint | on, off | 布林值 | FALSE |
| pg_hint_plan.enable_hint_table | on, off | 布林值 | FALSE |
| pg_hint_plan.message_level | debug5、debug4、debug3、debug2、debug1、debug、info、notice、warning、error、log | 列舉 | FALSE |
| pg_hint_plan.parse_messages | debug5、debug4、debug3、debug2、debug1、debug、info、notice、warning、error、log | 列舉 | FALSE |
| pg_stat_statements.max | [100, 2147483647] | 整數 | TRUE |
| pg_stat_statements.save | on, off | 布林值 | FALSE |
| pg_stat_statements.track | none、top、all | 列舉 | FALSE |
| pg_stat_statements.track_utility | on, off | 布林值 | FALSE |
| pg_wait_sampling.history_period | [1, 2147483647] | 整數 | FALSE |
| pg_wait_sampling.history_size | [1, 2147483647] | 整數 | FALSE |
| pg_wait_sampling.profile_period | [1, 2147483647] | 整數 | FALSE |
| pg_wait_sampling.profile_pid | on, off | 布林值 | FALSE |
| pg_wait_sampling.profile_queries | on, off | 布林值 | FALSE |
| pglogical.batch_inserts | on, off | 布林值 | TRUE |
| pglogical.conflict_log_level | debug5、debug4、debug3、debug2、debug1、info、notice、warning、error、log、fatal、panic | 列舉 | FALSE |
| pglogical.conflict_resolution | error、apply_remote、keep_local、last_update_wins、first_update_wins | 列舉 | FALSE |
| pglogical.extra_connection_options | 字串 | FALSE | |
| pglogical.synchronous_commit | on, off | 布林值 | TRUE |
| pglogical.use_spi | on, off | 布林值 | TRUE |
| pgtt.enabled | on, off | 布林值 | FALSE |
| plv8.execution_timeout | [1, 65536] | 整數 | FALSE |
| plv8.memory_limit | [256, 3096] | 整數 | FALSE |
| plv8.start_proc | 字串 | FALSE | |
| rdkit.agent_FP_bit_ratio | [0, 3] | 浮點值 | FALSE |
| rdkit.avalon_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.dice_threshold | [0, 1] | 浮點值 | FALSE |
| rdkit.difference_FP_weight_agents | [-10, 10] | 整數 | FALSE |
| rdkit.difference_FP_weight_nonagents | [1, 20] | 整數 | FALSE |
| rdkit.do_chiral_sss | on, off | 布林值 | FALSE |
| rdkit.do_enhanced_stereo_sss | on, off | 布林值 | FALSE |
| rdkit.featmorgan_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.hashed_atompair_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.hashed_torsion_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.ignore_reaction_agents | on, off | 布林值 | FALSE |
| rdkit.init_reaction | on, off | 布林值 | FALSE |
| rdkit.layered_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.morgan_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.move_unmmapped_reactants_to_agents | on, off | 布林值 | FALSE |
| rdkit.rdkit_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.reaction_difference_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.reaction_difference_fp_type | [1, 3] | 整數 | FALSE |
| rdkit.reaction_sss_fp_size | [64, 9192] | 整數 | FALSE |
| rdkit.reaction_sss_fp_type | [1, 5] | 整數 | FALSE |
| rdkit.sss_fp_size | [64, 4096] | 整數 | FALSE |
| rdkit.tanimoto_threshold | [0, 1] | 浮點值 | FALSE |
| rdkit.threshold_unmapped_reactant_atoms | [0, 1] | 浮點值 | FALSE |
下表列出與供應商預設值不同的旗標預設值:
| 標記 | 值/公式 | |
|---|---|---|
| shared_buffers | 1/3 * totalMemory(MiB) | |
| max_wal_size | 1504MB | |
| max_connections | 總記憶體 >= ? | 值 |
| 120 GB | 1000 | |
| 60 GB | 800 | |
| 30 GB | 600 | |
| 15 GB | 500 | |
| 7.5 GB | 400 | |
| 6GB | 200 | |
| 3.75 GB | 100 | |
| 1.7GB | 50 | |
| 0 | 25 | |
| effective_cache_size | 2/5 * totalMemory | |
| temp_file_limit | 1/10 * storageSize | |
| log_connections | 開啟 | |
| log_disconnections | 開啟 | |
| pgaudit.log | all, -misc | |
| log_hostname | 開啟 | |
| pgaudit.log_parameter | 開啟 | |