使用 Azure 数据库迁移服务的先决条件概述Overview of prerequisites for using the Azure Database Migration Service

若要确保 Azure 数据库迁移服务在执行数据库迁移时顺利运行,需要满足几个先决条件。There are several prerequisites required to ensure Azure Database Migration Service runs smoothly when performing database migrations. 某些先决条件适用于该服务支持的所有方案(源/目标对),而其他先决条件则是特定方案所特有的。Some of the prerequisites apply across all scenarios (source-target pairs) supported by the service, while other prerequisites are unique to a specific scenario.

以下各部分列出了与使用 Azure 数据库迁移服务关联的先决条件。Prerequisites associated with using the Azure Database Migration Service are listed in the following sections.

在不同迁移方案中通用的先决条件Prerequisites common across migration scenarios

在所有支持的迁移方案中通用的 Azure 数据库迁移服务先决条件包括需要:Azure Database Migration Service prerequisites that are common across all supported migration scenarios include the need to:

  • 使用 Azure 资源管理器部署模型创建 Azure 数据库迁移服务的 Azure 虚拟网络,它将使用 ExpressRouteVPN 为本地源服务器提供站点到站点连接。Create an Azure Virtual Network for Azure Database Migration Service by using the Azure Resource Manager deployment model, which provides site-to-site connectivity to your on-premises source servers by using either ExpressRoute or VPN.

  • 确保虚拟网络的网络安全组 (NSG) 规则未阻止以下通信端口:443、53、9354、445、12000。Ensure that your virtual network Network Security Group (NSG) rules don't block the following communication ports 443, 53, 9354, 445, 12000. 有关虚拟网络 NSG 流量筛选的更多详细信息,请参阅使用网络安全组筛选网络流量一文。For more detail on virtual network NSG traffic filtering, see the article Filter network traffic with network security groups.

  • 在源数据库的前面使用了防火墙设备时,可能需要添加防火墙规则以允许 Azure 数据库迁移服务访问要迁移的源数据库。When using a firewall appliance in front of your source database(s), you may need to add firewall rules to allow Azure Database Migration Service to access the source database(s) for migration.

  • 配置针对数据库引擎访问的 Windows 防火墙Configure your Windows Firewall for database engine access.

  • 按照启用或禁用服务器网络协议一文中的说明启用 TCP/IP 协议(在安装 SQL Server Express 时,会默认禁用它)。Enable the TCP/IP protocol, which is disabled by default during SQL Server Express installation, by following the instructions in the article Enable or Disable a Server Network Protocol.

    重要

    创建 Azure 数据库迁移服务实例需要访问通常不在同一资源组中的虚拟网络设置。Creating an instance of Azure Database Migration Service requires access to virtual network settings that are normally not within the same resource group. 因此,创建 DMS 实例的用户需要订阅级别的权限。As a result, the user creating an instance of DMS requires permission at subscription level. 若要创建所需的角色(你可以根据需要分配这些角色),请运行以下脚本:To create the required roles, which you can assign as needed, run the following script:

    
    $readerActions = `
    "Microsoft.Network/networkInterfaces/ipConfigurations/read", `
    "Microsoft.DataMigration/*/read", `
    "Microsoft.Resources/subscriptions/resourceGroups/read"
    
    $writerActions = `
    "Microsoft.DataMigration/services/*/write", `
    "Microsoft.DataMigration/services/*/delete", `
    "Microsoft.DataMigration/services/*/action", `
    "Microsoft.Network/virtualNetworks/subnets/join/action", `
    "Microsoft.Network/virtualNetworks/write", `
    "Microsoft.Network/virtualNetworks/read", `
    "Microsoft.Resources/deployments/validate/action", `
    "Microsoft.Resources/deployments/*/read", `
    "Microsoft.Resources/deployments/*/write"
    
    $writerActions += $readerActions
    
    # TODO: replace with actual subscription IDs
    $subScopes = ,"/subscriptions/00000000-0000-0000-0000-000000000000/","/subscriptions/11111111-1111-1111-1111-111111111111/"
    
    function New-DmsReaderRole() {
    $aRole = [Microsoft.Azure.Commands.Resources.Models.Authorization.PSRoleDefinition]::new()
    $aRole.Name = "Azure Database Migration Reader"
    $aRole.Description = "Lets you perform read only actions on DMS service/project/tasks."
    $aRole.IsCustom = $true
    $aRole.Actions = $readerActions
    $aRole.NotActions = @()
    
    $aRole.AssignableScopes = $subScopes
    #Create the role
    New-AzRoleDefinition -Role $aRole
    }
    
    function New-DmsContributorRole() {
    $aRole = [Microsoft.Azure.Commands.Resources.Models.Authorization.PSRoleDefinition]::new()
    $aRole.Name = "Azure Database Migration Contributor"
    $aRole.Description = "Lets you perform CRUD actions on DMS service/project/tasks."
    $aRole.IsCustom = $true
    $aRole.Actions = $writerActions
    $aRole.NotActions = @()
    
      $aRole.AssignableScopes = $subScopes
    #Create the role
    New-AzRoleDefinition -Role $aRole
    }
    
    function Update-DmsReaderRole() {
    $aRole = Get-AzRoleDefinition "Azure Database Migration Reader"
    $aRole.Actions = $readerActions
    $aRole.NotActions = @()
    Set-AzRoleDefinition -Role $aRole
    }
    
    function Update-DmsConributorRole() {
    $aRole = Get-AzRoleDefinition "Azure Database Migration Contributor"
    $aRole.Actions = $writerActions
    $aRole.NotActions = @()
    Set-AzRoleDefinition -Role $aRole
    }
    
    # Invoke above functions
    New-DmsReaderRole
    New-DmsContributorRole
    Update-DmsReaderRole
    Update-DmsConributorRole
    

