Saturday, July 29, 2023

 Using the Azure Database Migration Service to transfer data from source to destination MySQL database servers. 

When we want to transfer data and schema between databases whether they are on-premises or in the cloud, the azure data migration service instance comes helpful.  

Some highlights: 

  1. One instance works across all subscriptions. 

  1. Can transfer between on-premises and cloud and cloud to cloud. 

  1. Pay-per-use billing. 

  1. Provides a wizard to create data transfer activity. 

Some cons: 

  1. Limited features via IaC as compared to the portal but enough to get by. 

  1. Not recommended for developer instances or tiny databases that can be exported and imported via mysqldump. 

  1. binlog_expire_logs_seconds must be set to non-zero value on source server. 

The steps to perform the data transfer activity between the source and destination MySQL servers involves: 

  1. Create a source mysql instance mysql-src-1 in rg-mysql-1 

  1. Create a database and add a table to mysql-src-1 

  1. Create a destination mysql instance mysql-dest-1 in rg-mysql-1 

  1. Deploy the DMS service instance and project. 

  1. Create and run an activity to transfer data. 

  1. Verify the data. 

IaC: 

resource "azurerm_database_migration_service" "single-to-flexible-dms" { 

  name                = var.name 

  location            = var.location 

  resource_group_name = var.resource_group_name 

  subnet_id           = var.subnet_id 

  sku_name            = var.sku_name 

  tags                = var.tags 

} 

 

resource "azurerm_database_migration_project" "dms-project" { 

  name                = format("prj-%s", azurerm_database_migration_service.single-to-flexible-dms.name) 

  service_name        = azurerm_database_migration_service.single-to-flexible-dms.name 

  resource_group_name = azurerm_database_migration_service.single-to-flexible-dms.resource_group_name 

  location            = azurerm_database_migration_service.single-to-flexible-dms.location 

  source_platform     = try(var.source_platform, "SQL") 

  target_platform     = try(var.target_platform, "SQLDB") 

  tags                = azurerm_database_migration_service.single-to-flexible-dms.tags 

  depends_on = [ 

    azurerm_database_migration_service.single-to-flexible-dms 

  ] 

} 

No comments:

Post a Comment