Updating MySQL® cluster settings
After creating a cluster, you can:
-
Warning
You cannot change MySQL® settings using SQL commands.
-
Move the cluster to another folder.
Learn more about other cluster updates:
Changing the host class
The choice of a host class in Managed Service for MySQL® clusters is limited by the CPU and RAM quotas available to DB clusters in your cloud. To check the resources currently in use, open the Quotas
Note
Some MySQL® settings depend on the selected host class.
When changing the host class:
- Your single-host cluster will be unavailable for a few minutes with database connections terminated.
- Your multi-host cluster will get a new master host. Its hosts will be stopped and updated one by one. Once stopped, a host will be unavailable for a few minutes.
- Using a special FQDN does not guarantee a stable database connection: user sessions may be terminated.
We recommend changing the host class only when your cluster has no active workload.
- Navigate to the folder dashboard
and select Managed Service for MySQL. - Select the cluster and click Edit in the top panel.
- To change the class of MySQL® hosts, under Host class, select the required class.
- Click Save changes.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To change the host class for a cluster:
-
View the description of the CLI command for updating a cluster:
yc managed-mysql cluster update --help -
Get the list of available host classes (the
ZONE IDScolumn specifies the availability zones where you can select the appropriate class):yc managed-mysql resource-preset listResult:
+-----------+--------------------------------+-------+----------+ | ID | ZONE IDS | CORES | MEMORY | +-----------+--------------------------------+-------+----------+ | s1.micro | ru-central1-a, ru-central1-b, | 2 | 8.0 GB | | | ru-central1-d | | | | ... | +-----------+--------------------------------+-------+----------+ -
Specify the class in the update cluster command:
yc managed-mysql cluster update <cluster_name_or_ID> --resource-preset <class_ID>Managed Service for MySQL® will run the update host class command for the cluster.
-
Open the current Terraform configuration file describing your infrastructure.
For more information about creating this file, see this guide.
-
In the Managed Service for MySQL® cluster description, edit the
resource_preset_idparameter underresources:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... resources { resource_preset_id = "<host_class>" ... } } -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf 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.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 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_mysql_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 place it in an 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
updateMaskparameter 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-mysql/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.resources.resourcePresetId", "configSpec": { "resources": { "resourcePresetId": "<host_class>" } } }'Where:
-
updateMask: Comma-separated list of settings you want to update.Here, we provide only one setting.
-
configSpec.resources.resourcePresetId: New host class.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, 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_maskparameter 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/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.resources.resource_preset_id" ] }, "config_spec": { "resources": { "resource_preset_id": "<host_class>" } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array ofpaths[]strings.Here, we provide only one setting.
-
config_spec.resources.resource_preset_id: New host class.
You can get the cluster ID from the folder’s cluster list.
-
-
View the server response to make sure your request was successful.
Change the disk type and increase the storage size
Make sure the cloud has enough quota to increase the storage size. Open the cloud's Quotas
To change the disk type and increase the storage size for a cluster:
-
Navigate to the folder dashboard
and select Managed Service for MySQL. -
Select the cluster and click Edit in the top panel.
-
Under Storage size:
- Select the disk type.
- Specify the required disk size.
-
Click Save changes.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To change the disk type and increase the storage size for a cluster:
-
View the description of the CLI command for updating a cluster:
yc managed-mysql cluster update --help -
Specify the disk type and required storage size in the cluster update command (at least as large as
disk_sizein the cluster properties):yc managed-mysql cluster update <cluster_name_or_ID> \ --disk-type <disk_type> \ --disk-size <storage_size_in_GB>
To change the disk type and increase the storage size for a cluster:
-
Open the current Terraform configuration file describing your infrastructure.
For more information about creating this file, see this guide.
-
Under
resources, change thedisk_type_idanddisk_sizeparameter values:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... resources { disk_type_id = "<disk_type>" disk_size = <storage_size_in_GB> ... } } -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf 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.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 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_mysql_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 place it in an 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
updateMaskparameter 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-mysql/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.resources.diskTypeId,configSpec.resources.diskSize", "configSpec": { "resources": { "diskTypeId": "<disk_type>", "diskSize": "<storage_size_in_bytes>" } } }'Where:
-
updateMask: Comma-separated list of settings you want to update. -
configSpec.resources: Storage parameters:diskTypeId: Disk type.diskSize: New storage size in bytes.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, 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_maskparameter 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/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.resources.disk_type_id", "config_spec.resources.disk_size" ] }, "config_spec": { "resources": { "disk_type_id": "<disk_type>", "disk_size": "<storage_size_in_bytes>" } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array ofpaths[]strings. -
config_spec.resources: Storage parameters:disk_type_id: Disk type.disk_size: New storage size in bytes.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
Changing MySQL® settings
Note
Some MySQL® settings depend on the selected host class.
- Navigate to the folder dashboard
and select Managed Service for MySQL. - Select the cluster and click Edit in the top panel.
- Configure the MySQL® settings by clicking Settings under DBMS settings.
- Click Save.
- Click Save changes.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To update the MySQL® settings:
-
View the description of the CLI command to update the cluster configuration:
yc managed-mysql cluster update-config --help -
Set the required parameter values.
All supported parameters are listed in the request format for the update method, in the
mysql_config_5_7field. To specify a parameter name in the CLI call, convert its name fromlowerCamelCase
tosnake_case
. For example, convert thelogMinDurationStatementparameter from an API request tolog_min_duration_statementfor the CLI command:yc managed-mysql cluster update-config <cluster_name> --set log_min_duration_statement=100,<parameter_name>=<value>,...Managed Service for MySQL® runs the update cluster settings operation.
-
Open the current Terraform configuration file describing your infrastructure.
For more information about creating this file, see this guide.
-
In the Managed Service for MySQL® cluster description, add or update the DBMS settings under
mysql_config:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... mysql_config = { <MySQL®_setting_name> = <value> ... } } -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf 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.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 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_mysql_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 place it in an 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
updateMaskparameter 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-mysql/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.mysqlConfig_<MySQL®_version>", "configSpec": { "mysqlConfig_<MySQL®_version>": { "<setting_1>": "<value_1>", "<setting_2>": "<value_2>", ... "<setting_N>": "<value_N>" } } }'Where:
-
updateMask: Comma-separated list of settings you want to update.Here, we provide only one setting.
-
configSpec.mysqlConfig_<MySQL®_version>: MySQL® settings. Use a separate line for each setting; separate them by commas.See the method description for the list of MySQL® versions available for the parameter. See Cluster-level DBMS settings for a description and possible values for each setting.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, 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_maskparameter 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/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.mysql_config_<MySQL®_version>" ] }, "config_spec": { "mysql_config_<MySQL®_version>": { "<setting_1>": "<value_1>", "<setting_2>": "<value_2>", ... "<setting_N>": "<value_N>" } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array ofpaths[]strings.Here, we provide only one setting.
-
configSpec.mysqlConfig_<MySQL®_version>: MySQL® settings. Use a separate line for each setting; separate them by commas.See the method description for the list of MySQL® versions available for the parameter. See Cluster-level DBMS settings for a description and possible values for each setting.
You can get the cluster ID from the folder’s cluster list.
-
-
Check the server response to make sure your request was successful.
For more information on how to update the MySQL® settings, see FAQ.
Changing additional cluster settings
-
Navigate to the folder dashboard
and select Managed Service for MySQL. -
Select the cluster and click Edit in the top panel.
-
Change additional cluster settings:
-
Automatic increase of storage size
-
Select In the maintenance window when full at more than and specify the of the current size is full percentage at which the storage will be increased in the next maintenance window.
-
Select Immediately when full at more than and specify the of the current size is full percentage at which the storage will be increased immediately.
-
In the Maximum storage size field, specify the storage size limit for automatic storage size increase.
Warning
- Automatic increase of storage size is not supported on dedicated hosts.
- If you choose to increase storage size during a maintenance window, set the maintenance window schedule.
-
-
Backup start time (UTC): Time interval during which the cluster backup starts. Time is specified in 24-hour UTC format. The default time is
22:00 - 23:00UTC. -
Retention period for automatic backups, days
Automatic backups will be stored for this many days.
-
Maintenance window: Maintenance window settings:
- 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 the cluster is least loaded.
Maintenance operations are carried out both on enabled and disabled clusters. They may include updating the DBMS, applying patches, and so on.
-
DataLens access: Enables you to analyze cluster data in Yandex DataLens.
For more information about setting up a connection, see Connecting to DataLens.
-
WebSQL access: Enables SQL queries against cluster databases from the Yandex Cloud management console using Yandex WebSQL.
-
Yandex Query access: Enables YQL queries against cluster databases from Yandex Query. This feature is at the Preview stage. The default value is
false. -
Statistics sampling: Enable this option to use the Performance diagnostics tool in the cluster.
-
Deletion protection: Manages cluster protection against accidental deletion.
Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To change additional cluster settings:
-
View the description of the CLI command for updating a cluster:
yc managed-mysql cluster update --help -
Run the following command with the list of settings to update:
yc managed-mysql cluster update <cluster_name_or_ID> \ --backup-window-start <backup_start_time> \ --backup-retain-period-days=<backup_retention_period> \ --datalens-access=<true_or_false> \ --websql-access=<true_or_false> \ --yandexquery-access=<true_or_false> \ --disk-size-autoscaling disk-size-limit=<maximum_storage_size_in_GB>,` `planned-usage-threshold=<threshold_for_scheduled_increase_in_percent>,` `emergency-usage-threshold=<threshold_for_immediate_increase_in_percent> \ --maintenance-window type=<maintenance_type>,` `day=<day_of_week>,` `hour=<hour> \ --deletion-protection \ --performance-diagnostics enabled=true,` `sessions-sampling-interval=<session_sampling_interval>,` `statements-sampling-interval=<statement_sampling_interval>
You can update 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.
-
--backup-retain-period-days: Automatic backup retention period, in days. The valid values range from7to60. The default value is7. -
--datalens-access: Enables access to the cluster from DataLens. The default value isfalse. For more information about setting up a connection, see Connecting to a MySQL® cluster from DataLens. -
--websql-access: Enables SQL queries against cluster databases from the Yandex Cloud management console using Yandex WebSQL. The default value isfalse. -
--yandexquery-access: Enables YQL queries against cluster databases from Yandex Query. This feature is at the Preview stage. The default value isfalse.
-
--disk-size-autoscaling: Automatic storage size increase settings:-
planned-usage-threshold: Storage utilization threshold to trigger a storage increase during the next maintenance window, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
emergency-usage-threshold: Storage utilization threshold to trigger a storage increase right away, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
disk-size-limit: Maximum object size after increase, in GB.
Warning
- Automatic increase of storage size is not supported on dedicated hosts.
-
When using
planned-usage-threshold, make sure to specify the--maintenance-windowsetting. -
If you specify both thresholds,
emergency-usage-thresholdmust be greater thanplanned-usage-threshold.
-
-
--maintenance-window: Maintenance window settings (including for disabled clusters), wheretypeis the maintenance type:anytime: At any time (default).weekly: On a schedule. For this value, also specify the following:day: Day of week, i.e.,MON,TUE,WED,THU,FRI,SAT, orSUN.hour: Hour of day (UTC), from1to24.
-
--deletion-protection: Cluster protection from accidental deletion,trueorfalse.Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
-
performance-diagnostics: Enabling statistics collection for cluster performance diagnostics. Forsessions-sampling-intervalandstatements-sampling-interval, possible values range from1to86400seconds.
You can get the cluster name with the list of clusters in the folder.
-
Open the current Terraform configuration file describing your infrastructure.
For more information about creating this file, see this guide.
-
To change the backup start time, add a
backup_window_startblock to the Managed Service for MySQL® cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... backup_window_start { hours = <hour> minutes = <minute> } ... }Where:
hours: Backup start hour.minutes: Backup start minute.
-
To change the backup retention period, specify the
backup_retain_period_daysparameter in the cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... backup_retain_period_days = <backup_retention_period> ... }Where
backup_retain_period_daysis automatic backup retention period, in days. The valid values range from7to60. The default value is7. -
To enable access from DataLens and allow execution of SQL queries from the management console using Yandex WebSQL, add a section named
accessto the cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... access { data_lens = <true_or_false> web_sql = <true_or_false> } ... } -
To configure automatic increase of storage size, add the
disk_size_autoscalingsection to the cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... disk_size_autoscaling { disk_size_limit = <maximum_storage_size_in_GB> emergency_usage_threshold = <threshold_for_immediate_increase_in_percent> planned_usage_threshold = <threshold_for_scheduled_increase_in_percent> } ... }Where:
-
disk_size_limit: Maximum object size after increase, in gibibytes. -
emergency_usage_threshold: Storage utilization threshold to trigger a storage increase right away, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
planned_usage_threshold: Storage utilization threshold to trigger a storage increase during the next maintenance window, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100.
Warning
- Automatic increase of storage size is not supported on dedicated hosts.
-
When using
planned_usage_threshold, make sure to set themaintenance_window. -
If you specify both thresholds,
emergency_usage_thresholdmust be greater thanplanned_usage_threshold.
-
-
To set up the maintenance window (for disabled clusters as well), add the
maintenance_windowblock to the cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... maintenance_window { type = <maintenance_type> day = <day_of_week> hour = <hour> } ... }Where:
type: Maintenance type. The possible values include:ANYTIME: AnytimeWEEKLY: On a schedule
day: Day of week for theWEEKLYtype, i.e.,MON,TUE,WED,THU,FRI,SAT, orSUN.hour: UTC hour for theWEEKLYtype, from1to24.
-
To enable cluster protection against accidental deletion by a user of your cloud, add the
deletion_protectionfield set totrueto your cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... deletion_protection = <protect_cluster_from_deletion> }Where
deletion_protectionis protection against accidental cluster deletion:trueorfalse.Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
-
To enable statistics collection for cluster performance diagnostics, add a
performance_diagnosticsblock to your Managed Service for MySQL® cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... performance_diagnostics { enabled = true sessions_sampling_interval = <session_sampling_interval> statements_sampling_interval = <statement_sampling_interval> } ... }For
sessions_sampling_intervalandstatements_sampling_interval, possible values range from1to86400seconds. -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf 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.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 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_mysql_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 save it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it: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
updateMaskparameter as a single comma-separated string.{ "updateMask": "configSpec.backupWindowStart,configSpec.backupRetainPeriodDays,configSpec.access,configSpec.performanceDiagnostics,maintenanceWindow,deletionProtection", "configSpec": { "backupWindowStart": { "hours": "<hours>", "minutes": "<minutes>", "seconds": "<seconds>", "nanos": "<nanoseconds>" }, "backupRetainPeriodDays": "<number_of_days>", "access": { "dataLens": <allow_access_from_DataLens>, "webSql": <allow_access_from_WebSQL>, "yandexQuery": <allow_access_from_Yandex_Query> }, "performanceDiagnostics": { "enabled": <enable_statistics_collection>, "sessionsSamplingInterval": "<session_sampling_interval>", "statementsSamplingInterval": "<statement_sampling_interval>" }, "diskSizeAutoscaling": { "plannedUsageThreshold": "<threshold_for_scheduled_increase_in_percent>", "emergencyUsageThreshold": "<threshold_for_immediate_increase_in_percent>", "diskSizeLimit": "<maximum_storage_size_in_bytes>" } }, "maintenanceWindow": { "weeklyMaintenanceWindow": { "day": "<day_of_week>", "hour": "<hour>" } }, "deletionProtection": <protect_cluster_from_deletion> }Where:
-
updateMask: Comma-separated list of settings you want to update. -
configSpec: Cluster settings:-
backupWindowStart: Backup window settings.In this parameter, specify the backup start time:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
-
backupRetainPeriodDays: Number of days to retain the cluster backup, between7and60. -
access: Settings for cluster access from Yandex Cloud services:dataLens: Access from DataLens. For more information about setting up a connection, see Connecting from DataLens.webSql: SQL queries against cluster databases from the Yandex Cloud management console using Yandex WebSQL.yandexQuery: YQL queries against cluster databases from Yandex Query. This feature is currently in Preview.
The possible setting values are
trueorfalse. -
performanceDiagnostics: Statistics collection settings:enabled: Enables statistics collection,trueorfalse.sessionsSamplingInterval: Session sampling interval, from1to86400seconds.statementsSamplingInterval: Statement sampling interval, from1to86400seconds.
-
diskSizeAutoscaling: Automatic storage size increase settings:-
plannedUsageThreshold: Storage utilization threshold to trigger a storage increase during the next maintenance window, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
emergencyUsageThreshold: Storage utilization threshold to trigger a storage increase right away, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
diskSizeLimit: Maximum object size after increase, in bytes.
Warning
- Automatic increase of storage size is not supported on dedicated hosts.
-
When using
plannedUsageThreshold, make sure to specify themaintenanceWindowsetting. -
If you specify both thresholds,
emergencyUsageThresholdmust be greater thanplannedUsageThreshold.
-
-
-
maintenanceWindow: Maintenance window settings (including for disabled clusters). Provide one of these parameters:-
anytime(default): Maintenance can take place at any time. -
weeklyMaintenanceWindow: Scheduled maintenance:day: Day of week, inDDDformat. Valid values:MON,TUE,WED,THU,FRI,SAT,SUN.hour: Time of day (UTC) inHHformat. The valid values range from1to24.
-
-
deletionProtection: Cluster protection from accidental deletion,trueorfalse.Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
-
-
Use the Cluster.update method and send the following request, e.g., via cURL
:curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mysql/v1/clusters/<cluster_ID>' \ --data "@body.json"You can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and save it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Create a file named
body.jsonand paste the following code into it: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_maskparameter as an array ofpaths[]strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.backup_window_start", "config_spec.backup_retain_period_days", "config_spec.access", "config_spec.performance_diagnostics", "maintenance_window", "deletion_protection" ] }, "config_spec": { "backup_window_start": { "hours": "<hours>", "minutes": "<minutes>", "seconds": "<seconds>", "nanos": "<nanoseconds>" }, "backup_retain_period_days": "<number_of_days>", "access": { "data_lens": <allow_access_from_DataLens>, "web_sql": <allow_access_from_WebSQL>, "yandex_query": <allow_access_from_Yandex_Query> }, "performance_diagnostics": { "enabled": <enable_statistics_collection>, "sessions_sampling_interval": "<session_sampling_interval>", "statements_sampling_interval": "<statement_sampling_interval>" }, "disk_size_autoscaling": { "planned_usage_threshold": "<threshold_for_scheduled_increase_in_percent>", "emergency_usage_threshold": "<threshold_for_immediate_increase_in_percent>", "disk_size_limit": "<maximum_storage_size_in_bytes>" } }, "maintenance_window": { "weekly_maintenance_window": { "day": "<day_of_week>", "hour": "<hour>" } }, "deletion_protection": <protect_cluster_from_deletion> }Where:
-
update_mask: List of settings you want to update as an array ofpaths[]strings. -
config_spec: Cluster settings:-
backup_window_start: Backup window settings.In this parameter, specify the backup start time:
hours: Between0and23hours.minutes: Between0and59minutes.seconds: Between0and59seconds.nanos: Between0and999999999nanoseconds.
-
backup_retain_period_days: Number of days to retain the cluster backup, between7and60. -
access: Settings for cluster access from Yandex Cloud services:data_lens: Access from DataLens. For more information about setting up a connection, see Connecting from DataLens.web_sql: SQL queries against cluster databases from the Yandex Cloud management console using Yandex WebSQL.yandex_query: YQL queries against cluster databases from Yandex Query. This feature is currently in Preview.
The possible setting values are
trueorfalse. -
performance_diagnostics: Statistics collection settings:enabled: Enables statistics collection,trueorfalse.sessions_sampling_interval: Session sampling interval, from1to86400seconds.statements_sampling_interval: Statement sampling interval, from1to86400seconds.
-
disk_size_autoscaling: Automatic storage size increase settings:-
planned_usage_threshold: Storage utilization threshold to trigger a storage increase during the next maintenance window, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
emergency_usage_threshold: Storage utilization threshold to trigger a storage increase right away, in percent. This is an optional setting. The default setting is0(automatic increase disabled).The valid values range from
0to100. -
disk_size_limit: Maximum object size after increase, in bytes.
Warning
- Automatic increase of storage size is not supported on dedicated hosts.
-
When using
planned_usage_threshold, make sure to specify themaintenance_windowsetting. -
If you specify both thresholds,
emergency_usage_thresholdmust be greater thanplanned_usage_threshold.
-
-
-
maintenance_window: Maintenance window settings (including for disabled clusters). Provide one of these parameters:-
anytime(default): Maintenance can take place at any time. -
weekly_maintenance_window: Scheduled maintenance:day: Day of week, inDDDformat. Valid values:MON,TUE,WED,THU,FRI,SAT,SUN.hour: Time of day (UTC) inHHformat. The valid values range from1to24.
-
-
deletion_protection: Cluster protection from accidental deletion,trueorfalse.Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
You can get the cluster ID from the folder’s cluster list.
-
-
Use the ClusterService/Update call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.Update \ < body.json -
Check the server response to make sure your request was successful.
Connection Manager
If you cluster has no integration with Connection Manager, enable Use Connection Manager. It is only available in the management console
The following resources will be created for each database user:
-
Connection Manager connection with information about the database connection.
-
Yandex Lockbox secret with the user password. Storing passwords in Yandex Lockbox ensures their security.
The connection and secret will be created for each new database user. To view all connections, select the Connections tab on the cluster page.
You need the
connection-manager.viewerrole to view connection info. You can use Connection Manager to configure access to connections.Note
Connection Manager and secrets created with it are free of charge.
Manually switching the master
In a highly available Managed Service for MySQL® cluster with multiple hosts, you can switch the master role from the current master host to one of the replicas. After this operation, the current master host becomes the replica host of the new master.
Specifics of switching master hosts in Managed Service for MySQL®:
- You cannot assign the master role to a cascading replica.
- If you do not explicitly specify the replica host name, the master will switch to the replica with the highest priority or the smallest lag.
To learn more, see Replication.
To switch the master:
- Navigate to the folder dashboard and select Managed Service for MySQL.
- Click the cluster name and select the
Hosts tab. - Click
Switch master.- To switch the master to one of the 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 required replica from the drop-down list.
- Click Switch.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
Run this command:
yc managed-mysql cluster start-failover <cluster_name_or_ID> \
--host <replica_host_name>
You can request the replica host name with the list of cluster hosts and the cluster name with the list of clusters in the folder.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Use the Cluster.StartFailover method and send 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-mysql/v1/clusters/<cluster_ID>:startFailover' \ --data '{ "hostName": "<host_FQDN>" }'Where
hostNameis the FQDN of the replica which becomes the master host.You can get the cluster ID from the folder’s cluster list.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Use the ClusterService.StartFailover call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "host_name": "<host_FQDN>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.StartFailoverWhere
host_nameis the FQDN of the replica which becomes the master host.You can get the cluster ID from the folder’s cluster list.
-
Check the server response to make sure your request was successful.
Moving a cluster
- Navigate to the folder dashboard and select Managed Service for MySQL.
- Click
to the right of the cluster you want to move. - Select Move.
- Select the folder you want to move your cluster to.
- Click Move.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To move a cluster:
-
See the description of the CLI command for moving a cluster:
yc managed-mysql cluster move --help -
Specify the destination folder in that command:
yc managed-mysql cluster move <cluster_ID> \ --destination-folder-name=<destination_folder_name>You can get the cluster ID with the list of clusters in the folder.
-
Open the current Terraform configuration file describing your infrastructure.
For more information about creating this file, see this guide.
-
In the Managed Service for MySQL® cluster description, edit or add the
folder_idvalue:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... folder_id = "<destination_folder_ID>" } -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf 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.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 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_mysql_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 place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Use the Cluster.move method and send 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-mysql/v1/clusters/<cluster_ID>:move' \ --data '{ "destinationFolderId": "<folder_ID>" }'Where
destinationFolderIdis the ID of the folder you want to move your cluster to. You can fetch this ID together with the list of folders in the cloud.You can request the cluster ID with the list of clusters in the folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Use the ClusterService/Move call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "destination_folder_id": "<folder_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.MoveWhere
destination_folder_idis the ID of the folder you want to move your cluster to. You can fetch this ID together with the list of folders in the cloud.You can get the cluster ID from the folder’s cluster list.
-
Check the server response to make sure your request was successful.
Changing security groups
- Navigate to the folder dashboard
and select Managed Service for MySQL. - Select the cluster and click Edit in the top panel.
- Under Network settings, select security groups for cluster network traffic.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To edit the list of security groups for your cluster:
-
View the description of the CLI command for updating a cluster:
yc managed-mysql cluster update --help -
Specify the security groups in that command:
yc managed-mysql cluster update <cluster_name_or_ID> \ --security-group-ids <list_of_security_group_IDs>
-
Open the current Terraform configuration file describing your infrastructure.
For more information about creating this file, see this guide.
-
Edit the
security_group_idsparameter in the Managed Service for MySQL® cluster description:resource "yandex_mdb_mysql_cluster" "<cluster_name>" { ... security_group_ids = [<list_of_security_group_IDs>] } -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf 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.
-
-
For more information, see this Terraform provider guide.
Time limits
A Terraform provider sets the timeout for Managed Service for MySQL® cluster operations:
- Creating a cluster, including by restoring one from a backup: 15 minutes.
- Editing a cluster, including the MySQL® version update: 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_mysql_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 place it in an 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
updateMaskparameter 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-mysql/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "securityGroupIds", "securityGroupIds": [ "<security_group_1_ID>", "<security_group_2_ID>", ... "<security_group_N_ID>" ] }'Where:
-
updateMask: Comma-separated list of settings you want to update.Here, we provide only one setting.
-
securityGroupIds: New list of security groups presented in the form of array elements.
You can request the cluster ID with the list of clusters in the folder.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, 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_maskparameter 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/mysql/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "security_group_ids" ] }, "security_group_ids": [ "<security_group_1_ID>", "<security_group_2_ID>", ... "<security_group_N_ID>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mysql.v1.ClusterService.UpdateWhere:
-
update_mask: List of settings you want to update as an array ofpaths[]strings.Here, we provide only one setting.
-
security_group_ids: New list of security groups presented in the form of array elements.
You can get the cluster ID from the folder’s cluster list.
-
-
Check the server response to make sure your request was successful.
Warning
You may need to additionally set up security groups to connect to the cluster.