Database parameters, also known as Grand Unified Configuration (GUC) parameters, let you tune the performance and behavior of your AlloyDB Omni database cluster. For more information, see Setting parameters in the PostgreSQL documentation.
Before you begin
Before you configure database parameters, make sure that you have:
Configure database parameters
To configure database parameters, you use the parameters field within the
primarySpec section of your DBCluster resource specification.
Update the resource specification
Add the required parameters and their values to your DBCluster resource
specification:
DBCluster:
metadata:
name: CLUSTER_NAME
spec:
primarySpec:
# ... other settings ...
parameters:
max_wal_size: "MAX_WAL_SIZE"
max_connections: "MAX_CONNECTIONS_LIMIT"
Replace the following:
CLUSTER_NAME: name of your database cluster.MAX_WAL_SIZE: the maximum size the WAL can grow to between automatic WAL checkpoints, for example2GB.MAX_CONNECTIONS_LIMIT: maximum number of concurrent connections allowed to the database server, for example,200. Minimum supported value is50.
Supported parameters during cluster creation
You can configure the following database parameters (GUCs) in the DBCluster
resource specification during cluster creation:
log_connectionslog_disconnectionslog_hostnamelog_statementmax_connectionsmax_wal_sizehuge_pagestcp_keepalives_idletcp_keepalives_intervaltcp_keepalives_count
You cannot configure parameters, such as shared_buffers, that aren't
included in this list using the DBCluster specification. Instead, you must
update them manually after cluster creation.
Apply the configuration
Apply the changes using your preferred orchestrator interface.
Ansible
ansible-playbook -i DEPLOYMENT_SPECIFICATION DBCLUSTER_PLAYBOOK -e resource_spec=DBCLUSTER_SPECIFICATIONReplace the following variables:
DEPLOYMENT_SPECIFICATION: path to the deployment specification you created in Install AlloyDB Omni components.DBCLUSTER_PLAYBOOK: path to the playbook that you created for your database cluster.DBCLUSTER_SPECIFICATION: path to your cluster specification.
alloydbctl
alloydbctl apply -d DEPLOYMENT_SPECIFICATION -r DBCLUSTER_SPECIFICATIONReplace the following variables:
DEPLOYMENT_SPECIFICATION: path to the deployment specification you created in Install AlloyDB Omni components.DBCLUSTER_SPECIFICATION: path to your cluster specification.
Update database parameters after cluster creation
To update parameters after the cluster is created, you must manually modify the configuration files on your database nodes.
Update parameters in a high-availability cluster
To manually update database parameters in a high-availability (HA) cluster, complete the following steps:
If
availability.enableAutoFailoverandavailability.enableAutoHealare set totruein yourDBClusterspecification file, then set them tofalse.DBCluster: metadata: name: my-db-cluster spec: databaseVersion: 18.1.0 mode: "" availability: ... enableAutoFailover: false enableAutoHeal: false ...Apply the updated resource specification using your preferred interface.
On each database node, edit the
30startup.conffile in the following directory:DATA_DISK_PATH/18/db/postgresql.conf.d/.Replace
DATA_DISK_PATHwith the value from thepathfield of the disk namedDataDiskin yourDBClusterresource specification.Example DBCluster specification:
DBCluster: spec: primarySpec: resources: disks: - name: DataDisk path: /var/lib/alloydbomni/data # This is your DATA_DISK_PATHAdd or update your database parameter configurations in the
30startup.conffile. For more information, see PostgreSQL documentation.Restart the database service on all nodes:
sudo systemctl restart alloydbomni18If you modified the
availability.enableAutoFailoverandavailability.enableAutoHealfields in yourDBClusterresource specification, revert them to their original values and apply the changes.
Update parameters in a standalone cluster
To manually update database parameters in a standalone cluster, complete the following steps:
On the database node, update the
30startup.conffile in the following directory:DATA_DISK_PATH/18/db/postgresql.conf.d/.Replace
DATA_DISK_PATHwith the file system path defined for yourDataDiskin theDBClusterresource specification.Add or update your database parameter configurations in the
30startup.conffile.Restart the database service:
sudo systemctl restart alloydbomni18
Verify parameter changes
After applying the configuration, you can verify that the parameters are updated
using the SHOW command in psql:
SHOW PARAMETER_NAME;Replace PARAMETER_NAME
with the name of the parameter that you configured.