We use machine learning technology to do auto-translation. Click "English" on top navigation bar to check Chinese version.
Migrate a multi-TB SQL Server database to Amazon RDS Custom for SQL Server using Amazon S3 and Amazon EBS
This is the first in a two-part series of posts on how to migrate a multi-TB database to
Amazon RDS Custom for SQL Server is a managed database service that automates setup, operation, backups, high availability, and scaling of databases while granting access to the database and underlying operating system (OS). The database administrator can use this access to enable native features such as SQL Common Language Runtime (CLR), configure OS settings, and install drivers, in order to migrate legacy, custom, and packaged applications.
Overview
Amazon RDS Custom for SQL Server has a default data drive (D:) that allows for up to 16TB of storage. For Information on Amazon RDS Custom for SQL Server storage constraints and how to adjust storage refer to
A common challenge the customers have when migrating to Amazon RDS custom for SQL Server is when the database size plus the backup files are bigger than 16 TB. In this post, we show you how to successfully migrate a multi-TB database using
Avoid storage overprovisioning
You can also use this approach to migrate a multi-TB database even if the sum of the database and its backup files is less than 16TB. It prevents storage over-provisioning and lowers costs because you can reclaim the backup files space after database restore.
For example, if you have a database that is 10TB and the backup files adds up to 5TB, it is possible to provision an Amazon RDS Custom for SQL Server with 15TB allocated to it. Then you can copy the backup files to the D: drive and restore the database. However, choosing that approach would incur higher cost because you cannot reclaim the 5 TB of storage allocated for the backup files. This implies you will be paying for 5TB that are not being used. How much that costs can be calculated using the
The following table shows the current difference in storage cost for an Amazon RDS Custom for SQL Server in the us-east-1 Region:
RDS Custom SQL Server Storage Cost (Single-AZ) | |
Provisioned IOPS SSD (io1) | |
Provisioning IOPs: 1000 | |
Storage Amount | Monthly Cost |
10 TB | $ 1,277.60 |
15 TB | $ 1,866.40 |
Solution overview
One of the methods to migrate a multi-TB on-premises SQL Server database to Amazon RDS Custom for SQL Server is by using
You should not host database files on the additionally attached EBS volume to avoid RDS Custom for SQL Server from going into an unsupported configuration state. To understand more about the RDS Custom support perimeter and unsupported configuration monitoring, please refer to link
The following is a high-level architecture diagram of the migration.
The high-level workflow is:
- Back up the on-premises SQL Server database directly to the S3 File Gateway file share.
- Add an optional EBS volume to Amazon RDS Custom for SQL Server.
- Download the backup files from S3 File Gateway to the EBS volume.
- Restore the backup file on Amazon RDS Custom for SQL Server.
- Remove the EBS volume.
Prerequisites
We assume that you have the following prerequisites:
- Background knowledge regarding
SQL Server backup and restore . -
How to set up, launch, and connect to RDS for Custom SQL Server instances. - An S3 bucket configured to store the necessary database backup files. For instructions, refer to
Creating a bucket . - An S3 File Gateway. For reference, refer to
Create and activate an Amazon S3 File Gateway . - An SMB file share on the S3 File Gateway has been created and mounted on your on-premises server. Refer to
Create an SMB file share with default settings andMount your SMB file share on your client . - Amazon Web Services services such as
Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Web Services CLI.
Because this solution involves setting up and using Amazon Web Services resources, it will incur costs in your account. Refer to
Back up your on-premises SQL Server database to the S3 File Gateway file share
We back up our very large on-premises database to multiple backup files for
In our example, we back up to the following files:
-
SampleTest_FullBackupCompressed01.bak
-
SampleTest_FullBackupCompressed02.bak
-
SampleTest_FullBackupCompressed03.bak
-
SampleTest_FullBackupCompressed04.bak
Add an optional EBS volume to Amazon RDS Custom for SQL Server
Create a storage volume large enough to hold the backup files and make sure it’s in the same Availability Zone (AZ) as the RDS Custom for SQL Server database.
If your RDS Custom for SQL Server was deployed on a Single-AZ, create the EBS volume on the same availability zone as the RDS Custom.
If your RDS Custom for SQL Server was deployed on a Multi-AZ, to determine on which availability zone the RDS Custom is running on follow these steps (this can also be used for Single-AZ deploys):
- Retrieve the RDS Custom for SQL Server endpoint using Amazon Web Services CLI. The endpoint will be under “Endpoint” / “Address” as shown below:
In our example:
The endpoint can also be found in the Amazon Web Services RDS console in the “Connectivity & security” tab after selecting your database instance.
- Retrieve the IP address for the RDS Custom for SQL Server. From a box that has access to the RDS Custom for SQL Server (you might need a bastion server if the RDS was created on a private subnet as suggested per best practices), run the following command:
In our example:
- Compare the retrieved IP address with the address of the 2 EC2 created for the RDS Custom for SQL Server to determine which EC2 is the active one and thus being able to determine the availability zone it is running on. This post assumes that the RDS Custom for SQL Server database was created on the
us-east-1a
Availability Zone.
You can use Amazon Web Services Console or the Amazon Web Services CLI to create the EBS volume. For step-by-step instructions, see
- On the Amazon EBS console, create your volume. For this post, we added the name tag
rdscustombackupstorage
to our EBS volume.
To create an EBS volume using Amazon Web Services CLI, issue a command in PowerShell similar to the following:
When the storage volume is available, you need to attach it to the RDS Custom for SQL Server instance.
- Select the EBS volume that you created and on the Actions menu, choose Attach volume .
- Choose the RDS Custom for SQL Server instance.
- Choose Attach volume .
To attach an EBS volume to the instance using Amazon Web Services CLI, issue a command in PowerShell similar to the following:
After you attach an EBS volume to your instance, it is exposed as a block device, and appears as a removable disk in Windows.
- You can format the volume with any file system and then mount it.
Because the EBS volume is greater than 2 TiB, you must use a GPT partitioning scheme to access the entire volume. Refer to
- To make the EBS volume available to use, you need to RDP into the RDS Custom database instance. Refer to
Connecting to your RDS Custom DB instance using RDP for detailed steps. - After you RDP into your RDS Custom for SQL Server instance, you can attach the disk by either using PowerShell, the DiskPart command line tool, or the Disk Management utility. For more information, refer to
Make an Amazon EBS volume available for use on Windows .
In our example, we use the Disk Management utility.
After the disk is initialized, you must create a volume and assign a drive letter to it.
- Right-click on the unallocated space and choose New Simple Volume .
- Choose Next on the welcome page.
- Define the new volume size, then choose Next .
- Assign a drive letter, then choose Next .
- Format the partition, then choose Next .
- Review your settings and choose Finish .
Make sure the E: drive is available either through the file explorer or through the Disk Management utility.
To make an EBS volumes with raw partitions available to use with Windows using PowerShell, issue a command similar to the following:
Download the backup files from S3 File Gateway to the EBS volume
When the disk is online and available to use, transfer the backups from the S3 bucket to the new EBS volume after installing the Amazon Web Services CLI. Refer to
Run the following commands on the target RDS Custom for SQL Server instance to download all the backup files to the Backup folder created on the E: drive:
Restore the backup file on Amazon RDS Custom for SQL Server
After you download all the backup files, use the following native SQL Server command to restore the database, pointing to the EBS volume added and the location to the backup files (in our case, E:\Backup
). The database files must reside in D:\rdsdbdata\DATA
Furthermore, using
BLOCKSIZE
, MAXTRANSFERSIZE
, and BUFFERCOUNT
can considerably boost backup and restoration throughput.
Remove the EBS volume
After the database is restored, if you don’t intend to use the volume anymore, make sure to first
To unmount the volume:
- Start the Disk Management utility.
- (Windows Server 2012 and later) On the taskbar, right-click the Windows logo and choose Disk Management .
- Windows Server 2008) Choose Start , Administrative Tools , Computer Management , Disk Management .
- Right-click the disk and then choose Offline . Wait for the disk status to change to Offline before opening the Amazon EC2 console.
Detach the volume
You can use the Amazon Web Services console to detach the volume. Select volume , click on Actions and select Detach volume.
To detach an EBS volume using Amazon Web Services CLI, issue a command similar to the following in Powershell:
Delete the volume
You can use Amazon Web Services Console to delete the volume. Select the volume, click on Actions and select Delete volume.
To delete an EBS volume using Amazon Web Services CLI, issue a command similar to the following in Powershell:
Summary
In this post, we demonstrated how to successfully migrate a database when the total size of the database and backup exceeds 16 TB. This method also lets you avoid overprovisioning storage for Amazon RDS Custom for SQL Server while transferring very large databases, thereby reducing costs.
In part 2 of this series, we’ll show you how to migrate a multi-TB SQL Server database to Amazon RDS Custom for SQL Server using
About the Authors
Jose Amado-Blanco is a Sr. Consultant on Database Migration with over 25 years of experience working with Amazon Web Services Professional Services. He helps customers on their journey to migrate and modernize their database solutions from on-premises to Amazon Web Services.
Priya Nair is a Database consultant at Amazon Web Services. She has 18 plus years of experience working with different database technologies. She works as database migration specialist to help Amazon customers to move their on-premises database environment to Amazon Web Services cloud database solutions.
Suprith Krishnappa C is a Database Consultant with the Professional Services team at Amazon Web Services. He works with enterprise customers, offering technical support and designing customer solutions on database projects, as well as assisting them in migrating and modernizing their existing databases to the Amazon Web Services cloud.
The mentioned AWS GenAI Services service names relating to generative AI are only available or previewed in the Global Regions. Amazon Web Services China promotes AWS GenAI Services relating to generative AI solely for China-to-global business purposes and/or advanced technology introduction.