MySQL-PXC nodes must be down.
The cluster must have sufficient CPU, memory, storage, and other resources to create a MySQL-MGR cluster with the same specifications as MySQL-PXC.
The application side should update the MySQL driver to the MySQL-MGR version; you can refer to Connectors and APIs.
Use utf8mb4
character set.
The application side should use utf8mb4
.
On the database side, convert the library and tables to utf8mb4
.
The SQL for character conversion is as follows.
Tip: The larger the amount of data in the table, the longer the conversion time.
MySQL-MGR enforces that tables must have a primary key.
Even if there is no primary key in the table, an INVISIBLE
primary key will be automatically created during import into MySQL-MGR; it is recommended that business sides use explicit primary keys.
Tip: It will appear in SHOW TABLE
, but the SELECT
will hide this field.
To find tables in the business database that lack a primary key:
Note: When using the example code in this document, please replace with actual instance parameters.
The MySQL-PXC cluster status must be normal before backing up data.
In the left navigation bar, click MySQL-PXC.
Click Namespace Name.
Click Instance Name.
In the Details tab, Basic Information, Resource Configuration, and ProxySQL status should be Running.
In the Topology tab, the status of each ProxySQL and MySQL node should be Normal.
From the output, determine the name of the MySQL-PXC to which the read/write node demo-pxc-0.demo-pxc.demo-ds1.svc.cluster.local
belongs.
Note: Do not perform write operations on the application side, as this will result in an incomplete backup.
In the left navigation bar, click MySQL-PXC.
Click Namespace Name.
Click Instance Name.
Click Actions > Update.
Click YAML.
Change the value of the pxc.proxysql.size
parameter to 0
.
Click Update.
Note: The resource specifications for the created MySQL-MGR instance should not be lower than those of the MySQL-PXC instance.
In the left navigation bar, click MySQL-MGR.
Click Namespace Name.
Click Instance Name.
In the Details tab, Basic Information, Resource Configuration, and MySQL Router status should be Running.
In the YAML tab, the values of status.conditions.type
and status.state
should be ready
.
Nodes with MEMBER_ROLE
as PRIMARY
are the read/write nodes of MySQL-MGR.
Exclude MySQL system databases: information_schema
, mysql
, performance_schema
, and sys
.
For business databases: Record the business databases to back up, and when using the mysqldump
backup tool, specify the databases with the -B
option.
For example, from the following queried database list, you need to back up the business databases test1
, test2
, and test3
.
In the Container Platform view, in the left navigation bar, click Storage > Persistent Volume Claims.
Click Create Persistent Volume Claim.
Fill in the PVC configuration parameters.
Note: Use TopoLVM as the storage class.
Click Create; the PVC status should be Pending Binding.
Please contact the Platform Administrator to create a PV based on the following YAML. After creating the PV, check that the PVC status is Bound.
Check the MySQL-MGR image address.
In the Container Platform view, in the left navigation bar, click Compute Components > Deployments.
Click Create Deployment.
Select Input method, fill in Image Address, and click OK.
In Pods > Volumes, click Add.
Fill in the volume configuration, using the PVC created in this document as the storage volume for the MySQL container.
Click Add.
Fill in the container configuration.
Click Create.
Obtain the IP of the MySQL-PXC read/write Pod.
Obtain the root password for MySQL-PXC.
Enter the MySQL backup and recovery container created in this document, for example, Pod name is mgr-backcup-9f87d46c4-kwkps
.
Tip: The Pod name can be viewed in the container group list of this deployment.
Backup the business database.
Parameter explanation:
--password
: Root password of MySQL-PXC.
--host
: Specify the IP address of the read/write Pod of MySQL-PXC.
-B
: Specify the names of the business databases to back up in MySQL-PXC, separated by spaces.
Check the size of the logical backup.
Enter the MySQL-MGR Pod to back up the MySQL-PXC user table.
Obtain the SQL statements for the accounts: INSERT INTO
.
Delete the MySQL-PXC system users, keeping only the business application accounts.
Delete system accounts: ('localhost','root')
, ('localhost','mysql.session')
, ('localhost','mysql.sys')
, ('%','root')
, ('%','operator')
, ('%','monitor')
, ('localhost','clustercheck')
.
Retain business application accounts: test_user_1
, test_user_2
, test_user_3
.
Modify the inserted account records.
Note: Do not import the root account.
MySQL-MGR has added 6 fields to mysql.user
compared to MySQL-PXC, so when inserting account records, the following 6 fields need to be added: Create_role_priv: Y
, Drop_role_priv: Y
, Password_reuse_history: NULL
, Password_reuse_time: NULL
, Password_require_current: NULL
, User_attributes: NULL
. Thus, appending the following values to each insert record: , 'Y', 'Y', NULL, NULL, NULL, NULL
.
Insert account records into MySQL-MGR.
Verify whether the accounts are functioning correctly.
If the current cluster lacks resources and a same-spec MySQL-MGR cluster has not been deployed, you can use mysqldump
on the host machine to perform the backup.
Procedure:
Ensure that the MySQL-PXC cluster status is normal.
Stop business read/write and set the ProxySQL replicas to 0.
Perform a backup of MySQL-PXC.