在一中討論了通過Azure平臺的工具進行遷移的方案。
本文將討論另外一種遷移方式。通過磁碟複製的方式,把部分VM遷移到ARM的Managed Disk模式。
一. 獲得ASM中Disk的資訊
在管理介面上,獲取VM的Disk資訊
二. 通過這個Disk的URL,建立Managed Disk
root@hw-surfacebook:~# az disk create -g hwfdsk -n hwmd01 --source https://h2portalvhdsn6t2ktgjscst.blob.core.chinacloudapi.cn/vhds/hwfdsk-hwfdsk-2017-06-23.vhd {/ Finished .. "accountType": "Premium_LRS", "creationData": { "createOption": "Import", "imageReference": null, "sourceResourceId": null, "sourceUri": "https://h2portalvhdsn6t2ktgjscst.blob.core.chinacloudapi.cn/vhds/hwfdsk-hwfdsk-2017-06-23.vhd", "storageAccountId": null }, "diskSizeGb": null, "encryptionSettings": null, "id": "/subscriptions/xxxx/resourceGroups/hwfdsk/providers/Microsoft.Compute/disks/hwmd01", "location": "chinanorth", "name": "hwmd01", "osType": null, "ownerId": null, "provisioningState": "Succeeded", "resourceGroup": "hwfdsk", "tags": {}, "timeCreated": "2017-06-23T14:52:46.629909+00:00", "type": "Microsoft.Compute/disks" }
此時可以通過命令列獲得這個Disk的資訊:
root@hw-surfacebook:~# az disk list -o table AccountType Location Name ProvisioningState ResourceGroup TimeCreated DiskSizeGb OsType OwnerId ------------- ---------- ----------------- ------------------- --------------- -------------------------------- ------------ -------- --------------------------------------------------------------------------------------------------------------------------- Premium_LRS chinanorth hwmd01 Succeeded HWFDSK 2017-06-23T14:52:46.629909+00:00
因為建立是沒有制定sku,所以預設建立了Premium的Disk。是在Managed Disk的管理模式下,非常方便的可以更改其SKU。具體命令如下:
root@hw-surfacebook:~# az disk update -n hwmd01 -g hwfdsk --sku Standard_LRS { "accountType": "Standard_LRS", "creationData": { "createOption": "Import", "imageReference": null, "sourceResourceId": null, "sourceUri": "https://h2portalvhdsn6t2ktgjscst.blob.core.chinacloudapi.cn/vhds/hwfdsk-hwfdsk-2017-06-23.vhd", "storageAccountId": null }, "diskSizeGb": null, "encryptionSettings": null, "id": "/subscriptions/xxxx/resourceGroups/hwfdsk/providers/Microsoft.Compute/disks/hwmd01", "location": "chinanorth", "name": "hwmd01", "osType": null, "ownerId": null, "provisioningState": "Succeeded", "resourceGroup": "hwfdsk", "tags": {}, "timeCreated": "2017-06-23T14:52:46.629909+00:00", "type": "Microsoft.Compute/disks" }
此時Disk已經變成HDD的了。
三 通過這個Disk建立VM
建立VM前,先查詢在ARM中的VNet資訊:
在Portal頁面上找到Vnet資訊:
然後,用命令列建立VM:
root@hw-surfacebook:~# az vm create -n hwfdsk01 -g hwfdsk --attach-os-disk hwmd01 --size Standard_D1 --vnet-name hwazcopy-vnet --subnet default --os-type linux {/ Finished .. "fqdns": "", "id": "/subscriptions/xxxx/resourceGroups/hwfdsk/providers/Microsoft.Compute/virtualMachines/hwfdsk01", "location": "chinanorth", "macAddress": "00-17-FA-00-A7-B6", "powerState": "VM running", "privateIpAddress": "10.0.0.4", "publicIpAddress": "139.219.108.26", "resourceGroup": "hwfdsk" }
命令格式非常簡單,由於是已經有的Disk,所以不用指定使用者名稱和密碼,只需要指定:
- 機器名稱
- 資源組
- 掛載的OSDisk資訊
- VM的Size
- Vnet資訊,包括Subnet資訊
- OS型別
Protal上可以看到機器已經執行起來了,並且剛剛配置的幾個引數,都可以找到:
四 總結
通過ASM中VM的VHD連結建立Managed Disk,在通過這個Manage Disk方便的建立一臺VM。實現快速的VM從ASM到ARM的遷移。