将 SQL Server 迁移到 Azure SQL 数据库的先决条件Prerequisites for migrating SQL Server to Azure SQL Database

除了普遍适用于所有迁移方案的 Azure 数据库迁移服务先决条件外,还有特别适用于个别方案的先决条件。In addition to Azure Database Migration Service prerequisites that are common to all migration scenarios, there are also prerequisites that apply specifically to one scenario or another.

使用 Azure 数据库迁移服务执行 SQL Server 到 Azure SQL 数据库的迁移时,除了普遍适用于所有迁移方案的先决条件外,还必须满足以下附加先决条件:When using the Azure Database Migration Service to perform SQL Server to Azure SQL Database migrations, in addition to the prerequisites that are common to all migration scenarios, be sure to address the following additional prerequisites:

  • 按照使用 Azure 门户在 Azure SQL 数据库中创建数据库一文中的详细说明创建 Azure SQL 数据库实例。Create an instance of Azure SQL Database instance, which you do by following the detail in the article Create a database in Azure SQL Database in the Azure portal.

  • 下载并安装数据迁移助手 v3.3 或更高版本。Download and install the Data Migration Assistant v3.3 or later.

  • 打开 Windows 防火墙,使 Azure 数据库迁移服务能够访问源 SQL Server(默认情况下为 TCP 端口 1433)。Open your Windows Firewall to allow the Azure Database Migration Service to access the source SQL Server, which by default is TCP port 1433.

  • 如果使用动态端口运行多个命名 SQL Server 实例,则可能需要启用 SQL Browser 服务并允许通过防火墙访问 UDP 端口 1434,以便 Azure 数据库迁移服务可连接到源服务器上的命名实例。If you are running multiple named SQL Server instances using dynamic ports, you may wish to enable the SQL Browser Service and allow access to UDP port 1434 through your firewalls so that the Azure Database Migration Service can connect to a named instance on your source server.

  • 为 SQL 数据库创建服务器级防火墙规则,以允许 Azure 数据库迁移服务访问目标数据库。Create a server-level firewall rule for SQL Database to allow the Azure Database Migration Service access to the target databases. 提供用于 Azure 数据库迁移服务的虚拟网络子网范围。Provide the subnet range of the virtual network used for the Azure Database Migration Service.

  • 确保用于连接到源 SQL Server 实例的凭据具有 CONTROL SERVER 权限。Ensure that the credentials used to connect to source SQL Server instance have CONTROL SERVER permissions.

  • 确保用于连接到目标数据库的凭据具有目标数据库的 CONTROL DATABASE 权限。Ensure that the credentials used to connect to target database have CONTROL DATABASE permission on the target database.

    备注

    有关使用 Azure 数据库迁移服务执行从 SQL Server 到 Azure SQL 数据库的迁移所需的先决条件的完整列表,请参阅教程将 SQL Server 迁移到 Azure SQL 数据库For a complete listing of the prerequisites required to use the Azure Database Migration Service to perform migrations from SQL Server to Azure SQL Database, see the tutorial Migrate SQL Server to Azure SQL Database.

