Here’s a step-by-step guide to migrating from a single server to a flexible server in Azure using Azure Database Migration Service (DMS) for PostgreSQL.
Step 1: Prepare the Source and Target Servers
Source Server: Ensure that your single server PostgreSQL instance is running properly and that you have access credentials (username, password, IP, etc.).
Target Server: Set up an Azure PostgreSQL Flexible Server as the target environment.
In the Azure Portal, go to Azure Database for PostgreSQL and select Flexible Server.
Configure the necessary settings, including compute and storage, networking options, and database configurations.
Make a note of the connection details for the new flexible server.
Step 2: Set Up Network Access
Ensure network access between the source single server and the target flexible server. Both servers must be able to communicate over the network.
If both are in Azure, they must be in the same virtual network or properly peered.
If the source is outside Azure, configure the firewall rules for both instances to allow IP access.
Step 3: Install and Configure Azure Database Migration Service (DMS)
Create DMS Instance:
Go to the Azure Portal and search for Azure Database Migration Service.
Click on Create to configure a new DMS instance.
Select the resource group and region where DMS will be deployed.
Choose the appropriate pricing tier (depending on the migration scale).
Provision the DMS Instance:
Once created, configure the networking for DMS to access both the source and target databases. You may need to add network rules or create peering if necessary.
Step 4: Configure PostgreSQL DMS Migration Project
Create a Migration Project:
In the DMS dashboard, create a new migration project.
Choose PostgreSQL as the database type for both the source and target.
Select Online Data Migration if you want minimal downtime.
Provide Source and Target Details:
Source Server: Enter the connection details for your PostgreSQL single server (hostname, port, username, password).
Target Server: Enter the connection details for your Flexible Server.
Choose Databases to Migrate:
Select the databases on the source server that you want to migrate to the flexible server.
DMS will allow you to select specific databases or the entire instance.
Step 5: Start Data Migration
Run the Migration:
Start the migration process by clicking Start Migration.
DMS will handle the data movement, and it can take some time depending on the size of your databases.
Monitor the Migration:
Go to the Migration Status in the DMS project to monitor progress.
You can see the state of individual databases and review any errors that occur during the migration process.
Step 6: Post-Migration Tasks
Validation:
Once the migration completes, validate the data in the target flexible server to ensure everything transferred properly.
Compare schema and data between the source and the target.
Switch Applications:
Once validation is complete, update your application connection strings to point to the new flexible server.
Test the application to ensure it works with the new database.
Decommission Source Server:
After ensuring that the new setup is running correctly, decommission the old single server if it's no longer needed.
Commands for Migration (CLI)
While most of the migration tasks are done through the Azure portal, some command-line steps can be helpful:
Create DMS using Azure CLI:
bash
az dms create --resource-group <ResourceGroup> --name <DMSInstanceName> --location <AzureRegion> --sku-name Premium_4vCores --subnet <subnetResourceId>
Start a migration task:
bash
az dms project task create --resource-group <ResourceGroup> --service-name <DMSInstanceName> --project-name <ProjectName> --name <TaskName> --database-options-json "[{'name':'<DatabaseName>', 'target_database_name':'<TargetDatabaseName>'}]"
Monitor migration task:
bash
az dms project task show --resource-group <ResourceGroup> --service-name <DMSInstanceName> --project-name <ProjectName> --name <TaskName>
Комментарии