您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

手动将经典 VM 从 VHD 迁移到新的 ARM 托管磁盘 VMManually migrate a Classic VM to a new ARM Managed Disk VM from the VHD

本部分有助于将现有 Azure VM 从经典部署模型迁移到 Resource Manager 部署模型中的托管磁盘This section helps you to migrate your existing Azure VMs from the classic deployment model to Managed Disks in the Resource Manager deployment model.

计划迁移到托管磁盘Plan for the migration to Managed Disks

本部分有助于在 VM 和磁盘类型方面做出最佳决策。This section helps you to make the best decision on VM and disk types.

位置Location

选择 Azure 托管磁盘的可用位置。Pick a location where Azure Managed Disks are available. 如果要迁移到高级托管磁盘,还请确保高级存储在计划迁移到的目标区域中可用。If you are migrating to Premium Managed Disks, also ensure that Premium storage is available in the region where you are planning to migrate to. 有关可用位置的最新信息,请参阅 Azure 服务(按区域)See Azure Services byRegion for up-to-date information on available locations.

VM 大小VM sizes

如果要迁移到高级托管磁盘,必须将 VM 的大小更新为该 VM 所在区域中提供的支持高级存储的大小。If you are migrating to Premium Managed Disks, you have to update the size of the VM to Premium Storage capable size available in the region where VM is located. 查看支持高级存储的 VM 大小。Review the VM sizes that are Premium Storage capable. 虚拟机大小中列出了 Azure VM 大小规范。The Azure VM size specifications are listed in Sizes for virtual machines. 查看适用于高级存储的虚拟机的性能特征并选择最适合工作负荷的 VM 大小。Review the performance characteristics of virtual machines that work with Premium Storage and choose the most appropriate VM size that best suits your workload. 确保 VM 上有足够的带宽来驱动磁盘通信。Make sure that there is sufficient bandwidth available on your VM to drive the disk traffic.

磁盘大小Disk sizes

高级托管磁盘Premium Managed Disks

有七种类型的高级托管磁盘可用于 VM,每种磁盘都具有特定的 IOPS 和吞吐量限制。There are seven types of premium Managed disks that can be used with your VM and each has specific IOPs and throughput limits. 根据应用程序在容量、性能、可伸缩性和峰值负载方面的需要为 VM 选择高级磁盘类型时,需要考虑这些限制。Consider these limits when choosing the Premium disk type for your VM based on the needs of your application in terms of capacity, performance, scalability, and peak loads.

高级磁盘类型Premium Disks Type P4P4 P6P6 P10P10 P20P20 P30P30 P40P40 P50P50
磁盘大小Disk size 128 GB128 GB 512 GB512 GB 128 GB128 GB 512 GB512 GB 1024 GB (1 TB)1024 GB (1 TB) 2048 GB (2 TB)2048 GB (2 TB) 4095 GB (4 TB)4095 GB (4 TB)
每个磁盘的 IOPSIOPS per disk 120120 240240 500500 23002300 50005000 75007500 75007500
每个磁盘的吞吐量Throughput per disk 每秒 25 MB25 MB per second 每秒 50 MB50 MB per second 每秒 100 MB100 MB per second 每秒 150 MB150 MB per second 每秒 200 MB200 MB per second 每秒 250 MB250 MB per second 每秒 250 MB250 MB per second

标准托管磁盘Standard Managed Disks

有七种类型的标准托管磁盘可用于 VM。There are seven types of Standard Managed disks that can be used with your VM. 每种类型的磁盘具有不同的容量,但具有相同的 IOPS 和吞吐量限制。Each of them have different capacity but have same IOPS and throughput limits. 根据应用程序的容量需求选择标准托管磁盘的类型。Choose the type of Standard Managed disks based on the capacity needs of your application.

标准磁盘类型Standard Disk Type S4S4 S6S6 S10S10 S20S20 S30S30 S40S40 S50S50
磁盘大小Disk size 30 GB30 GB 64 GB64 GB 128 GB128 GB 512 GB512 GB 1024 GB (1 TB)1024 GB (1 TB) 2048 GB (2 TB)2048 GB (2TB) 4095 GB (4 TB)4095 GB (4 TB)
每个磁盘的 IOPSIOPS per disk 500500 500500 500500 500500 500500 500500 500500
每个磁盘的吞吐量Throughput per disk 每秒 60 MB60 MB per second 每秒 60 MB60 MB per second 每秒 60 MB60 MB per second 每秒 60 MB60 MB per second 每秒 60 MB60 MB per second 每秒 60 MB60 MB per second 每秒 60 MB60 MB per second

磁盘缓存策略Disk caching policy

高级托管磁盘Premium Managed Disks

默认情况下,所有高级数据磁盘的磁盘缓存策略都是“只读”,所有附加到 VM 的高级操作系统都是“读写”。By default, disk caching policy is Read-Only for all the Premium data disks, and Read-Write for the Premium operating system disk attached to the VM. 为使应用程序的 IO 达到最佳性能,建议使用此配置设置。This configuration setting is recommended to achieve the optimal performance for your application’s IOs. 对于频繁写入或只写的磁盘(例如 SQL Server 日志文件),禁用磁盘缓存可获得更佳的应用程序性能。For write-heavy or write-only data disks (such as SQL Server log files), disable disk caching so that you can achieve better application performance.

定价Pricing

查看托管磁盘定价Review the pricing for Managed Disks. 高级托管磁盘的定价与高级非托管磁盘相同。Pricing of Premium Managed Disks is same as the Premium Unmanaged Disks. 但标准托管磁盘的定价与标准非托管磁盘不同。But pricing for Standard Managed Disks is different than Standard Unmanaged Disks.

