Creating MySQL clusters
A MySQL cluster is one or more database hosts. In multi-host clusters, semi-synchronous replication is configured automatically.
For more about Managed Service for MySQL cluster structure, see Resource relationships in Managed Service for MySQL.
Note
The number of hosts you can create together with a MySQL cluster depends on the selected host class.
How to create a MySQL cluster
-
In the management console
, select Managed Service for MySQL. -
Click Create cluster.
-
Enter a name for the Managed Service for MySQL cluster in the Cluster name field.
-
Select the DBMS version.
-
Select the host class that defines the technical specifications of the VMs where the DB hosts will be deployed. All available options are listed in MySQL host classes. When you change the host class for the Managed Service for MySQL cluster, the characteristics of all existing hosts change, too.
-
Under Size of storage:
-
Select the storage size to be used for data and backups. For more information about how backups take up storage space, see Backups in Managed Service for MySQL.
Note
If DB storage is 95% full, the Managed Service for MySQL cluster will switch to read-only mode. Increase the storage size in advance.
-
-
Under Database, specify the DB attributes:
-
DB name.
A database name may contain letters, numbers, and underscores. The name may be up to 63 characters long. Such names as
mysql
,sys
,information_schema
, andperformance_schema
are reserved for Managed Service for MySQL. You cannot create DBs with these names. -
DB owner username and password.
Note
A username may contain letters, numbers, hyphens, and underscores, but must start with a letter or an underscore. It can be between 1 and 32 characters long.
The password must be between 8 and 128 characters.
-
-
Under Hosts, click
and select the parameters for the DB hosts created together with the Managed Service for MySQL cluster:- Availability zone.
- Host subnet: By default, each host is created in a separate subnet.
- Select Public access if the host must be accessible from outside Nebius AI.
- Priority for assigning the host as a master.
- Host priority as a MySQL replica for creating backups.
-
Configure additional Managed Service for MySQL cluster settings, if required:
-
Backup start time (UTC)
The time in UTC (in 24-hour format) to start backing up the cluster. If the time is not set, the backup will start at 22:00 UTC.
-
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 required, configure DBMS cluster-level settings.
Note
Some MySQL settings depend on the selected host class.
-
Click Create cluster.
If you don't have the Nebius AI 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 create a Managed Service for MySQL cluster:
-
View a description of the create Managed Service for MySQL cluster CLI command:
ncp managed-mysql cluster create --help
-
Specify the Managed Service for MySQL cluster parameters in the create command:
ncp managed-mysql cluster create \ --name=<cluster name> \ --network-name <network name> \ --host zone-id=<availability zone>,` `subnet-id=<subnet ID>,` `assign-public-ip=<public access to the host: true or false>,` `priority=<priority when selecting a new master host: from 0 to 100>,` `backup-priority=<backup priority: from 0 to 100> \ --resource-preset <host class> \ --user name=<username>,password=<user password> \ --database name=<database name> \ --disk-size <storage size in GB>
Configure additional Managed Service for MySQL cluster settings, if required:
ncp managed-mysql cluster create \ ... --backup-window-start <backup start time> \ --deletion-protection=<cluster deletion protection: true or false>
A database name may contain letters, numbers, and underscores. The name may be up to 63 characters long. Such names as
mysql
,sys
,information_schema
, andperformance_schema
are reserved for Managed Service for MySQL. You cannot create DBs with these names.Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
Configure the DBMS settings, if required.
Examples
Creating a single-host cluster
To create a Managed Service for MySQL cluster with a single host, provide a single --host
parameter.
Create a Managed Service for MySQL cluster with test characteristics:
- Named
my-mysql
. - Versions
8.0
. - In the
default
network. - With a single
s3-c2-m8
class host in theb0rcctk2rvtr8efcch64
subnet, in theeu-north1-c
availability zone. - With 20 GB of storage.
- With one user,
user1
, with the passworduser1user1
. - With one
db1
database, in whichuser1
has full rights (same asGRANT ALL PRIVILEGES on db1.*
). - With protection against accidental cluster deletion.
-
Run this command to create a Managed Service for MySQL cluster:
ncp managed-mysql cluster create \ --name="my-mysql" \ --network-name=default \ --host zone-id=eu-north1-c,subnet-id=b0rcctk2rvtr8efcch64 \ --resource-preset s3-c2-m8 \ --disk-size 20 \ --user name=user1,password="user1user1" \ --database name=db1 \ --deletion-protection=true
-
Run the change permissions command for the
user1
user.ncp managed-mysql user grant-permission user1 \ --cluster-name="my-mysql" \ --database=db1 \ --permissions ALL
Creating a multi-host cluster
To create a multi-host Managed Service for MySQL cluster, provide as many --host
parameters as there should be hosts in your cluster.
Create a Managed Service for MySQL cluster with test characteristics:
-
Named
my-mysql-3
. -
In the
default
network. -
With three public hosts of the
s3-c2-m8
class.One host will be added to each subnet of the
default
network:subnet-a
:10.5.0.0/24
.subnet-b
:10.6.0.0/24
.subnet-c
:10.7.0.0/24
.
The host residing in
subnet-b
will have the backup priority. Backups will be created from this host's data unless you choose it to be the master host. -
With 32 GB of storage.
-
With one user,
user1
, with the passworduser1user1
. -
With one
db1
database, in whichuser1
has full rights (same asGRANT ALL PRIVILEGES on db1.*
).
-
Run this command to create a Managed Service for MySQL cluster:
ncp managed-mysql cluster create \ --name="my-mysql-3" \ --network-name=default \ --host zone-id=eu-north1-c,` `subnet-name=subnet-a,` `assign-public-ip=true \ --host zone-id=eu-north1-c,` `subnet-name=subnet-b,` `backup-priority=10,` `assign-public-ip=true \ --host zone-id=eu-north1-c,` `subnet-name=subnet-c,` `assign-public-ip=true \ --resource-preset s3-c2-m8 \ --disk-type network-ssd \ --disk-size 32 \ --user name=user1,password="user1user1" \ --database name=db1
-
Run the change permissions command for the
user1
user.ncp managed-mysql user grant-permission user1 \ --cluster-name="my-mysql-3" \ --database=db1 \ --permissions ALL