将 SQL Server 迁移到 Azure SQL 托管实例的先决条件Prerequisites for migrating SQL Server to Azure SQL Managed Instance

  • 按照在 Azure 门户中创建 Azure SQL 托管实例一文中的详述创建 SQL 托管实例。Create a SQL Managed Instance by following the detail in the article Create a Azure SQL Managed Instance in the Azure portal.

  • 打开防火墙以允许 Azure 数据库迁移服务 IP 地址或子网范围的端口 445 上的 SMB 流量。Open your firewalls to allow SMB traffic on port 445 for the Azure Database Migration Service IP address or subnet range.

  • 打开 Windows 防火墙,使 Azure 数据库迁移服务能够访问源 SQL Server(默认情况下为 TCP 端口 1433)。Open your Windows Firewall to allow the Azure Database Migration Service to access the source SQL Server, which by default is TCP port 1433.

  • 如果使用动态端口运行多个命名 SQL Server 实例,则可能需要启用 SQL Browser 服务并允许通过防火墙访问 UDP 端口 1434,以便 Azure 数据库迁移服务可连接到源服务器上的命名实例。If you are running multiple named SQL Server instances using dynamic ports, you may wish to enable the SQL Browser Service and allow access to UDP port 1434 through your firewalls so that the Azure Database Migration Service can connect to a named instance on your source server.

  • 确保用于连接源 SQL Server 和目标托管实例的登录名是 sysadmin 服务器角色的成员。Ensure that the logins used to connect the source SQL Server and target Managed Instance are members of the sysadmin server role.

  • 创建网络共享,供 Azure 数据库迁移服务用来备份源数据库。Create a network share that the Azure Database Migration Service can use to back up the source database.

  • 确保运行源 SQL Server 实例的服务帐户对你创建的网络共享拥有写入权限,并且源服务器的计算机帐户具有对同一共享的读/写访问权限。Ensure that the service account running the source SQL Server instance has write privileges on the network share that you created and that the computer account for the source server has read/write access to the same share.

  • 请记下在前面创建的网络共享中拥有完全控制权限的 Windows 用户(和密码)。Make a note of a Windows user (and password) that has full control privilege on the network share that you previously created. Azure 数据库迁移服务可模拟用户凭据,将备份文件上传到 Azure 存储容器,以执行还原操作。The Azure Database Migration Service impersonates the user credential to upload the backup files to Azure Storage container for restore operation.

  • 通过采用使用存储资源管理器管理 Azure Blob 存储资源一文中的步骤,创建 blob 容器并检索其 SAS URI。Create a blob container and retrieve its SAS URI by using the steps in the article Manage Azure Blob Storage resources with Storage Explorer. 在创建 SAS URI 时,务必在策略窗口选择所有权限(读取、写入、删除、列出)。Be sure to select all permissions (Read, Write, Delete, List) on the policy window while creating the SAS URI.

    备注

    有关使用 Azure 数据库迁移服务执行从 SQL Server 到 SQL 托管实例的迁移所需的先决条件的完整列表,请参阅教程将 SQL Server 迁移到 SQL 托管实例For a complete listing of the prerequisites required to use the Azure Database Migration Service to perform migrations from SQL Server to SQL Managed Instance, see the tutorial Migrate SQL Server to SQL Managed Instance.

后续步骤Next steps

有关 Azure 数据库迁移服务和区域可用性的概述,请参阅什么是 Azure 数据库迁移服务一文。For an overview of the Azure Database Migration Service and regional availability, see the article What is the Azure Database Migration Service.