You are on page 1of 12

Build on Amazon Aurora

Lab02: Schema conversion and Data migration

Overview:
This lab guide introduces you to Schema Conversion Tool (SCT) and Database Migration Service (DMS). As part of this lab,
you would be migrating data from source SQL Server to Aurora (MySQL compatible) database.

Lab Instructions:

Task 01: Schema Conversion.

1. Launch SCT on your Windows Host created as part of cloud formation stack – there’s a shortcut for it
on your taskbar.
2. Select Not now, from the dialogue box suggesting to download the newer version of SCT.

3. Accept the license agreement.

4. The “Create a new database Migration Project” Wizard will launch. If it doesn’t you should select “New
Project Wizard” option from the File Menu. Make sure you have the following selected and then click
Next.
Page 1 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

a. Transactional database (OLTP)


b. Source database engine: Microsoft SQL Server
c. I want to switch engines and optimize for the cloud.
d. Click Next.

5. Provide the connection information for your source RDS Database. This information can be obtained
from the Outputs section of the CloudFormation Stack.
a. For the Instance name, leave it blank.
b. Leave “Use SSL” unchecked
c. Check “Store password”
d. When you are finished press the “Test Connection” button
e. After successful connection, click “OK”, then Next.

Note: if you get a warning, metadata loading was interrupted, please ignore.

6. Now select the schema to convert and click next. For this workshop the schema will be
dms_sample.dbo.

Page 2 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

7. The Schema Conversion Tool will now perform an analysis of the dms_sample.dbo schema, wait while
it completes.
8. When the analysis is complete you will see the “Database migration assessment report”. Review it as it
will provide information on various target databases and how much can automatically be converted.
When done reviewing the report click “Next”

9. Now you will setup your connection to your target database. Select the target database engine as
Amazon Aurora (MySQL Compatible) and fill out the connection details for the instance created in last
lab.

Page 3 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

10. Once the connection test completes successfully click “OK” and then click “Finish”.

** Ignore any warning about recommended database versions.

11. At this point a migration project will launch.

12. In the left-hand panel deselect all of the source databases and schemas except for dms_sample
database and dbo schema.

13. Now on the source schema panel. Select the schema “dbo” and right click to bring up the menu to
convert the schema. You can also select convert schema from the Actions menu.

Page 4 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

14. A confirmation dialog box will come popup. Click “Yes” to replace objects, as there are no objects in
the target database at this point.
15. SCT will convert your source schema to a target schema that will be displayed in the right-hand panel
as dms_sample_dbo.

16. At this point you can select objects in either the source or target panels and see a comparison of
original and converted code and objects. You can also make changes to the converted objects as
desired. Look through which objects could be automatically converted and which could not be.

Page 5 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

17. Since the majority of the objects which could be converted, right click on the schema that was created
(in the right panel) and select “Apply to database”. This will write the converted objects to the target
database.

18. Another confirmation dialog box will pop up at this point. Click “Yes” to continue.
19. The schema conversion is now complete. You are ready to move on to the next step and use DMS to
move data from source to your Aurora instance.

Task 02: Data Migration.

In this task, we will use the Database Migration Service (DMS) to move the data from the Source to the
Target.

Page 6 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

1. Go to the AWS Console and bring up the Database Migration Service page. Click Endpoints on the left-
hand side of the screen. Then click “Create Endpoint” and the create endpoint page will appear. You
will do this twice, once to create a source endpoint and then to create a target endpoint.
a. Source endpoint:
i. For Endpoint type section, choose “source endpoint”
ii. Check “select RDS DB Instance”
iii. Select RDS source instance from dropdown menu.
iv. For the Endpoint Configuration section,
1. Enter the password.
2. Database name: dms_sample
v. In the Test endpoint connection section
1. Choose the VPC created in lab1.
2. Replication instance created as part of lab setup.
3. Click Run test.
vi. One the connection is successful, click Create endpoint.

b. Target endpoint creation


i. Follow the same steps as above except
1. choose Endpoint type as Target endpoint.
Page 7 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

2. Enter password for target database.


3. For Endpoint-specific settings copy this in Extra connection attributes:
initstmt=SET FOREIGN_KEY_CHECKS=0
4. In the Test endpoint connection section, test the connection similar to last step.
5. One the connection is successful, click Create endpoint.

2. Next, we need to create a migration task. Select “Database migration tasks” from the menu on the left
side. Click the “Create task” button in the upper right and fill out the form as follows:
a. Task identifier: Give your task a relevant name (e.g datalab-task)
b. Replication Instance: choose the one you created (see your cloud formation stack outputs)
c. Source Endpoint: choose the source endpoint you just created
d. Target Endpoint: choose the target endpoint you just created
e. Migration Type: Migrate existing data
f. Start task on create: check this (or don't, up to you). If you don’t, you’ll need to start your task
Separately.

Page 8 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

g. Target table preparation mode: Do Nothing


h. Include LOB columns in replication: Accept the default
i. Enable validation: leave unchecked for this lab.
j. Enable logging: YES! (Check this box)

k. For Table mappings section,


i. Add new selection rule,
1. Schema: dbo.
Page 9 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

2. Action: Include
ii. Under transformation rules, click Add new transformation rule.
1. Target: Schema
2. Schema Name: dbo
3. Action: Rename to ; Value: dms_sample_dbo

l. Leave “Advanced task setting” default for this lab.


m. Click “Create task”
3. Start moving the data
a. Check the task just created in previous step.
b. From Actions, select “Restart/Resume”
c. Monitor the task status by Logs or Table statistics sections on Task details page.

Page 10 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

Note: Data migration would take approx. 20-25 mins. Output of Table statistics would look like this at the end of data
migration.

Task 03: Create procedures.

After the data migration, most of the procedures where converted successfully from SQL Server to MySQL, for remaining
procedures, use following sql script to recreate them.

1. Connect to Aurora database created in last lab, follow the steps from Lab 1A to connect Aurora
database using Mysql workbench.
2. Execute following SQL scripts to create procedures:
a. From the File menu, select “Run SQL script”
b. Run the below steps for the all scripts located in “C:\Users\Administrator\Desktop\scripts” one
at a time.

Page 11 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Build on Amazon Aurora

Lab02: Schema conversion and Data migration

c. When running the script, select Schema: dms_sample_dbo and leave Default Character Set as
blank.

d. Click “Run”.

You have now successfully migrated a database from commercial to open-source. Check the resources at
https://aws.amazon.com/dms/resources/ for additional playbooks with more details about specific migration
patterns and frequently asked questions.

Page 12 of 12

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

You might also like