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.
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:
Disable automatic failover and heal triggers in your cluster specification:
- Check your
DBClusterresource specification for the values ofavailability.enableAutoFailoverandavailability.enableAutoHeal. - If either field is set to
true, update them tofalse. - Apply the updated resource specification using your preferred interface.
- Check your
On each database node, create or update the
50user.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 your database parameter configurations to the
50user.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, create or update the
50user.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 your database parameter configurations to the
50user.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.