把ASM下的HDD VM转换成ARM下Managed Disk的SSD VM

在ASM下,要把HDD的VM转换成SSD的VM步骤非常复杂。需要手工把Disk从普通存储账户复制到高级存储账户。再通过这个Disk创建VM。

目前在有了ASM到ARM的迁移工具,以及Managed Disk后,这个工作就简单了。

下面将介绍如何实现从ASM的HDD VM迁移到ARM模式下的Managed Disk的SSD VM。

一 ASM下的VM迁移到ARM下

1 Cli版本

这个工作,可以用powershell或Azure xplate cli,我采用的cli:

C:\Users\hengwei>azure
info:             _    _____   _ ___ ___
info:            /_\  |_  / | | | _ \ __|
info:      _ ___/ _ \__/ /| |_| |   / _|___ _ _
info:    (___  /_/ \_\/___|\___/|_|_\___| _____)
info:       (_______ _ _)         _ ______ _)_ _
info:              (______________ _ )   (___ _ _)
info:
info:    Microsoft Azure: Microsoft's Cloud Platform
info:
info:    Tool version 0.10.13

版本是0.10.13.

2 查看VNet和VM信息

C:\Users\hengwei>azure network vnet list
info:    Executing command network vnet list
+ Looking up the virtual network sites
data:    Name    Location    Affinity group  State    Address space   Subnets count  VPN Gateway address
data:    ------  ----------  --------------  -------  --------------  -------------  -------------------
data:    hwfgfw  China East                  Created  10.0.0.0/8      1
data:    hws2p   China East                  Created  192.168.1.0/24  1
info:    network vnet list command OK

 

C:\Users\hengwei>azure vm list
info:    Executing command vm list
+ Getting virtual machines
data:    Name        Status              Location    DNS Name                     IP Address
data:    ----------  ------------------  ----------  ---------------------------  -----------
data:    mp-ngfwf-1  StoppedDeallocated  China East  mp-ngfwf-1.chinacloudapp.cn
data:    hws2p       ReadyRole           China East  hws2p01.chinacloudapp.cn     192.168.1.4
info:    vm list command OK

 

3 迁移

迁移分三步:

C:\Users\hengwei>azure network vnet  validate-migration hws2p
info:    Executing command network vnet validate-migration
data:    Information                     : Virtual Network hws2p is eligible for migration.
data:    Information                     : Deployment hws2p in Cloud Service hws2p01 is eligible for migration.
data:    Information                     : VM hws2p in Deployment hws2p within Cloud Service hws2p01 is eligible for migration.
info:    network vnet validate-migration command OK

C:\Users\hengwei>azure network vnet prepare-migration hws2p
info:    Executing command network vnet prepare-migration
info:    network vnet prepare-migration command OK

C:\Users\hengwei>azure network vnet commit-migration hws2p
info:    Executing command network vnet commit-migration
info:    network vnet commit-migration command OK

此时Vnet和VM都已经迁移到ARM模式下了。

 

二 把ARM模式下的VM转换成Managed Disk

1 CLI版本

这个工作的Azure采用的是Azure CLI2.0版本

root@hw-surfacebook:~# az --version
azure-cli (2.0.7)

2 查看VM

root@hw-surfacebook:~# az vm list -o table
Name       ResourceGroup     Location
---------  ----------------  ----------
hwmdt      HWNAVS            chinanorth
hwcisco    CISCOROUTER       chinaeast
hwazcopy   HWAZCOPY          chinaeast
hwmt       HWMT              chinaeast
hwmt02     HWMT              chinaeast
hws2p      HWS2P01-MIGRATED  chinaeast
hwmysql01  HWWAF             chinaeast
hwwaf02    HWWAF             chinaeast
hwwaf03    HWWAF             chinaeast

3 转换Disk

root@hw-surfacebook:~# az vm convert -n hws2p -g hws2p01-migrated
 | Running ..
{| Finished ..
  "endTime": "2017-06-23T10:45:42.174661+00:00",
  "error": null,
  "name": "fa343688-ba91-447b-b531-5ff983866f9a",
  "startTime": "2017-06-23T10:44:57.245702+00:00",
  "status": "Succeeded"
}

此时,Disk已经是Managed Disk了。

4 查看disk信息

root@hw-surfacebook:~# az disk list -o table
AccountType      DiskSizeGb  Location    Name                                    OwnerId                                                                                                                                ProvisioningState    ResourceGroup     TimeCreated                       OsType
-------------  ------------  ----------  --------------------------------------  -------------------------------------------------------------------------------------------------------------------------------------  -------------------  ----------------  --------------------------------  --------
Standard_LRS             31  chinaeast   hws2p_hws2p-hws2p-0-201706231030480950  /subscriptions/xxxx/resourceGroups/hws2p01-Migrated/providers/Microsoft.Compute/virtualMachines/hws2p  Succeeded            HWS2P01-MIGRATED  2017-06-23T10:45:15.240624+00:00

 

