How to Upload Database to Aws Postgres Rdb

There are multiple means to deploy the databases in the AWS RDS SQL Server. Suppose you want to migrate your on-premises SQL Server database to AWS managed relational database service and yous have a critical application and require minimal (nearly zilch) downtime. For this purpose, you tin use the AWS Database Migration Service (AWS DMS) in a combination of SQL Server native backups.

You can use the on-premises SQL Server as a source database; however, for sit-in of the steps, I volition utilise the SQL Server on EC2 instance.

Configuring SQL Server on EC2 instance every bit a source database

For the demonstration, nosotros use the Amazon Machine Prototype (AMI) preconfigured with the SQL Server 2019. Log in to your AWS console and search for SQL Server 2019 AMI.

Information technology highlights all available AMI for SQL Server 2019. I choose the Microsoft Windows Server 2019 with SQL server 2019 standard.

Configure the SQL Server on EC2 instance as a source database

You can get through the remaining steps and build the SQL Server on an EC2 case. Refer to the article for detailed steps on AWS SQLShack for detailed instructions.

An EC2 case is in a running state, and it takes some time to perform the two/2 status check.

EC2 instance status

Open the EC2 instance properties, and click on Connect.

EC2 instance properties

In the Connect to the instance page, click on RDP client. From here, download the remote desktop file.

RDP Client

Click on Go Countersign, input your PEM secret fundamental, and information technology displays the password on the screen. You lot require this password for an RDP session on the EC2 Windows server.

Get password for Windows RDP

Specify your administrator password and become an RDP session, as shown beneath.

Specify your administrator password

This EC2 example is having preinstalled SQL Server 2019. Therefore, for a sample database, browse to Microsoft docs and download the [AdventureWorks2019.bak] file.

download [AdventureWorks2019.bak] file

Restore the [AdventureWorks2019] database in SQL Server on EC2 case with the post-obit script.

Restore the [AdventureWorks2019] database

Before starting the database migration, yous can take a Total database fill-in for the [AdventureWorks2019] database. Nosotros will restore this backup on the AWS RDS SQL Server.

Take DB full backup

SQL Server uses the log sequence number for the transaction log records in the database. We can use this LSN in the database migration job configurations.

Execute this script on the [AdvenutreWorks2019] database and note-downward the LSN value.

transaction log records LSN

Restore the full database backup on the AWS RDS SQL Server

In this step, we volition restore the total fill-in taken earlier in the AWS RDS SQL Server instance. Earlier you movement forrard, you should have the post-obit prerequisites.

  • AWS S3 bucket: Hither, I use the S3 bucket [SQLShackDemo17112020]
  • RDS SQL Server: Here, I employ the RDS instance [myrdssql] with SQL Server 2019

AWS RDS SQL Server

Both the S3 bucket and RDS example should exist in an AWS region.

Upload the backup file in the AWS S3 bucket

Open up the AWS S3 bucket [SQLShackDemo17112020] and upload the full backup of the [AdventureWorks2019] database.

Upload the backup file in the AWS S3 bucket

Restore database fill-in from S3 to RDS SQL

We need to restore the backup stored from the S3 bucket to AWS RDS SQL Server. To enable the restoration, practise the following tasks.

  • Create an IAM policy and part to integrate S3 saucepan and RDS
  • Create an pick group with SQLSERVER_BACKUP_RESTORE, modify the RDS example to use the new option grouping

You tin can refer to the article, AWS RDS SQL Server migration using native backups for detailed instructions.

In the beneath script, specify the ARN for backup stored in AWS S3 saucepan and execute on the RDS instance.

Information technology initiates a database restoration task and returns the job id.

Restore database backup from S3 to RDS SQL

Track the database restoration task condition using the post-obit script.

As shown beneath, the database restoration task is successful for the [AdventureWorks2019] database. RDS task status

Creating an AWS DMS replication instance

We need to configure an AWS DMS replication example for database migration. In the AWS Web Panel, launch Database Migration Service. It gives the following AWS DMS dashboard.

AWS DMS replication instance

Click on Create replication case. On the replication instance page, enter the following information.

  • DMS instance proper name
  • Descriptive Amazon resource name (Optional)
  • Description
  • Choose an instance class
  • AWS DMS version: You can go with the prepopulated DMS version

AWS RDS SQL Server Create Replication instance

  • VPC: Select the Amazon Virtual Private deject for your replication instance
  • Multi-AZ: If yous want to configure the high availability for the DMS example, cull the Multi-AZ configuration
  • Publicly accessible: If you want to assign a public IP address to your AWS DMS instance, put a tick on the checkbox

