Changing cluster settings
After creating a cluster, you can:
-
Increasing storage size (unavailable for non-replicated SSD storage).
-
Configure PostgreSQL servers according to the PostgreSQL documentation.
-
Move a cluster to another folder.
Note
For information about how to update the PostgreSQL cluster version, see PostgreSQL version upgrade.
Changing the host class
Note
Some PostgreSQL settings depend on the selected host class.
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click Edit cluster in the top panel.
- Under Host class, select the class for the PostgreSQL hosts.
- Click Save changes.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change the host class for the cluster:
-
View a description of the CLI's update cluster command:
yc managed-postgresql cluster update --help
-
Request a list of available host classes (the
ZONES
column specifies the availability zones where you can select the appropriate class):yc managed-postgresql resource-preset list
+-----------+--------------------------------+-------+----------+ | ID | ZONE IDS | CORES | MEMORY | +-----------+--------------------------------+-------+----------+ | s1.micro | ru-central1-a, ru-central1-b, | 2 | 8.0 GB | | | ru-central1-c | | | | ... | +-----------+--------------------------------+-------+----------+
-
Specify the class in the update cluster command:
yc managed-postgresql cluster update <cluster ID or name> \ --resource-preset <host class ID>
Managed Service for PostgreSQL will run the update host class command for the cluster.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating PostgreSQL clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.
-
In the Managed Service for PostgreSQL cluster description, change the
resource_preset_id
attribute value underconfig.resources
:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... config { resources { resource_preset_id = "<host class>" ... } } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm the update of resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Timeout limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Updating a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
Increasing storage size
Note
Some PostgreSQL settings depend on the storage size.
Make sure that:
- The required cluster doesn't use non-replicated SSD storage. You can't increase the size of non-replicated SSD storage.
- The cloud has sufficient quota to increase storage capacity. Open your cloud's Quotas page and make sure that under Managed Databases, there is space available in the HDD storage capacity or the SSD storage capacity lines.
To increase a cluster's storage size:
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click Edit cluster in the top panel.
- Under Storage size, specify the required value.
- Click Save changes.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To increase a cluster's storage size:
-
View a description of the CLI's update cluster command:
yc managed-postgresql cluster update --help
-
Specify the required amount of storage in the cluster update command (it must be at least as large as
disk_size
in the cluster properties):yc managed-postgresql cluster update <cluster ID or name> \ --disk-size <storage size in GB>
To increase a cluster's storage size:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating PostgreSQL clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.
-
In the Managed Service for PostgreSQL cluster description, change the
disk_size
attribute value underconfig.resources
:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... config { resources { disk_size = <storage size in GB> ... } } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm the update of resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Timeout limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Updating a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
To increase a cluster's storage size, use the API update method and pass in in the call:
-
The cluster ID in the
clusterId
parameter. -
New storage size in the
configSpec.postgresqlConfig_<version PostgreSQL>.resources.diskSize
parameter. -
List of cluster configuration fields to be changed in the
updateMask
parameter.Warning
This API method resets the values of all parameters of the object to update, which aren't passed explicitly in the request. To avoid this, in the
updateMask
parameter, list the settings you want to change (in a single line, separated by commas).
Changing PostgreSQL settings
You can change the DBMS settings of the hosts in your cluster.
Warning
- You can't change PostgreSQL settings using SQL commands.
- Some PostgreSQL settings depend on the selected host class or storage size.
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click Edit cluster in the top panel.
- Change the PostgreSQL settings by clicking Configure under DBMS settings.
- Click Save.
- Click Save changes.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change PostgreSQL server settings:
-
View the full list of settings specified for the cluster:
yc managed-postgresql cluster get <cluster ID or name> --full
-
View a description of the CLI's update cluster configuration command:
yc managed-postgresql cluster update-config --help
-
Set the required parameter values:
All supported parameters are listed in the request format for the update method, in the
postgresqlConfig_<version PostgreSQL>
field. To specify a parameter name in the CLI call, convert the name fromlowerCamelCase
tosnake_case
. For example, themaxPreparedTransactions
parameter from an API call should be converted tomax_prepared_transactions
for the CLI command:yc managed-postgresql cluster update-config <cluster ID or name> \ --set <parameter1 name>=<value1>,<parameter2 name>=<value2>,...
Managed Service for PostgreSQL runs the update cluster settings operation.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating PostgreSQL clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.
-
In the Managed Service for PostgreSQL cluster description, change the values of the parameters under
config.postgresql_config
. If there is no such block, create one:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... config { ... postgresql_config = { max_connections = <max. number of connections> enable_parallel_hash = <true or false> vacuum_cleanup_index_scale_factor = <number 0 to 1> ... } } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm the update of resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Timeout limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Updating a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
Use the API update method and pass the requisite values in the configSpec.postgresqlConfig_<version>.config
parameter.
Changing additional cluster settings
-
Go to the folder page and select Managed Service for PostgreSQL.
-
Select the cluster and click Edit cluster in the top panel.
-
Change additional cluster settings:
-
Backup start time (UTC): UTC time when you want to start creating a cluster backup (in 24-hour format). If the time is not set, the backup will start at 22:00 UTC.
-
Retention period for automatic backups, days: The period to store the automatically created backups. If an automatic backup expires, it is deleted. The default is 7 days. This feature is in the Preview stage. For more information, see Backups.
Changing the retention period affects both new automatic backups and existing backups. For example, the initial retention period was 7 days. The remaining lifetime for a backup with this period is 1 day. When the retention period increases to 9 days, the remaining lifetime for this backup is 3 days.
-
Maintenance window: Settings for the maintenance window:
- To enable maintenance at any time, select arbitrary (default).
- To specify the preferred maintenance start time, select by schedule and specify the desired day of the week and UTC hour. For example, you can choose a time when cluster load is lightest.
Maintenance operations are carried out both on enabled and disabled clusters. They may include updating the DBMS version, applying patches, and so on.
-
Access from DataLens : Enable this option to be able to analyze data from the cluster in Yandex DataLens. For more information about setting up a connection, see Connecting to DataLens.
-
Access from management console: Enable this option to be able to run SQL queries against a cluster's databases from the Yandex Cloud management console.
-
Access from Serverless: Enable this option to allow cluster access from Yandex Cloud Functions. For more detail on setting up access, see the Cloud Functions.
-
Statistics sampling: Enable this option to use the Performance diagnostics tool in the cluster. This feature is in the Preview stage.
-
Autofailover: Enable this option so that when the master host changes, the replication source for every replica host is automatically switched over to the new master host. To learn more, see Replication.
-
Connection pooler mode: Choose one of connection pooler modes.
-
Deletion protection: Manages cluster protection from accidental deletion by a user.
Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
-
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change additional cluster settings:
-
View a description of the CLI's update cluster command:
yc managed-postgresql cluster update --help
-
Run the command with a list of settings to update:
yc managed-postgresql cluster update <cluster ID or name> \ --backup-window-start <backup start time> \ --datalens-access=<true or false> \ --maintenance-window type=<maintenance type: anytime or weekly>,` `day=<day of week for weekly>,` `hour=<hour for weekly> \ --websql-access=<true or false> \ --deletion-protection=<cluster deletion protection: true or false> \ --connection-pooling-mode=<connection manager mode> \ --serverless-access=<true or false>
You can change the following settings:
--backup-window-start
: The cluster backup start time, set in UTC formatHH:MM:SS
. If the time is not set, the backup will start at 22:00 UTC.
*--datalens-access
: Enables DataLens access. Default value: false
. For more information about setting up a connection, see Connecting to DataLens.
-
--maintenance-window
: Settings for the maintenance window (including disabled clusters):type
: Maintenance type:anytime
: Anytime.weekly
: By schedule.
day
: Day of the week for theweekly
type inDDD
format. For example,MON
.hour
: Hour of the day for theweekly
type in theHH
format. For example,21
.
-
--websql-access
: Enables SQL queries to be run from the management console. Default value:false
. -
--serverless-access
: Enables cluster access from Yandex Cloud Functions. Default value:false
. For more detail on setting up access, see the Cloud Functions. -
--connection-pooling-mode
: Specifies the connection pooler mode:SESSION
,TRANSACTION
, orSTATEMENT
. -
--deletion-protection
: Cluster protection from accidental deletion by a user.Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
You can retrieve the cluster name with a list of clusters in the folder.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating PostgreSQL clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.
-
To change the backup start time, add a block named
config.backup_window_start
to the Managed Service for PostgreSQL cluster description.resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... config { backup_window_start { hours = <backup start hour> minutes = <backup start minute> } ... } }
-
To allow access from Yandex DataLens and execution of SQL queries from the management console, change the values of the appropriate fields in the
config.access
block:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... config { access { data_lens = <access from DataLens: true or false> web_sql = <execution of SQL queries from management console: true or false> ... } ... }
-
To change the connection pooler mode, add the
config.pooler_config
section to the Managed Service for PostgreSQL cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... config { pooler_config { pool_discard = <Odyssey pool_discard parameter: true or false> pooling_mode = "<operation mode: SESSION, TRANSACTION, or STATEMENT>" } ... } }
-
To set up the maintenance window (for example, for disabled clusters), add the
maintenance_window
section to the cluster description:resource "yandex_mdb_kafka_cluster" "<cluster name>" { ... maintenance_window { type = <maintenance type: ANYTIME or WEEKLY> day = <day of the week for the WEEKLY type> hour = <hour of the day for the WEEKLY type> } ... }
Where:
type
: Maintenance type:anytime
: Anytime.weekly
: By schedule.
day
: Day of the week for theweekly
type inDDD
format. For example,MON
.hour
: Hour of the day for theweekly
type in theHH
format. For example,21
.
-
To enable cluster protection against accidental deletion by a user of your cloud, add the
deletion_protection
field set totrue
to your cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... deletion_protection = <protect cluster from deletion: true or false> }
Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm the update of resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Timeout limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Updating a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
Use the update API method and pass the following in the request:
-
The cluster ID in the
clusterId
parameter. -
Settings for access from other services and access to SQL queries from the management console in the
configSpec.access
parameter. -
Backup window settings in the
configSpec.backupWindowStart
parameter. -
Connection pooler mode in the
configSpec.poolerConfig.poolingMode
parameter. -
Settings for the maintenance window (including for disabled clusters) in the
maintenanceWindow
parameter. -
Cluster deletion protection settings in the
deletionProtection
parameter.Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
-
List of cluster configuration fields to be changed in the
updateMask
parameter.
You can get the cluster ID with a list of clusters in the folder.
Warning
This API method resets any cluster settings that aren't passed explicitly in the request to their defaults. To avoid this, be sure to pass the names of the fields to be changed in the updateMask
parameter.
To allow cluster access from Yandex Cloud Functions, pass true
for the configSpec.access.serverless
parameter. For more detail on setting up access, see the Cloud Functions.
Switching the master
In a failover PostgreSQL cluster with multiple hosts, you can switch the master role from the current master host to the cluster's replica host. After this operation, the current master host becomes the replica host of the new master.
Specifics of switching master hosts in Managed Service for PostgreSQL
- You can't switch the master host to a replica that the source of the replication thread is explicitly given for.
- If you don't specify the replica host name explicitly, the master host will switch to one of the quorum replicas.
For more information, see Replication.
To switch the master:
- Go to the folder page and select Managed Service for PostgreSQL.
- Click on the name of the cluster you want and select the Hosts tab.
- Click Switch master.
- To switch the master to one of the quorum replicas, leave the Choose master host automatically option enabled.
- To switch the master to a specific replica, disable the Choose master host automatically option and then select the desired replica from the drop-down list.
- Click Switch.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Run the command:
yc managed-postgresql cluster start-failover <cluster ID or name> \
--host <replica host name>
You can request the replica host name with a list of cluster hosts and the cluster name with a list of clusters in the folder.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating PostgreSQL clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.
-
In the
host_master_name
parameter, specify the name of the replica host to switch to.resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... host_master_name = "<replica host name: the name attribute of the appropriate host block>" } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm the update of resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Timeout limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Updating a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
Use the API startFailover method and pass the following in the request:
- In the
clusterId
parameter, the ID of the cluster where you want to switch the master. To find out the cluster ID, get a list of clusters in the folder. - In the
hostName
parameter, the name of the replica host to switch to. To find out the name, request a list of hosts in the cluster.
Moving a cluster
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the icon to the right of the cluster you want to move.
- Click Move.
- Select the folder you want to move the cluster to.
- Click Move.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To move a cluster:
-
View a description of the CLI move cluster command:
yc managed-postgresql cluster move --help
-
Specify the destination folder in the move cluster command:
yc managed-postgresql cluster move <cluster ID> \ --destination-folder-name=<destination folder name>
You can get the cluster ID with a list of clusters in the folder.
Use the move API method and pass the following in the query:
- The cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - The ID of the destination folder in the
destinationFolderId
parameter.
Changing security groups
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click Edit cluster in the top panel.
- Under Network settings, select security groups for cluster network traffic.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To edit the list of security groups for your cluster:
-
View a description of the CLI's update cluster command:
yc managed-postgresql cluster update --help
-
Specify the security groups in the update cluster command:
yc managed-postgresql cluster update <cluster ID or name> \ --security-group-ids <security group list>
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating PostgreSQL clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.
-
Change the value of the
security_group_ids
parameter in the cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... security_group_ids = [ <list of cluster security groups> ] }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm the update of resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Timeout limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Updating a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
Use the update API method and pass the following in the request:
- The cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - The list of groups in the
securityGroupIds
parameter. - The list of settings to update in the
updateMask
parameter. If this parameter is omitted, the API method resets any cluster settings that aren't explicitly specified in the request to their default values.
Warning
You may need to additionally set up security groups to connect to the cluster.