Azure 標(biāo)準(zhǔn)與高級(jí)托管磁盤存儲(chǔ)的相互轉(zhuǎn)換

托管磁盤提供兩種存儲(chǔ)選項(xiàng):高級(jí)(基于 SSD)和標(biāo)準(zhǔn)(基于 HDD)。 它允許基于性能需求在這兩個(gè)選項(xiàng)之間輕松切換,并保障最短停機(jī)時(shí)間。 非托管磁盤不具備此功能。 但可以輕松轉(zhuǎn)換為托管磁盤,以便在這兩個(gè)選項(xiàng)之間輕松切換。

本文介紹了如何使用 Azure PowerShell 實(shí)現(xiàn)標(biāo)準(zhǔn)與高級(jí)托管磁盤的相互轉(zhuǎn)換。 如需進(jìn)行安裝或升級(jí),請(qǐng)參閱安裝和配置 Azure PowerShell

開始之前

該轉(zhuǎn)換需要重啟 VM,因此請(qǐng)?jiān)陬A(yù)先存在的維護(hù)時(shí)段內(nèi)計(jì)劃磁盤存儲(chǔ)遷移。

如果使用的是非托管磁盤,請(qǐng)先轉(zhuǎn)換為托管磁盤,以便按照本文中的說(shuō)明在兩個(gè)存儲(chǔ)選項(xiàng)之間切換。

實(shí)現(xiàn) VM 的所有標(biāo)準(zhǔn)與高級(jí)托管磁盤的相互轉(zhuǎn)換

以下示例展示如何將 VM 的所有磁盤從標(biāo)準(zhǔn)存儲(chǔ)切換到高級(jí)存儲(chǔ)。 若要使用高級(jí)托管磁盤,VM 必須使用支持高級(jí)存儲(chǔ)的VM 大小。 此示例還切換到了支持高級(jí)存儲(chǔ)的大小。

PowerShell復(fù)制

# Name of the resource group that contains the VM$rgName='yourResourceGroup'# Name of the your virtual machine$vmName='yourVM'# Choose between StandardLRS and PremiumLRS based on your scenario$storageType='PremiumLRS'# Premium capable size# Required only if converting storage from standard to premium$size='Standard_DS2_v2'$vm=Get-AzureRmVM-Name$vmName-resourceGroupName$rgName# Stop and deallocate the VM before changing the sizeStop-AzureRmVM-ResourceGroupName$rgName-Name$vmName-Force# Change the VM size to a size that supports premium storage# Skip this step if converting storage from premium to standard$vm.HardwareProfile.VmSize =$sizeUpdate-AzureRmVM-VM$vm-ResourceGroupName$rgName# Get all disks in the resource group of the VM$vmDisks=Get-AzureRmDisk-ResourceGroupName$rgName# For disks that belong to the selected VM, convert to premium storageforeach($diskin$vmDisks){if($disk.OwnerId-eq$vm.Id)? ? {$diskUpdateConfig=New-AzureRmDiskUpdateConfig–AccountType$storageTypeUpdate-AzureRmDisk-DiskUpdate$diskUpdateConfig-ResourceGroupName$rgName`-DiskName$disk.Name? ? }}Start-AzureRmVM-ResourceGroupName$rgName-Name$vmName

標(biāo)準(zhǔn)與高級(jí)托管磁盤的相互轉(zhuǎn)換

對(duì)于開發(fā)/測(cè)試工作負(fù)荷,可能需要同時(shí)具有標(biāo)準(zhǔn)磁盤和高級(jí)磁盤,以減少成本。 可通過(guò)僅將需要更佳性能的磁盤升級(jí)到高級(jí)存儲(chǔ)來(lái)實(shí)現(xiàn)此目的。 以下示例展示如何將 VM 的單個(gè)磁盤在標(biāo)準(zhǔn)存儲(chǔ)與高級(jí)存儲(chǔ)之間相互切換。 若要使用高級(jí)托管磁盤,VM 必須使用支持高級(jí)存儲(chǔ)的VM 大小。 此示例還切換到了支持高級(jí)存儲(chǔ)的大小。

PowerShell復(fù)制

$diskName='yourDiskName'# resource group that contains the managed disk$rgName='yourResourceGroupName'# Choose between StandardLRS and PremiumLRS based on your scenario$storageType='PremiumLRS'# Premium capable size$size='Standard_DS2_v2'$disk=Get-AzureRmDisk-DiskName$diskName-ResourceGroupName$rgName# Get the ARM resource to get name and resource group of the VM$vmResource=Get-AzureRmResource-ResourceId$disk.OwnerId$vm=Get-AzureRmVM$vmResource.ResourceGroupName-Name$vmResource.ResourceName# Stop and deallocate the VM before changing the storage typeStop-AzureRmVM-ResourceGroupName$vm.ResourceGroupName-Name$vm.Name-Force# Change the VM size to a size that supports premium storage# Skip this step if converting storage from premium to standard$vm.HardwareProfile.VmSize =$sizeUpdate-AzureRmVM-VM$vm-ResourceGroupName$rgName# Update the storage type$diskUpdateConfig=New-AzureRmDiskUpdateConfig–AccountType$storageTypeUpdate-AzureRmDisk-DiskUpdate$diskUpdateConfig-ResourceGroupName$rgName`-DiskName$disk.NameStart-AzureRmVM-ResourceGroupName$vm.ResourceGroupName-Name$vm.Name

后續(xù)步驟

使用快照獲取 VM 的只讀副本。立即訪問(wèn)http://market.azure.cn

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容