三 把VM的型号转换成DS系列,把Disk转换成SSD

1 VM型号转换

root@hw-surfacebook:~# az vm resize -n hws2p -g hws2p01-migrated --size Standard_DS1
 - Running ..

 \ Running ..
{/ Finished ..
  "availabilitySet": null,
  "diagnosticsProfile": null,
  "hardwareProfile": {
    "vmSize": "Standard_DS1"
  },
  "id": "/subscriptions/xxxx/resourceGroups/hws2p01-migrated/providers/Microsoft.Compute/virtualMachines/hws2p",
  "instanceView": null,
  "licenseType": null,
  "location": "chinaeast",
  "name": "hws2p",
  "networkProfile": {
    "networkInterfaces": [
      {
        "id": "/subscriptions/xxxx/resourceGroups/hws2p01-Migrated/providers/Microsoft.Network/networkInterfaces/hws2p-PrimaryNic",
        "primary": true,
        "resourceGroup": "hws2p01-Migrated"
      }
    ]
  },
  "osProfile": null,
  "plan": null,
  "provisioningState": "Succeeded",
  "resourceGroup": "hws2p01-migrated",
  "resources": null,
  "storageProfile": {
    "dataDisks": [],
    "imageReference": null,
    "osDisk": {
      "caching": "ReadWrite",
      "createOption": "attach",
      "diskSizeGb": null,
      "encryptionSettings": null,
      "image": null,
      "managedDisk": {
        "id": "/subscriptions/xxxx/resourceGroups/hws2p01-Migrated/providers/Microsoft.Compute/disks/hws2p_hws2p-hws2p-0-201706231030480950",
        "resourceGroup": "hws2p01-Migrated",
        "storageAccountType": null
      },
      "name": "hws2p_hws2p-hws2p-0-201706231030480950",
      "osType": "Linux",
      "vhd": null
    }
  },
  "tags": null,
  "type": "Microsoft.Compute/virtualMachines",
  "vmId": "3d7b7a7f-6271-4fa5-9f94-88711eb9db43"
}

2 Disk转换成SSD

az disk update -g hws2p01-Migrated -n hws2p_hws2p-hws2p-0-201706231030480950 --sku Premium_LRS
{
  "accountType": "Premium_LRS",
  "creationData": {
    "createOption": "Import",
    "imageReference": null,
    "sourceResourceId": null,
    "sourceUri": "https://2mportalvhdsg0nfxclb1p0q.blob.core.chinacloudapi.cn/vhds/hws2p01-hws2p-2017-06-23.vhd",
    "storageAccountId": null
  },
  "diskSizeGb": 31,
  "encryptionSettings": null,
  "id": "/subscriptions/xxxx/resourceGroups/hws2p01-Migrated/providers/Microsoft.Compute/disks/hws2p_hws2p-hws2p-0-201706231030480950",
  "location": "chinaeast",
  "name": "hws2p_hws2p-hws2p-0-201706231030480950",
  "osType": null,
  "ownerId": "/subscriptions/xxxx/resourceGroups/hws2p01-Migrated/providers/Microsoft.Compute/virtualMachines/hws2p",
  "provisioningState": "Succeeded",
  "resourceGroup": "hws2p01-Migrated",
  "tags": null,
  "timeCreated": "2017-06-23T10:45:15.240624+00:00",
  "type": "Microsoft.Compute/disks"
}

3 查看Disk信息

root@hw-surfacebook:~# az disk list -o table
AccountType      DiskSizeGb  Location    Name                                    OwnerId                                                                                                                                ProvisioningState    ResourceGroup     TimeCreated                       OsType
-------------  ------------  ----------  --------------------------------------  -------------------------------------------------------------------------------------------------------------------------------------  -------------------  ----------------  --------------------------------  --------
Premium_LRS              31  chinaeast   hws2p_hws2p-hws2p-0-201706231030480950  /subscriptions/xxxx/resourceGroups/hws2p01-Migrated/providers/Microsoft.Compute/virtualMachines/hws2p  Succeeded            HWS2P01-MIGRATED  2017-06-23T10:45:15.240624+00:00

已经是SSD的硬盘了。

 

四总结

通过ASM->ARM的转换工具,可以方便的把ASM的VM迁移到ARM。

通过命令行方便的把disk迁移到Managed Disk。

在ARM中,可以在关机的状态下resize VM到ssd类型的机器。

通过命令行,方便的把HDD的Disk转换成SSD的Disk。

posted @ 2017-06-23 19:29  衡子  阅读(761)  评论(3编辑  收藏  举报