PostgreSQL cluster maintenance
Yandex Managed Service for PostgreSQL cluster maintenance can be managed.
Getting a list of maintenances
- Navigate to the folder dashboard and select Managed Service for PostgreSQL.
- Click the cluster name and open the Technical maintenance tab.
To view maintenances with a particular status, click Status above the list of maintenances and select the status of interest from the drop-down menu. You can also find a maintenance by its ID or task name: use the box above the list of maintenances.
Getting cluster logs related to maintenance
- Navigate to the folder dashboard and select Managed Service for PostgreSQL.
- Click the cluster name and open the Technical maintenance tab.
- Click the maintenance ID you need.
- Click Task logs.
Moving scheduled maintenance
Maintenance jobs with the Planned status are scheduled for a particular date and time specified in the Start date column. You can move them to a new date and time if needed.
To move a maintenance to a new date and time:
- Navigate to the folder dashboard and select Managed Service for PostgreSQL.
- Click the cluster name and open the Technical maintenance tab.
- Click
to the right of the maintenance with the Planned status. - In the drop-down menu, select
Postpone. - In the window that opens:
- To move a maintenance forward to the next maintenance window, click Next window and then Reschedule.
- To move a maintenance forward or backward to a specific UTC date and time, click Choose date (UTC), then select a new date and time interval and click Reschedule.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To move a maintenance to a new date and time:
-
View the description of the CLI command to move maintenance:
yc managed-postgresql cluster reschedule-maintenance --help
-
To move a maintenance to the nearest window, run the command by specifying the
next-available-window
reschedule type. To move to a specific date and time, specify thespecific-time
reschedule type:yc managed-postgresql cluster reschedule-maintenance <cluster_name_or_ID> \ --reschedule-type <reschedule_type> \ --delayed-until <timestamp>
The timestamp must have one of the following formats:
- RFC-3339
- HH:MM:SS
- Number of hours and minutes by which to move the maintenance.
For example,
2006-01-02T15:04:05Z
,15:04:05
,2h
, or3h30m ago
. When selecting thenext-available-window
reschedule type, you do not need to specify--delayed-until
. - RFC-3339
You can get the cluster name with the list of clusters in the folder.
To move a maintenance to a new date and time:
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.rescheduleMaintenance method and run the following request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>:rescheduleMaintenance' \ --data '{ "rescheduleType": <reschedule_type>, "delayedUntil": <timestamp> }'
Where
rescheduleType
is the reschedule type, which can take one of these two values:NEXT_AVAILABLE_WINDOW
: Move the maintenance to the nearest window.SPECIFIC_TIME
: Move the maintenance to a specific date and time.
The timestamp must be in RFC-3339
format, e.g.,2006-01-02T15:04:05Z
. When selecting theNEXT_AVAILABLE_WINDOW
reschedule type, you do not need to specifydelayedUntil
.You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.RescheduleMaintenance call and run the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "reschedule_type": <reschedule_type>, "delayed_until": <timestamp> }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.postgresql.v1.ClusterService.RescheduleMaintenance
Where
reschedule_type
is the reschedule type, which can take one of these two values:NEXT_AVAILABLE_WINDOW
: Move the maintenance to the nearest window.SPECIFIC_TIME
: Move the maintenance to a specific date and time.
The timestamp must be in RFC-3339
format, e.g.,2006-01-02T15:04:05Z
. When selecting theNEXT_AVAILABLE_WINDOW
reschedule type, you do not need to specifydelayed_until
.You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
Performing scheduled maintenance immediately
If you need to, you can perform a maintenance with the Planned status immediately without waiting for the time specified in the Start date column.
To perform a scheduled cluster maintenance immediately:
- Navigate to the folder dashboard and select Managed Service for PostgreSQL.
- Click the cluster name and open the Technical maintenance tab.
- Click
to the right of the maintenance. - In the drop-down menu, select
Carry out now.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To perform a scheduled cluster maintenance immediately:
-
View the description of the CLI command to move maintenance:
yc managed-postgresql cluster reschedule-maintenance --help
-
Run this command with
immediate
for reschedule type:yc managed-postgresql cluster reschedule-maintenance <cluster_name_or_ID> \ --reschedule-type immediate
You can get the cluster name with the list of clusters in the folder.
To perform a scheduled cluster maintenance immediately:
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.rescheduleMaintenance method and run the following request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>:rescheduleMaintenance' \ --data '{ "rescheduleType": "IMMEDIATE" }'
You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.RescheduleMaintenance call and run the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "reschedule_type": "IMMEDIATE" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.postgresql.v1.ClusterService.RescheduleMaintenance
You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
Configuring a maintenance window
By default, maintenance can be scheduled to any time slot. You can select a particular day of week and hour for the maintenance. For example, you can specify the time when the cluster is least loaded.
Warning
Selecting a new maintenance interval will automatically cancel any scheduled maintenance not falling within the new interval.
- Navigate to the folder dashboard and select Managed Service for PostgreSQL.
- Click the cluster name and open the Technical maintenance tab.
- Click
Configure the maintenance window. - In the window that opens:
- To allow maintenance at any time, select arbitrary (default).
- To allow maintenance once a week at a particular time, select by schedule and specify the day of week and hour in UTC.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the CLI command for updating the maintenance window:
yc managed-postgresql cluster reschedule-maintenance --help
-
Run this command:
yc managed-postgresql cluster update <cluster_name_or_ID> \ --maintenance-window type=<maintenance_type>,` `day=<day_of_week>,` `hour=<hour>
Where
type
is the maintenance type:anytime
(default): Any time.weekly
: On a schedule. If setting this value, specify the day of week and the hour:day
: Day of week inDDD
format:MON
,TUE
,WED
,THU
,FRI
,SAT
, orSUN
.hour
: Hour (UTC) inHH
format:1
to24
.
You can get the cluster name with the list of clusters in the folder.
-
Open the current Terraform configuration file that defines your infrastructure.
For more information about creating this file, see Creating clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation
. -
To set up the maintenance window (for disabled clusters as well), add the
maintenance_window
section to the cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... maintenance_window { type = <maintenance_type> day = <day_of_week> hour = <hour> } ... }
Where:
type
: Maintenance type. The possible values include:anytime
: Anytime.weekly
: By schedule.
day
: Day of the week for theweekly
type inDDD
format, e.g.,MON
.hour
: Hour of the day for theweekly
type in theHH
format, e.g.,21
.
-
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validate
Terraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform plan
If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply
-
Confirm updating the resources.
-
Wait for the operation to complete.
-
Time limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Editing 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 } }
-
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.Update method and send the following request, e.g., via cURL
:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMask
parameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "maintenanceWindow", "maintenanceWindow": { "weeklyMaintenanceWindow": { "day": "<day_of_week>", "hour": "<hour>" } } }'
Where:
-
updateMask
: List of parameters to update as a single string, separated by commas.Only one parameter is provided in this case.
-
maintenanceWindow
: Maintenance window settings (including for disabled clusters). InmaintenanceWindow
, provide one of the two parameters:-
anytime
: Maintenance can be scheduled to any time slot. -
weeklyMaintenanceWindow
: Maintenance can be scheduled to selected day of week and time only:day
: Day of week inDDD
format:MON
,TUE
,WED
,THU
,FRI
,SAT
, orSUN
.hour
: Hour of day (UTC) inHH
format, from1
to24
.
-
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.Update call and send the following request, e.g., via gRPCurl
:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": ["maintenance_window"] }, "maintenance_window": { "weekly_maintenance_window": { "day": "<day_of_week>", "hour": "<hour>" } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.postgresql.v1.ClusterService.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings.Only one parameter is provided in this case.
-
maintenance_window
: Maintenance window settings (including for disabled clusters). Inmaintenance_window
, provide one of the two parameters:-
anytime
: Maintenance can be scheduled to any time slot. -
weekly_maintenance_window
: Maintenance can be scheduled to selected day of week and time only:day
: Day of week inDDD
format:MON
,TUE
,WED
,THU
,FRI
,SAT
, orSUN
.hour
: Hour of day (UTC) inHH
format, from1
to24
.
-
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.