Delen via


Schijven uitsluiten van PowerShell-replicatie van Azure-VM's

In dit artikel wordt beschreven hoe u schijven kunt uitsluiten wanneer u Azure-VM's repliceert. U kunt schijven uitsluiten om de verbruikte replicatiebandbreedte of de resources aan de doelzijde te optimaliseren die door deze schijven worden gebruikt. Deze mogelijkheid is momenteel alleen beschikbaar via Azure PowerShell.

Notitie

Het wordt aanbevolen de Azure Az PowerShell-module te gebruiken om te communiceren met Azure. Zie Azure PowerShell installeren om aan de slag te gaan. Raadpleeg Azure PowerShell migreren van AzureRM naar Az om te leren hoe u naar de Azure PowerShell-module migreert.

Vereisten

Voordat u begint:

Waarom schijven uitsluiten van replicatie

Mogelijk moet u schijven uitsluiten van replicatie omdat:

  • Uw virtuele machine heeft azure Site Recovery-limieten bereikt om de snelheid van gegevenswijziging te repliceren.

  • De gegevens die op de uitgesloten schijf worden geverloop, zijn niet belangrijk of hoeven niet te worden gerepliceerd.

  • U wilt opslag- en netwerkresources opslaan door de gegevens niet te repliceren.

Schijven uitsluiten van replicatie

In ons voorbeeld repliceren we een virtuele machine met één besturingssysteem en drie gegevensschijven die zich in de regio VS - oost bevinden naar de regio VS - west 2. De naam van de virtuele machine is AzureDemoVM. Schijf 1 wordt uitgesloten en schijven 2 en 3 behouden.

Details ophalen van de virtuele machines die u wilt repliceren

# Get details of the virtual machine
$VM = Get-AzVM -ResourceGroupName "A2AdemoRG" -Name "AzureDemoVM"

Write-Output $VM     
ResourceGroupName  : A2AdemoRG
Id                 : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/A2AdemoRG/providers/Microsoft.Compute/virtualMachines/AzureDemoVM
VmId               : 1b864902-c7ea-499a-ad0f-65da2930b81b
Name               : AzureDemoVM
Type               : Microsoft.Compute/virtualMachines
Location           : eastus
Tags               : {}
DiagnosticsProfile : {BootDiagnostics}
HardwareProfile    : {VmSize}
NetworkProfile     : {NetworkInterfaces}
OSProfile          : {ComputerName, AdminUsername, WindowsConfiguration, Secrets}
ProvisioningState  : Succeeded
StorageProfile     : {ImageReference, OsDisk, DataDisks}

Meer informatie over de schijven van de virtuele machine. Deze informatie wordt later gebruikt wanneer u de replicatie van de VIRTUELE machine start.

$OSDiskVhdURI = $VM.StorageProfile.OsDisk.Vhd
$DataDisk1VhdURI = $VM.StorageProfile.DataDisks[0].Vhd

Een virtuele Azure-machine repliceren

In het volgende voorbeeld wordt ervan uitgegaan dat u al een cacheopslagaccount, replicatiebeleid en toewijzingen hebt. Als u deze dingen niet hebt, volgt u het proces bij Herstel na noodgevallen instellen voor virtuele Azure-machines met behulp van Azure PowerShell.

Een virtuele Azure-machine repliceren met beheerde schijven.


#Get the resource group that the virtual machine must be created in when failed over.
$RecoveryRG = Get-AzResourceGroup -Name "a2ademorecoveryrg" -Location "West US 2"

#Specify replication properties for each disk of the VM that is to be replicated (create disk replication configuration).

#OsDisk
$OSdiskId =  $vm.StorageProfile.OsDisk.ManagedDisk.Id
$RecoveryOSDiskAccountType = $vm.StorageProfile.OsDisk.ManagedDisk.StorageAccountType
$RecoveryReplicaDiskAccountType =  $vm.StorageProfile.OsDisk.ManagedDisk.StorageAccountType

$OSDiskReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $EastUSCacheStorageAccount.Id `
         -DiskId $OSdiskId -RecoveryResourceGroupId  $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType  $RecoveryReplicaDiskAccountType `
         -RecoveryTargetDiskAccountType $RecoveryOSDiskAccountType

# Data Disk 1 i.e StorageProfile.DataDisks[0] is excluded, so we will provide it during the time of replication.

# Data disk 2
$datadiskId2  = $vm.StorageProfile.DataDisks[1].ManagedDisk.id
$RecoveryReplicaDiskAccountType =  $vm.StorageProfile.DataDisks[1]. StorageAccountType
$RecoveryTargetDiskAccountType = $vm.StorageProfile.DataDisks[1]. StorageAccountType

$DataDisk2ReplicationConfig  = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $CacheStorageAccount.Id `
         -DiskId $datadiskId2 -RecoveryResourceGroupId  $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType  $RecoveryReplicaDiskAccountType `
         -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType

# Data Disk 3

$datadiskId3  = $vm.StorageProfile.DataDisks[2].ManagedDisk.id
$RecoveryReplicaDiskAccountType =  $vm.StorageProfile.DataDisks[2]. StorageAccountType
$RecoveryTargetDiskAccountType = $vm.StorageProfile.DataDisks[2]. StorageAccountType

$DataDisk3ReplicationConfig  = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $CacheStorageAccount.Id `
         -DiskId $datadiskId3 -RecoveryResourceGroupId  $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType  $RecoveryReplicaDiskAccountType `
         -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType

#Create a list of disk replication configuration objects for the disks of the virtual machine that are to be replicated.
$diskconfigs = @()
$diskconfigs += $OSDiskReplicationConfig, $DataDisk2ReplicationConfig, $DataDisk3ReplicationConfig


#Start replication by creating a replication protected item. Using a GUID for the name of the replication protected item to ensure uniqueness of name.
$TempASRJob = New-ASRReplicationProtectedItem -AzureToAzure -AzureVmId $VM.Id -Name (New-Guid).Guid -ProtectionContainerMapping $EusToWusPCMapping -AzureToAzureDiskReplicationConfiguration $diskconfigs -RecoveryResourceGroupId $RecoveryRG.ResourceId

Wanneer de startreplicatiebewerking slaagt, worden de VM-gegevens gerepliceerd naar de herstelregio.

U kunt naar Azure Portal gaan en de gerepliceerde VM's bekijken onder Gerepliceerde items.

Het replicatieproces begint met het seeden van een kopie van de replicerende schijven van de virtuele machine in de herstelregio. Deze fase wordt de initiële replicatiefase genoemd.

Nadat de initiële replicatie is voltooid, wordt de replicatie verplaatst naar de fase differentiële synchronisatie. Op dit moment is de virtuele machine beveiligd. Selecteer de beveiligde virtuele machine om te zien of er schijven zijn uitgesloten.

Volgende stappen