0% found this document useful (0 votes)
18 views21 pages

12 Migrating On-Premises MySQL Databases

This document outlines the process of migrating on-premises MySQL databases to Huawei Cloud using Data Replication Service (DRS) and Relational Database Service (RDS). It details tasks such as preparing the environment, creating an RDS instance, running performance tests, and setting up migration tasks. The document also includes specific commands and configurations necessary for successful migration and testing of the database performance.

Uploaded by

Mostafa Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views21 pages

12 Migrating On-Premises MySQL Databases

This document outlines the process of migrating on-premises MySQL databases to Huawei Cloud using Data Replication Service (DRS) and Relational Database Service (RDS). It details tasks such as preparing the environment, creating an RDS instance, running performance tests, and setting up migration tasks. The document also includes specific commands and configurations necessary for successful migration and testing of the database performance.

Uploaded by

Mostafa Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Migrating On-Premises MySQL Databases

1 Tasks
1. To comply with cyber security requirements on the sandbox lab environment, this exercise
uses a database built on Huawei Cloud ECS and binds an EIP to the ECS to simulate the
migration of a database from an on-premises IDC or another cloud to Huawei Cloud
Relational Database Service (RDS).
2. In this exercise, the simulated on-premises environment has been created in the ECS,
including the database and Sysbench. You can use the Xfce to log in to the database on the
ECS.
3. Sysbench imports test data to simulate I/O workloads, so the database built in the on-
premises environment continuously updates its data records. This helps prove that using
DRS to migrate databases has little impact on the source database.
4. This exercise focuses on how to use Data Replication Service (DRS), Relational Database
Service (RDS), and Elastic IP (EIP) to migrate your database to the cloud.

2 Objectives
⚫ Be able to buy an RDS instance on Huawei Cloud.
⚫ Be able to use DRS to migrate a MySQL database to the cloud.

3 Procedure
3.1 Preparing the Environment
3.1.1 Presetting the Lab Environment
**problem**(Why do I need to preset the lab environment before the exercise?)
**answer**(Presetting a lab environment includes preparing account credentials, cloud resources,
and network environments required by the exercise. This frees users from preparing the
environment.)
<font class='remin' color= '#c7000b'>Before you start, go to the Tutorials tab and click Preset
Lab. </font>
It takes 2 minutes to preset the lab environment. You can click the icon shown in the following
figure to view environment details such as the ECS username and password.