We can go with the default configuration in the remaining options. Click on Create.

VPC configuration

Information technology creates the AWS DMS instance in a few minutes. Its condition should be Available before we proceed to the next step.

AWS DMS instance status

Configure the Source and Target endpoints

We need endpoints for both the source (On-premise or SQL Server on EC2 instance) and Target (RDS SQL Server) for the database migration task.

Configure the Source and Target endpoints

In the AWS DMS, click on the Endpoints.

Source Endpoint
  • Endpoint type: Source endpoint
  • Endpoint identified: Give a unique proper noun for your source endpoint
  • Descriptive Amazon Resource Name( optional)
  • Source engine: Choose Microsoft SQL Server
  • Server name: Specify the public DNS name of your AWS EC2 instance or the FQDN of your on-premise SQL Server.
  • Port: Specify the SQL Server network port. The default port is 1433.
  • User name and countersign: Enter the credentials for connecting to SQL Server example. Information technology should accept sysadmin permissions so that DMS can configure the replication or Change data capture(CDC) procedure.
  • Database name: Enter the source database name that we want to migrate to the AWS RDS SQL Server.

Source Endpoint

Specify VPC for your AWS account and click on Create endpoint.

VPC

Open the source endpoint and go-to connection. Click on Test Connection; its status should be Successful, as shown below.

Test Connection,

Target Endpoint

Similar to the source endpoint, we need to create the target endpoint for AWS RDS SQL Server.

  • RDS instance: Put a check on Select RDS DB instance and cull your target RDS from the drop-down

The remaining configurations are similar to the source endpoint.

Target Endpoint

Target Endpoint configuration

In one case the target endpoint for the RDS instance is created, its test connection should be successful, as shown below.

Test connection status

Create a database migration task

In the AWS DMS, navigate to database migration tasks. Nosotros exercise not have whatever existing DMS chore. Therefore, it shows the blank screen.

Click on Create database migration chore.

Create a database migration task

In the database migration task, do the following configurations.

  • Chore identifier: Requite a unique name for the DMS task
  • Descriptive Amazon Resource Proper noun (optional)
  • Replication example: Select the DMS replication instance from the driblet-down
  • Source database endpoint: Choose the source database endpoint from the drop-down
  • Target database endpoint: Cull the target database endpoint from the drop-down value
  • Migration type: Nosotros already restored the total backup from the source to RDS SQL Server. Therefore, choose the selection – Replicate information changes merely

    DB migration task status

  • In the CDC state mode, choose selection Specify log sequence number and enter the LSN in the System change number box
  • In the Target tabular array preparation fashion, cull to Do Zippo
  • Put a cheque on Enable Data Validation. Using this pick, AWS DMS compares data at source and target databases. It also ensures that data migration is successful and consistent

    AWS RDS SQL Server CDC start mode

  • In the Selection rules, we can filter the objects for specific schema, table or pattern. Hither, we did not specify any specific schema or pattern. Therefore information technology replicates complete data changes

Selection rules

Click on the Create task button.

Migration task startup

It starts configuration for database migration chore.

Status for DMS task

Its status changes to replication ongoing after a few minutes.

Replication ongoing

Y'all can click on tabular array statistics. It populates all tables. Hither, you can monitor the inserts, delete, updates, DDL, full rows once the table is validated on both source and target. Information technology takes a few minutes for populating the information depending upon your database size.

Table validations

You can also become back to your source case and view that a local publication exists. The AWS database migration service configures it for populating data betwixt the source and destinations.

Publication on source instance

AWS DMS uses the replication and CDC for the database migrations.

  • SQL Server replication for capturing data changes for tables with primary keys. AWS DMS automatically configures the replication if you provide an endpoint user with the sysadmin permissions
  • Change Data Capture ( CDC) for tables without primary keys. You lot demand to enable the MSCDC at the database level and add the tables manually

Refer to the commodity, Using a Microsoft SQL Server database every bit a source for AWS DMS for more details.

Information technology continuously replicates the data from the source to the target AWS RDS SQL Server. You can stop data replication during the cutting-off time and betoken your awarding to connect with RDS endpoints.

Conclusion

In this commodity, we explored the AWS database migration service for migrating a database from source on-premise or SQL Server on EC2 instance to AWS RDS SQL Server with zero reanimation. It is suitable for disquisitional databases where nosotros cannot afford much downtime.

  • Author
  • Recent Posts

Rajendra Gupta

beattydeme1968.blogspot.com

Source: https://www.sqlshack.com/migrating-your-on-premises-sql-databases-to-aws-rds-sql-server-using-aws-dms/

0 Response to "How to Upload Database to Aws Postgres Rdb"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel