Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Managed Service for PostgreSQL
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Connecting to a database
    • Stopping and starting clusters
    • SQL queries in the management console
    • Updating the PostgreSQL version
    • Changing cluster and database settings
    • Connecting to DataLens
    • Managing PostgreSQL hosts
    • Managing databases
    • Managing PostgreSQL extensions
    • Managing database users
    • Assigning privileges and roles
    • Managing backups
    • Deleting clusters
    • Performance diagnostics
    • Monitoring the state of clusters and hosts
  • Practical guidelines
    • Creating PostgreSQL clusters for 1C
    • Performance analysis and tuning
    • Replication and migration
      • Logical PostgreSQL replication
      • Migrating databases to Managed Service for PostgreSQL
      • Migrating databases from Managed Service for PostgreSQL
      • Creating a logical replica of Amazon RDS for PostgreSQL in Managed Service for PostgreSQL
    • Delivering data using Debezium
  • Concepts
    • Relationships between service resources
    • Host classes
      • Active host classes
      • Archive
        • Before June 1, 2020
      • Using deprecated host classes
    • Network in Yandex Managed Service for PostgreSQL
    • Quotas and limits
    • Storage in Managed Service for PostgreSQL
    • Backups
    • Assigning roles
    • Managing connections
    • Replication
    • Maintenance
    • Supported clients
    • PostgreSQL settings
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January, 1 to March 1, 2019
      • From March 1, 2019 to February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • BackupService
      • ClusterService
      • DatabaseService
      • ResourcePresetService
      • UserService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • backup
        • create
        • delete
        • deleteHosts
        • get
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • move
        • rescheduleMaintenance
        • restore
        • start
        • startFailover
        • stop
        • streamLogs
        • update
        • updateHosts
      • Database
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Operation
        • Overview
        • get
  • Revision history
  • Questions and answers
    • General questions
    • Connection
    • Updating clusters
    • Cluster configuration
    • Moving and restoring a cluster
    • Monitoring and logs
    • All questions on one page
  1. Step-by-step instructions
  2. Changing cluster and database settings

Changing cluster settings

Written by
Yandex Cloud
  • Changing the host class
  • Increasing storage size
  • Changing PostgreSQL settings
  • Changing additional cluster settings
  • Switching the master
  • Moving a cluster
  • Changing security groups

After creating a cluster, you can:

  • Change the host class.

  • Increasing storage size  (unavailable for non-replicated SSD storage).

  • Configure PostgreSQL servers according to the PostgreSQL documentation.

  • Changing additional cluster settings.

  • Manually switch the master in the cluster.

  • Move a cluster to another folder.

  • Change cluster security groups.

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.

Management console
CLI
Terraform
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the cluster and click Edit cluster in the top panel.
  3. Under Host class, select the class for the PostgreSQL hosts.
  4. 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:

  1. View a description of the CLI's update cluster command:

    yc managed-postgresql cluster update --help
    
  2. 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                  |       |          |
    | ...                                                           |
    +-----------+--------------------------------+-------+----------+
    
  3. 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.

  1. 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.

  2. In the Managed Service for PostgreSQL cluster description, change the resource_preset_id attribute value under config.resources:

    resource "yandex_mdb_postgresql_cluster" "<cluster name>" {
      ...
      config {
        resources {
          resource_preset_id = "<host class>"
          ...
        }
      }
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. 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 value in the configSpec.resources.resourcePresetId parameter.

To request a list of supported values, use the list method for ResourcePreset resources.

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.
Management console
CLI
Terraform
API

To increase a cluster's storage size:

  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the cluster and click Edit cluster in the top panel.
  3. Under Storage size, specify the required value.
  4. 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:

  1. View a description of the CLI's update cluster command:

    yc managed-postgresql cluster update --help
    
  2. 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:

  1. 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.

  2. In the Managed Service for PostgreSQL cluster description, change the disk_size attribute value under config.resources:

    resource "yandex_mdb_postgresql_cluster" "<cluster name>" {
      ...
      config {
        resources {
          disk_size = <storage size in GB>
          ...
        }
      }
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. 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.
Management console
CLI
Terraform
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the cluster and click Edit cluster in the top panel.
  3. Change the PostgreSQL settings by clicking Configure under DBMS settings.
  4. Click Save.
  5. 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:

  1. View the full list of settings specified for the cluster:

    yc managed-postgresql cluster get <cluster ID or name> --full
    
  2. View a description of the CLI's update cluster configuration command:

    yc managed-postgresql cluster update-config --help
    
  3. 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 from lowerCamelCase to snake_case. For example, the maxPreparedTransactions parameter from an API call should be converted to max_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.

  1. 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.

  2. 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>
          ...
        }
      }
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. 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

Management console
CLI
Terraform
API
  1. Go to the folder page and select Managed Service for PostgreSQL.

  2. Select the cluster and click Edit cluster in the top panel.

  3. 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:

  1. View a description of the CLI's update cluster command:

    yc managed-postgresql cluster update --help
    
  2. 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 format HH: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 the weekly type in DDD format. For example, MON.
    • hour: Hour of the day for the weekly type in the HH 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, or STATEMENT.

  • --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.

  1. 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.

  2. 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>
        }
        ...
      }
    }
    
  3. 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>
          ...
      }
      ...
    }
    
  4. 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>"
        }
        ...
      }
    }
    
  5. 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 the weekly type in DDD format. For example, MON.
    • hour: Hour of the day for the weekly type in the HH format. For example, 21.
  6. To enable cluster protection against accidental deletion by a user of your cloud, add the deletion_protection field set to true 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.

  7. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  8. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. 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

  1. You can't switch the master host to a replica that the source of the replication thread is explicitly given for.
  2. 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:

Management console
CLI
Terraform
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Click on the name of the cluster you want and select the Hosts tab.
  3. Click Switch master.
  4. To switch the master to one of the quorum replicas, leave the Choose master host automatically option enabled.
  5. 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.
  6. 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.

  1. 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.

  2. 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>"
      }
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. 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:

  1. 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.
  2. 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

Management console
CLI
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Click the icon to the right of the cluster you want to move.
  3. Click Move.
  4. Select the folder you want to move the cluster to.
  5. 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:

  1. View a description of the CLI move cluster command:

    yc managed-postgresql cluster move --help
    
  2. 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

Management console
CLI
Terraform
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  2. Select the cluster and click Edit cluster in the top panel.
  3. 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:

  1. View a description of the CLI's update cluster command:

    yc managed-postgresql cluster update --help
    
  2. Specify the security groups in the update cluster command:

    yc managed-postgresql cluster update <cluster ID or name> \
        --security-group-ids <security group list>
    
  1. 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.

  2. 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> ]
    }
    
  3. Make sure the settings are correct.

    1. Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.

    2. Run the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

  4. Confirm the update of resources.

    1. 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.

    2. If you are happy with the planned changes, apply them:

      1. Run the command:

        terraform apply
        
      2. Confirm the update of resources.

      3. 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.

Was the article helpful?

Language / Region
© 2022 Yandex.Cloud LLC
In this article:
  • Changing the host class
  • Increasing storage size
  • Changing PostgreSQL settings
  • Changing additional cluster settings
  • Switching the master
  • Moving a cluster
  • Changing security groups