清单Checklist

  1. 如果要迁移到高级托管磁盘,请确保它在要迁移到的区域中可用。If you are migrating to Premium Managed Disks, make sure it is available in the region you are migrating to.

  2. 决定要使用的新 VM 系列。Decide the new VM series you will be using. 如果要迁移到高级托管磁盘,则应支持高级存储。It should be a Premium Storage capable if you are migrating to Premium Managed Disks.

  3. 确定将使用的确切 VM 大小,将迁移到的区域应支持此大小。Decide the exact VM size you will use which are available in the region you are migrating to. VM 大小需要足够大以支持所拥有的数据磁盘数。VM size needs to be large enough to support the number of data disks you have. 例如,如果有四个数据磁盘,则 VM 必须至少有两个内核。For example, if you have four data disks, the VM must have two or more cores. 此外,还应考虑处理能力、内存和网络带宽需求。Also, consider processing power, memory and network bandwidth needs.

  4. 手边具备当前 VM 详细信息,包括磁盘和对应的 VHD blob 的列表。Have the current VM details handy, including the list of disks and corresponding VHD blobs.

让应用程序做好停机准备。Prepare your application for downtime. 为了执行净迁移,必须停止当前系统中的所有处理。To do a clean migration, you have to stop all the processing in the current system. 只有这样才能使其处于一致状态,可以将该状态迁移到新的平台。Only then you can get it to consistent state which you can migrate to the new platform. 停机持续时间取决于要迁移的磁盘中的数据量。Downtime duration depends on the amount of data in the disks to migrate.

迁移 VMMigrate the VM

让应用程序做好停机准备。Prepare your application for downtime. 为了执行净迁移,必须停止当前系统中的所有处理。To do a clean migration, you have to stop all the processing in the current system. 只有这样才能使其处于一致状态,可以将该状态迁移到新的平台。Only then you can get it to consistent state which you can migrate to the new platform. 停机持续时间取决于要迁移的磁盘中的数据量。Downtime duration depends the amount of data in the disks to migrate.

  1. 首先,设置公共参数:First, set the common parameters:

    $resourceGroupName = 'yourResourceGroupName'
    
    $location = 'your location' 
    
    $virtualNetworkName = 'yourExistingVirtualNetworkName'
    
    $virtualMachineName = 'yourVMName'
    
    $virtualMachineSize = 'Standard_DS3'
    
    $adminUserName = "youradminusername"
    
    $adminPassword = "yourpassword" | ConvertTo-SecureString -AsPlainText -Force
    
    $imageName = 'yourImageName'
    
    $osVhdUri = 'https://storageaccount.blob.core.windows.net/vhdcontainer/osdisk.vhd'
    
    $dataVhdUri = 'https://storageaccount.blob.core.windows.net/vhdcontainer/datadisk1.vhd'
    
    $dataDiskName = 'dataDisk1'
    
  2. 使用经典 VM 中的 VHD 创建托管 OS 磁盘。Create a managed OS disk using the VHD from the classic VM.

    确保已为 $osVhdUri 参数提供 OS VHD 的完整 URI。Ensure that you have provided the complete URI of the OS VHD to the $osVhdUri parameter. 此外,根据要迁移到的磁盘类型(高级或标准),输入 -AccountType 作为 PremiumLRSStandardLRSAlso, enter -AccountType as PremiumLRS or StandardLRS based on type of disks (Premium or Standard) you are migrating to.

    $osDisk = New-AzureRmDisk -DiskName $osDiskName -Disk (New-AzureRmDiskConfig '
    -AccountType PremiumLRS -Location $location -CreateOption Import -SourceUri $osVhdUri) '
    -ResourceGroupName $resourceGroupName
    
  3. 将 OS 磁盘附加到新的 VM。Attach the OS disk to the new VM.

    $VirtualMachine = New-AzureRmVMConfig -VMName $virtualMachineName -VMSize $virtualMachineSize
    $VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -ManagedDiskId $osDisk.Id '
    -StorageAccountType PremiumLRS -DiskSizeInGB 128 -CreateOption Attach -Windows
    
  4. 从数据 VHD 文件中创建托管数据磁盘,并将其添加到新的 VM。Create a managed data disk from the data VHD file and add it to the new VM.

    $dataDisk1 = New-AzureRmDisk -DiskName $dataDiskName -Disk (New-AzureRmDiskConfig '
    -AccountType PremiumLRS -Location $location -CreationDataCreateOption Import '
    -SourceUri $dataVhdUri ) -ResourceGroupName $resourceGroupName
    
    $VirtualMachine = Add-AzureRmVMDataDisk -VM $VirtualMachine -Name $dataDiskName '
    -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun 1
    
  5. 通过设置公共 IP、虚拟网络和 NIC 创建新的 VM。Create the new VM by setting public IP, Virtual Network and NIC.

    $publicIp = New-AzureRmPublicIpAddress -Name ($VirtualMachineName.ToLower()+'_ip') '
    -ResourceGroupName $resourceGroupName -Location $location -AllocationMethod Dynamic
    
    $vnet = Get-AzureRmVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName
    
    $nic = New-AzureRmNetworkInterface -Name ($VirtualMachineName.ToLower()+'_nic') '
    -ResourceGroupName $resourceGroupName -Location $location -SubnetId $vnet.Subnets[0].Id '
    -PublicIpAddressId $publicIp.Id
    
    $VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $nic.Id
    
    New-AzureRmVM -VM $VirtualMachine -ResourceGroupName $resourceGroupName -Location $location
    

备注

本指南可能未涵盖支持应用程序所要执行的其他步骤。There may be additional steps necessary to support your application that is not be covered by this guide.

后续步骤Next steps