批注 [L(1]: 替换为英文
While waiting for the sandbox to complete the configuration, you can perform operations in
sections 3.1.2 Logging In to Huawei Cloud and 3.2.1 Creating an RDS Instance.
If the environment is successfully preset, the system has created the ECS, EIP, VPC, and
security group required for the exercise and installed a MariaDB database, Sysbench, and the
iostat tool on the ECS.

3.1.2 Logging In to Huawei Cloud


**problem**(What is Lab Desktop?)
**answer**(After you click Start Exercise on the Huawei Cloud lab page, the exercise operation
interface is available for you as a terminal device to perform exercise operations. This terminal
device is pre-installed with the software and tools required for the exercise.)
**problem**(How do I access Lab Desktop?)
**answer**(After you click Start Exercise, the exercise operation page is displayed. The exercise
tutorial is displayed on the left, and the exercise topology on the right. There is a computer icon
on the menu bar between the tutorial and the exercise topology. You can click the icon to enter
the exercise operation interface.)
**problem**(What is the difference between the Huawei Cloud lab account and the real Huawei
Cloud account?)
**answer**(The Huawei Cloud lab account is a real Huawei Cloud account allocated by the
system. You can use this account to perform operations only for the cloud services required in the
exercise.)
Go to the Lab Desktop and open the Chrome browser. The Huawei Cloud console can be
automatically logged in for the first time.
<font class='remin' color= '#c7000b'>If you close the browser and log in again or the automatic
login fails, perform the following steps: Select IAM User. In the login dialog box, enter the Huawei
Cloud lab account and password allocated by the system to log in to Huawei Cloud, as shown in
the following figure.
Note: Use the login credentials provided by the exercise tutorial. Do not use your own account
credentials. </font>
批注 [L(2]: 替换为英文

3.2 Migrating the Database


3.2.1 Creating an RDS Instance
**problem**(What is Huawei Cloud Relational Database Service (RDS)?)
**answer**(Relational Database Service (RDS) is a cloud-based web service that is reliable,
scalable, easy to manage, and out of the box. To view more information, click the RDS in the
topology.)
**problem**(What is the relationship between Lab Desktop and the local MySQL database?)
**answer**(Lab Desktop is an interface for users to perform exercise operations. You can use it
to install MySQL to simulate a local data center and install a browser to log in to the Huawei
Cloud console and access cloud services such as RDS and DRS.)
In the upper left corner, choose Service List > Databases > Relational Database Service. On
the Instances page, click Buy DB Instance. On the displayed page, set parameters to create a
target DB instance:
<font class='remin' color= '#c7000b'>Be sure to strictly follow this tutorial to create resources. The
resources created with incorrect configurations will be deleted, leading to a creation failure.
</font>
1. Billing Mode: Pay-per-use
2. Region: CN North-Beijing4
3. DB Instance Name: data-transfer-rds
4. DB Engine Version: MySQL 5.7
5. DB Instance Type: Single
6. Storage Type: Cloud SSD
7. AZ: AZ where there are available resources. This exercise uses AZ2 as an example.
8. Time Zone: UTC+08:00
9. Instance Class: General-purpose, 2 vCPUs | 4 GB
<font class='remin' color='#c7000b'>Note: Ensure that General-purpose is selected. </font>
10. Storage Space (GB): 40 GB (default)
11. Disk Encryption: Disable
12. VPC: Select the VPC named Sandbox-Voyagerxxx, which was generated during environment
presetting.
13. Database Port. 3306 (default)
14. Password: Set a password, for example, RL2IoQOYb@I0mw9o.
The password must comply with complexity requirements.
15. Retain the default values for other parameters.
Click Next. If all the information is correct, click Submit and go back to the Instances page. After
about 5 minutes, the instance status changes from Creating to Available. The instance is
created.
3.2.2 Database Testing

3.2.2.1 Running the DB Performance Test Script


**problem**(What is Sysbench?)
**answer**(Sysbench is a multi-threaded benchmark tool based on LuaJIT. It is most frequently
used for database benchmarks. With Sysbench, you can perform multi-thread concurrent
operations using the built-in database test model to evaluate the database performance.)
Log in to the console. Choose Service List > Compute > Elastic Cloud Server. On the
displayed page, locate the preset ECS and make a note of its EIP information.
1. Double-click Xfce Terminal on the desktop and run the following command to log in to the ECS:
Note: Replace EIP in the command with the EIP bound to the ECS named using the Huawei
Cloud account.

ssh root@EIP

2. Enter yes and press Enter to accept the key.

3. Enter the password: Click to obtain the ECS user password included in the preset 批注 [L(3]: 中文添加
environment information. (When you enter the password, it is not displayed in the CLI. Press
Enter after entering the password.) After you log in to the ECS, the following page is displayed.

Log in to the database and create a test database named loadtest. Replace <mysql-ip> in the
MySQL command with the private IP address of the ECS.

mysql -u root -h <mysql-ip> -p -e "create database loadtest"

Note: Enter the password Cloud12#$.


Import test data to the database loadtest and replace <host> in the command with the private IP
address of the ECS.
sysbench /root/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-db=loadtest
--mysql-user=root --mysql-password='Cloud12#$' --mysql-port=3306 --mysql-host='<host>' --oltp-
tables-count=10 --oltp-table-size=10000 --threads=20 prepare

Run the following command and replace <host> in the command with the private IP address of
the ECS. Ensure that the CLI remains open.

sysbench /root/sysbench/tests/include/oltp_legacy/insert.lua --db-driver=mysql --mysql-


db=loadtest --mysql-user=root --mysql-password='Cloud12#$' --mysql-port=3306 --mysql-
host='<host>' --oltp-tables-count=10 --oltp-table-size=1000 --max-time=3600 --max-requests=0 --
threads=10 --report-interval=3 --rate=20 --forced-shutdown=1 run

After the command is executed, read and write operations are continuously performed for the
database, as shown in the following figure. (The performance test script is used to simulate
continuous database I/O workloads.)

3.2.2.2 Checking the CPU and Read/Write Throughput


After the test script execution is complete, open a new CLI window and query the CPU usage and
read/write throughput. In section 2.8.4, you will compare them with the real-time CPU usage and
read/write throughput queried during a DRS online data migration task to see if the source
database performance changes. Run the following command to log in to the ECS:
Note: Replace EIP in the command with the EIP bound to the ECS named using the Huawei
Cloud account.

ssh root@EIP

Run the following command to query the CPU usage:

top

The following figure shows the database CPU usage.

Press Ctrl+C to exit the top command execution. Then run the following command to query the
database read/write throughput.

iostat -d vda vdb -m 1 10

Check the changes of the VDA read/write throughput (unit: MB/s). To exit, press Ctrl+C.
3.3 Creating a Migration Task
In the upper left corner, choose Service List > Databases > Data Replication Service.
On the Online Migration Management page, click Create Migration Task.
What is DRS?
Data Replication Service (DRS) is a stable, efficient, and easy-to-use cloud service for online
data migration and real-time data synchronization between databases. It simplifies data migration
processes and reduces migration costs. Click the cloud service in the topology to view details.

If a dialog box is displayed, close it.

On the Create Replication Instance page, set parameters to create a replication instance:
1. Region: CN North-Beijing4
2. Task Name: data-transfer-task
3. Data Flow: To the cloud
4. Source DB Engine: MySQL
5. Destination DB Engine: MySQL
6. Network Type: Public network
7. Destination DB Instance: Select the RDS DB instance you have created.
8. Destination DB Instance Access: Read/Write
9. Migration Type: Full+Incremental
Click Create Now.
3.4 Setting the Source and Destination Databases
After the replication instance is created, set parameters on the Configure Source and
Destination Databases page.
Source database information:
1. IP Address or Domain Name: Enter the preset EIP bound to the ECS named after the
username.
2. Port: 3306
3. Database Username: root
4. Database Password: Cloud12#$
5. SSL Connection: Toggle it off.
Click Test Connection. When "Test successful" is displayed, the source database is connected.
It takes about 3 to 5 minutes to create a replication instance. Test Connection is available only
after the replication instance is created.

Destination database information:


1. DB Instance Name: Retain the default value.
2. Database Username: root
3. Database Password: Enter a user-defined password, for example, RL2IoQOYb@I0mw9o.
4. Migrate Definer to User: Yes
Click Test Connection. When "Test successful" is displayed, the destination database is
connected.
After the source and destination databases are connected, read and agree to the agreement, and
click Next.

3.5 Setting the Migration Task


You can retain the default settings of parameters on the Set Task page, including Flow Control,
Migrate Account, and Migrate Object.
If you set Migrate Account to Yes, accounts that already exist in the destination RDS database
will not be migrated and accounts that do not exist (new accounts) in the destination RDS
database will be automatically migrated.
For accounts that cannot be migrated, you can click View to learn the details. For accounts that
can be migrated, you can change the host address (the IP address used by the user to log in to
the database), set a password for each individual account, or set a unified password for all the
accounts.
Note: The password must consist of uppercase letters, lowercase letters, digits, and special
characters.
Click Confirm All Remarks.
Set Migrate Object to All and click Next. In the displayed dialog box, click Ignore and Next.
3.6 Checking the Task
On the Check Task page, check the migration task.
If any check fails, review the cause and rectify the fault. After the fault is rectified, click Check
Again.
For details, see Troubleshooting > Solutions to Failed Check Items in the Data Replication
Service User Guide at https://support.huaweicloud.com/intl/en-us/trouble-drs/drs_11_0001.html.
After all checks pass, click Next.
You can proceed to the next step only when all checks are successful. If there are any
items that require confirmation, view and confirm the details first before proceeding to the
next step.

3.6.1 Comparing Parameters


In most cases, it is normal that some common parameters and performance parameters of the
destination database are inconsistent with those of the source database. You can determine
whether to keep them consistent with those of the source database, or you can skip this step.
1. Service parameters include the character set, connection wait timeout, maximum number of
connections, lock wait timeout, transaction isolation level, and scheduling parameters.
2. Performance parameters include *_buffer_size and *_cache_size.
When most parameters are not migrated, the migration will not fail, but service running and
performance may be affected. In most cases, it is normal that some common parameters and
performance parameters of the destination database are inconsistent with those of the source
database.
If all information is correct, click Next.
3.7 Confirming the Task
On the Confirm Task page, set Start Time (select Start upon task creation for this exercise
task). In the displayed dialog box, select I have read the precautions and click Start at a
specified time.
After the migration task is submitted, go to the Online Migration Management page to view the
task status.

3.8 Managing the Task


3.8.1 Full Migration
You can click the target full migration task. On the displayed page, click Migration Progress to
view the migration progress. When the progress reaches 100%, the migration is complete.

3.8.2 Incremental Migration


After the full migration is complete, incremental migration starts. You can click the target migration
task. On the displayed page, click Migration Progress to view the incremental migration delay. If
the delay is close to 0s (read and write operations are continuously performed to test the
database I/O performance, so there is a small delay during the migration), the destination
database is being synchronized with the source database in real time.
3.8.3 Migration Comparison

In the incremental migration phase, DRS provides Object-Level Comparison, Data-Level


Comparison, and User-Level Comparison.
Check the integrity of the database objects. Click Validate Objects. On the Object-Level
Comparison tab, click Compare. Wait for a while and view the comparison result of each item.
After object comparison is complete, compare the number of rows and content of the migrated
data. 1. Click the Data-Level Comparison tab. 2. Click Create Comparison Task (if the button
is unavailable, click the refresh icon). 3. On the displayed Create Comparison Task page, set
Comparison Type to Row and Comparison Time to Start upon task creation. Select a table
under the loadtest database, click >> to add the table to the right pane, and click OK to create a
comparison task.

Note: This task checks whether the content of the selected table is consistent before and after the
migration. (It is normal that content inconsistency may occur because read/write operations are
continuously performed for the database.) If you select all the data, it takes a long period of time
to compare it so you are advised to select a table for comparison.
The following figure shows that the comparison task is created.

After the comparison is complete, click View Results to view the details.
3.8.4 Querying CPU Usage and Read/Write Throughput During
Incremental Migration
During incremental migration, the ECS-hosted database synchronizes data with the RDS
instance in near real time. You can check whether the synchronization affects the source
database performance. For details about how to query the CPU usage and read/write throughput,
see section 2.2.2. The following figure displays the CPU usage.

Query the VDA read/write throughput (unit: MB/s) by referring to section 2.2.2. The following
figure shows the read/write throughput changes.

Compared the CPU usage and read/write throughput with those obtained in section 2.2.2. From
the comparison, you can see that the incremental migration has little impact on the ECS where
the database is installed.
3.9 Service Migration
3.9.1 Stopping Services
Switch to the CLI for running the pressure test script (section 2.2.1). Press Ctrl+C to exit the
script execution. That is, stop read/write operations of the ECS-hosted database.
Return to the browser and observe the synchronization delay on the DRS console. When the
delay is 0 and remains 0 for a period (there is no read/write operation) and data in the source and
destination databases is consistent, the migration is complete.

You can use migration comparison (referring to section 2.8.3) to compare data of the source and
destination databases. When the data is consistent, all data has been migrated to RDS.

3.9.2 Migrating Services


Open the RDS instance list by choosing Service List > Databases > Relational Database
Service (referring to section 2.1). Locate the RDS instance named data-transfer-rds. Query its
IP address by doing the following:

Open the CLI. Run the following command and replace <password> with the RDS user password
(RL2IoQOYb@I0mw9o is used as an example in this exercise) and <host> with the private IP
address of the RDS instance.

sysbench /root/sysbench/tests/include/oltp_legacy/insert.lua --db-driver=mysql --mysql-


db=loadtest --mysql-user=root --mysql-password='<password>' --mysql-port=3306 --mysql-
host='<host>' --oltp-tables-count=10 --oltp-table-size=1000 --max-time=3600 --max-requests=0 --
threads=20 --report-interval=4 --rate=20 --forced-shutdown=1 run

After the command is executed, a command output shown in the following figure is displayed.
Data can be read from and written to the RDS database, and your service system is connected to
the RDS instance of Huawei Cloud. This indicates that the service system is working properly
with the RDS and that the migration is successful.
Note: If you are prompted to enter the password when running this command, enter the ECS user
password included in the preset environment information.

3.9.3 Ending the Exercise


Press Ctrl+C to exit the CLI. Switch to your browser and go to the DRS console. Select the
migration task and click Stop. After about 2 minutes, the task stops and the exercise is complete.

You might also like