Share via


Herstel na noodgevallen van virtuele VMware-machines naar Azure instellen met PowerShell

Let op

In dit artikel wordt verwezen naar CentOS, een Linux-distributie die de status End Of Life (EOL) nadert. Houd rekening met uw gebruik en plan dienovereenkomstig. Zie de Richtlijnen voor het einde van de levensduur van CentOS voor meer informatie.

In dit artikel ziet u hoe u virtuele VMware-machines repliceert en een failover uitvoert naar Azure met behulp van Azure PowerShell.

U leert het volgende:

  • Een Recovery Services-kluis maken en de kluiscontext instellen.
  • Valideer de serverregistratie in de kluis.
  • Stel replicatie in, inclusief een replicatiebeleid. Voeg uw vCenter-server toe en detecteer VM's.
  • Een vCenter-server toevoegen en detecteren
  • Maak opslagaccounts voor het opslaan van replicatielogboeken of -gegevens en repliceer de VM's.
  • Een failover uitvoeren. Configureer failover-instellingen, voer een instellingen uit voor het repliceren van virtuele machines.

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:

Meld u aan bij Azure

Meld u aan bij uw Azure-abonnement met behulp van de cmdlet Verbinding maken-AzAccount:

Connect-AzAccount

Selecteer het Azure-abonnement waarnaar u uw virtuele VMware-machines wilt repliceren. Gebruik de cmdlet Get-AzSubscription om de lijst met Azure-abonnementen op te halen waarvoor u toegang hebt. Selecteer het Azure-abonnement waarmee u wilt werken met behulp van de cmdlet Select-AzSubscription.

Select-AzSubscription -SubscriptionName "ASR Test Subscription"

Een Recovery Services-kluis instellen

  1. Maak een resourcegroep waarin de Recovery Services-kluis moet worden gemaakt. In het volgende voorbeeld heeft de resourcegroep de naam VMwareDRtoAzurePS en wordt deze gemaakt in de regio Azië - oost.

    New-AzResourceGroup -Name "VMwareDRtoAzurePS" -Location "East Asia"
    
    ResourceGroupName : VMwareDRtoAzurePS
    Location          : eastasia
    ProvisioningState : Succeeded
    Tags              :
    ResourceId        : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VMwareDRtoAzurePS
    
  2. Maak een Recovery Services-kluis. In het volgende voorbeeld heeft de Recovery Services-kluis de naam VMwareDRToAzurePs en wordt deze gemaakt in de regio Azië - oost en in de resourcegroep die u in de vorige stap hebt gemaakt.

    New-AzRecoveryServicesVault -Name "VMwareDRToAzurePs" -Location "East Asia" -ResourceGroupName "VMwareDRToAzurePs"
    
    Name              : VMwareDRToAzurePs
    ID                : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VMwareDRToAzurePs/providers/Microsoft.RecoveryServices/vaults/VMwareDRToAzurePs
    Type              : Microsoft.RecoveryServices/vaults
    Location          : eastasia
    ResourceGroupName : VMwareDRToAzurePs
    SubscriptionId    : xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    Properties        : Microsoft.Azure.Commands.RecoveryServices.ARSVaultProperties
    
  3. Download de kluisregistratiesleutel voor de kluis. De kluisregistratiesleutel wordt gebruikt om de on-premises configuratieserver te registreren bij deze kluis. Registratie maakt deel uit van het installatieproces van de configuratieserversoftware.

    #Get the vault object by name and resource group and save it to the $vault PowerShell variable 
    $vault = Get-AzRecoveryServicesVault -Name "VMwareDRToAzurePS" -ResourceGroupName "VMwareDRToAzurePS"
    
    #Download vault registration key to the path C:\Work
    Get-AzRecoveryServicesVaultSettingsFile -SiteRecovery -Vault $Vault -Path "C:\Work\"
    
    FilePath
    --------
    C:\Work\VMwareDRToAzurePs_2017-11-23T19-52-34.VaultCredentials
    
  4. Gebruik de gedownloade kluisregistratiesleutel en volg de volgende stappen in de artikelen om de installatie en registratie van de configuratieserver te voltooien.

De kluiscontext instellen

Stel de kluiscontext in met behulp van de set-ASRVaultContext-cmdlet. Na het instellen worden volgende Azure Site Recovery-bewerkingen in de PowerShell-sessie uitgevoerd in de context van de geselecteerde kluis.

Tip

De Azure Site Recovery PowerShell-module (Az.RecoveryServices-module) wordt geleverd met gebruiksvriendelijke aliassen voor de meeste cmdlets. De cmdlets in de module maken gebruik van het formulier Operation-AzRecoveryServicesAsr-object>>< en hebben gelijkwaardige aliassen die het formulier <Operation-ASR-object>>< vormen.< U kunt de cmdlet-aliassen vervangen voor gebruiksgemak.

In het volgende voorbeeld worden de kluisdetails van de $vault variabele gebruikt om de kluiscontext voor de PowerShell-sessie op te geven.

Set-ASRVaultContext -Vault $vault
ResourceName      ResourceGroupName ResourceNamespace          ResourceType
------------      ----------------- -----------------          -----------
VMwareDRToAzurePs VMwareDRToAzurePs Microsoft.RecoveryServices vaults

Als alternatief voor de cmdlet Set-ASRVaultContext kunt u ook de cmdlet Import-AzRecoveryServicesAsrVault Instellingen File gebruiken om de kluiscontext in te stellen. Geef het pad op waar het bestand met de kluisregistratiesleutel zich bevindt als de parameter -path naar de cmdlet Import-AzRecoveryServicesAsrVault Instellingen Bestand. Voorbeeld:

Get-AzRecoveryServicesVaultSettingsFile -SiteRecovery -Vault $Vault -Path "C:\Work\"
Import-AzRecoveryServicesAsrVaultSettingsFile -Path "C:\Work\VMwareDRToAzurePs_2017-11-23T19-52-34.VaultCredentials"

In volgende secties van dit artikel wordt ervan uitgegaan dat de kluiscontext voor Azure Site Recovery-bewerkingen is ingesteld.

Kluisregistratie valideren

Voor dit voorbeeld hebben we de volgende vereisten:

  • Er is een configuratieserver (ConfigurationServer) geregistreerd bij deze kluis.
  • Er is een extra processerver (ScaleOut-ProcessServer) geregistreerd bij ConfigurationServer
  • Accounts (vCenter_account, WindowsAccount, LinuxAccount) zijn ingesteld op de configuratieserver. Deze accounts worden gebruikt om de vCenter-server toe te voegen, virtuele machines te detecteren en de mobility-servicesoftware te pushen installeren op Windows- en Linux-servers die moeten worden gerepliceerd.
  1. Geregistreerde configuratieservers worden vertegenwoordigd door een fabric-object in Site Recovery. Haal de lijst met infrastructuurobjecten op in de kluis en identificeer de configuratieserver.

    # Verify that the Configuration server is successfully registered to the vault
    $ASRFabrics = Get-AzRecoveryServicesAsrFabric
    $ASRFabrics.count
    
    1
    
    #Print details of the Configuration Server
    $ASRFabrics[0]
    
    Name                  : 2c33d710a5ee6af753413e97f01e314fc75938ea4e9ac7bafbf4a31f6804460d
    FriendlyName          : ConfigurationServer
    ID                    : /Subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VMwareDRToAzurePs/providers/Microsoft.RecoveryServices/vaults/VMwareDRToAzurePs/replicationFabrics
                            /2c33d710a5ee6af753413e97f01e314fc75938ea4e9ac7bafbf4a31f6804460d
    Type                  : Microsoft.RecoveryServices/vaults/replicationFabrics
    FabricType            : VMware
    SiteIdentifier        : ef7a1580-f356-4a00-aa30-7bf80f952510
    FabricSpecificDetails : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRVMWareSpecificDetails
    
  2. Identificeer de processervers die kunnen worden gebruikt om machines te repliceren.

    $ProcessServers = $ASRFabrics[0].FabricSpecificDetails.ProcessServers
    for($i=0; $i -lt $ProcessServers.count; $i++) {
     "{0,-5} {1}" -f $i, $ProcessServers[$i].FriendlyName
    }
    
    0     ScaleOut-ProcessServer
    1     ConfigurationServer
    

    Uit de bovenstaande uitvoer $ProcessServers[0] komt overeen met ScaleOut-ProcessServer en $ProcessServers[1] komt overeen met de functie Processerver op ConfigurationServer

  3. Identificeer accounts die zijn ingesteld op de configuratieserver.

    $AccountHandles = $ASRFabrics[0].FabricSpecificDetails.RunAsAccounts
    #Print the account details
    $AccountHandles
    
    AccountId AccountName
    --------- -----------
    1         vCenter_account
    2         WindowsAccount
    3         LinuxAccount
    

    Uit de bovenstaande uitvoer $AccountHandles[0] komt overeen met het account vCenter_account, $AccountHandles[1] aan account WindowsAccount en $AccountHandles[2] naar account LinuxAccount

Een replicatiebeleid maken

In deze stap worden twee replicatiebeleidsregels gemaakt. Eén beleid voor het repliceren van virtuele VMware-machines naar Azure en de andere voor het repliceren van virtuele machines die in Azure worden uitgevoerd, terug naar de on-premises VMware-site.

Notitie

De meeste Azure Site Recovery-bewerkingen worden asynchroon uitgevoerd. Wanneer u een bewerking start, wordt een Azure Site Recovery-taak verzonden en wordt er een object voor het bijhouden van taken geretourneerd. Dit object voor het bijhouden van taken kan worden gebruikt om de status van de bewerking te bewaken.

  1. Maak een replicatiebeleid met de naam ReplicationPolicy om virtuele VMware-machines te repliceren naar Azure met de opgegeven eigenschappen.

    $Job_PolicyCreate = New-AzRecoveryServicesAsrPolicy -VMwareToAzure -Name "ReplicationPolicy" -RecoveryPointRetentionInHours 24 -ApplicationConsistentSnapshotFrequencyInHours 4 -RPOWarningThresholdInMinutes 60
    
    # Track Job status to check for completion
    while (($Job_PolicyCreate.State -eq "InProgress") -or ($Job_PolicyCreate.State -eq "NotStarted")){
            sleep 10;
            $Job_PolicyCreate = Get-ASRJob -Job $Job_PolicyCreate
    }
    
    #Display job status
    $Job_PolicyCreate
    
    Name             : 8d18e2d9-479f-430d-b76b-6bc7eb2d0b3e
    ID               : /Subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VMwareDRToAzurePs/providers/Microsoft.RecoveryServices/vaults/VMwareDRToAzurePs/replicationJobs/8d18e2d
                       9-479f-430d-b76b-6bc7eb2d0b3e
    Type             :
    JobType          : AddProtectionProfile
    DisplayName      : Create replication policy
    ClientRequestId  : a162b233-55d7-4852-abac-3d595a1faac2 ActivityId: 9895234a-90ea-4c1a-83b5-1f2c6586252a
    State            : Succeeded
    StateDescription : Completed
    StartTime        : 11/24/2017 2:49:24 AM
    EndTime          : 11/24/2017 2:49:23 AM
    TargetObjectId   : ab31026e-4866-5440-969a-8ebcb13a372f
    TargetObjectType : ProtectionProfile
    TargetObjectName : ReplicationPolicy
    AllowedActions   :
    Tasks            : {Prerequisites check for creating the replication policy, Creating the replication policy}
    Errors           : {}
    
  2. Maak een replicatiebeleid voor failback van Azure naar de on-premises VMware-site.

    $Job_FailbackPolicyCreate = New-AzRecoveryServicesAsrPolicy -AzureToVMware -Name "ReplicationPolicy-Failback" -RecoveryPointRetentionInHours 24 -ApplicationConsistentSnapshotFrequencyInHours 4 -RPOWarningThresholdInMinutes 60
    

    Gebruik de taakdetails in $Job_FailbackPolicyCreate om de bewerking bij te houden tot voltooiing.

    • Maak een beveiligingscontainertoewijzing om replicatiebeleid toe te wijzen met de configuratieserver.
    #Get the protection container corresponding to the Configuration Server
    $ProtectionContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $ASRFabrics[0]
    
    #Get the replication policies to map by name.
    $ReplicationPolicy = Get-AzRecoveryServicesAsrPolicy -Name "ReplicationPolicy"
    $FailbackReplicationPolicy = Get-AzRecoveryServicesAsrPolicy -Name "ReplicationPolicy-Failback"
    
    # Associate the replication policies to the protection container corresponding to the Configuration Server.
    
    $Job_AssociatePolicy = New-AzRecoveryServicesAsrProtectionContainerMapping -Name "PolicyAssociation1" -PrimaryProtectionContainer $ProtectionContainer -Policy $ReplicationPolicy
    
    # Check the job status
    while (($Job_AssociatePolicy.State -eq "InProgress") -or ($Job_AssociatePolicy.State -eq "NotStarted")){
            sleep 10;
            $Job_AssociatePolicy = Get-ASRJob -Job $Job_AssociatePolicy
    }
    $Job_AssociatePolicy.State
    
    <# In the protection container mapping used for failback (replicating failed over virtual machines
       running in Azure, to the primary VMware site.) the protection container corresponding to the
       Configuration server acts as both the Primary protection container and the recovery protection
       container
    #>
     $Job_AssociateFailbackPolicy = New-AzRecoveryServicesAsrProtectionContainerMapping -Name "FailbackPolicyAssociation" -PrimaryProtectionContainer $ProtectionContainer -RecoveryProtectionContainer $ProtectionContainer -Policy $FailbackReplicationPolicy
    
    # Check the job status
    while (($Job_AssociateFailbackPolicy.State -eq "InProgress") -or ($Job_AssociateFailbackPolicy.State -eq "NotStarted")){
            sleep 10;
            $Job_AssociateFailbackPolicy = Get-ASRJob -Job $Job_AssociateFailbackPolicy
    }
    $Job_AssociateFailbackPolicy.State
    
    

Een vCenter-server toevoegen en VM's detecteren

Voeg een vCenter Server toe op IP-adres of hostnaam. De parameter -port specificeert de poort op de vCenter-server waarmee verbinding moet worden gemaakt. De parameter -Name geeft een beschrijvende naam op die moet worden gebruikt voor de vCenter-server. De parameter -Account geeft de accounthandgreep op de configuratieserver die moet worden gebruikt om virtuele machines te detecteren die worden beheerd door de vCenter-server.

# The $AccountHandles[0] variable holds details of vCenter_account

$Job_AddvCenterServer = New-AzRecoveryServicesAsrvCenter -Fabric $ASRFabrics[0] -Name "MyvCenterServer" -IpOrHostName "10.150.24.63" -Account $AccountHandles[0] -Port 443

#Wait for the job to complete and ensure it completed successfully

while (($Job_AddvCenterServer.State -eq "InProgress") -or ($Job_AddvCenterServer.State -eq "NotStarted")) {
        sleep 30;
        $Job_AddvCenterServer = Get-ASRJob -Job $Job_AddvCenterServer
}
$Job_AddvCenterServer
Name             : 0f76f937-f9cf-4e0e-bf27-10c9d1c252a4
ID               : /Subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VMwareDRToAzurePs/providers/Microsoft.RecoveryServices/vaults/VMwareDRToAzurePs/replicationJobs/0f76f93
                   7-f9cf-4e0e-bf27-10c9d1c252a4
Type             :
JobType          : DiscoverVCenter
DisplayName      : Add vCenter server
ClientRequestId  : a2af8892-5686-4d64-a528-10445bc2f698 ActivityId: 7ec05aad-002e-4da0-991f-95d0de7a9f3a
State            : Succeeded
StateDescription : Completed
StartTime        : 11/24/2017 2:41:47 AM
EndTime          : 11/24/2017 2:44:37 AM
TargetObjectId   : 10.150.24.63
TargetObjectType : VCenter
TargetObjectName : MyvCenterServer
AllowedActions   :
Tasks            : {Adding vCenter server}
Errors           : {}

Opslagaccounts maken voor replicatie

Als u naar een beheerde schijf wilt schrijven, gebruikt u de PowerShell Az.RecoveryServices-module 2.0.0 en hoger. Hiervoor hoeft alleen een logboekopslagaccount te worden gemaakt. Het is raadzaam om een standaardaccounttype en LRS-redundantie te gebruiken, omdat het wordt gebruikt om alleen tijdelijke logboeken op te slaan. Zorg ervoor dat het opslagaccount is gemaakt in dezelfde Azure-regio als de kluis.

Als u een versie van de Az.RecoveryServices-module gebruikt die ouder is dan 2.0.0, gebruikt u de volgende stappen om opslagaccounts te maken. Deze opslagaccounts worden later gebruikt om virtuele machines te repliceren. Zorg ervoor dat de opslagaccounts zijn gemaakt in dezelfde Azure-regio als de kluis. U kunt deze stap overslaan als u van plan bent een bestaand opslagaccount voor replicatie te gebruiken.

Notitie

Tijdens het repliceren van on-premises virtuele machines naar een Premium-opslagaccount, moet u een extra Standard-opslagaccount (logboekopslagaccount) opgeven. Het logboekopslagaccount bevat replicatielogboeken als een tussenliggend archief totdat de logboeken kunnen worden toegepast op het Premium-opslagdoel.


$PremiumStorageAccount = New-AzStorageAccount -ResourceGroupName "VMwareDRToAzurePs" -Name "premiumstorageaccount1" -Location "East Asia" -SkuName Premium_LRS

$LogStorageAccount = New-AzStorageAccount -ResourceGroupName "VMwareDRToAzurePs" -Name "logstorageaccount1" -Location "East Asia" -SkuName Standard_LRS

$ReplicationStdStorageAccount= New-AzStorageAccount -ResourceGroupName "VMwareDRToAzurePs" -Name "replicationstdstorageaccount1" -Location "East Asia" -SkuName Standard_LRS

Virtuele VMware-machines repliceren

Het duurt ongeveer 15-20 minuten voordat virtuele machines zijn gedetecteerd vanaf de vCenter-server. Zodra het object is gedetecteerd, wordt er een beveiligbaar itemobject gemaakt in Azure Site Recovery voor elke gedetecteerde virtuele machine. In deze stap worden drie van de gedetecteerde virtuele machines gerepliceerd naar de Azure Storage-accounts die in de vorige stap zijn gemaakt.

U hebt de volgende gegevens nodig om een gedetecteerde virtuele machine te beveiligen:

  • Het beveiligbare item dat moet worden gerepliceerd.
  • Het opslagaccount waarnaar de virtuele machine moet worden gerepliceerd (alleen als u repliceert naar het opslagaccount).
  • Er is een logboekopslag nodig om virtuele machines te beveiligen tegen een Premium-opslagaccount of op een beheerde schijf.
  • De processerver die moet worden gebruikt voor replicatie. De lijst met beschikbare processervers is opgehaald en opgeslagen in de variabelen $ProcessServers[0](ScaleOut-ProcessServer) en $ProcessServers[1](ConfigurationServer).
  • Het account dat moet worden gebruikt voor het push-installeren van de Mobility-service software op de computers. De lijst met beschikbare accounts is opgehaald en opgeslagen in de variabele $AccountHandles.
  • De beveiligingscontainertoewijzing voor het replicatiebeleid dat moet worden gebruikt voor replicatie.
  • De resourcegroep waarin virtuele machines moeten worden gemaakt bij failover.
  • Eventueel moeten het virtuele Azure-netwerk en het subnet waarmee de virtuele machine waarvoor een failover is uitgevoerd, worden verbonden.

Repliceer nu de volgende virtuele machines met behulp van de instellingen die zijn opgegeven in deze tabel:

Virtuele machine Processerver Opslagaccount Logboekopslagaccount Beleid Account voor Mobility-service installatie Doelresourcegroep Virtueel doelnetwerk Doelsubnet
CentOSVM1 ConfigurationServer N.v.t. logstorageaccount1 ReplicationPolicy LinuxAccount VMwareDRToAzurePs ASR-vnet Subnet-1
Win 2K12VM1 ScaleOut-ProcessServer premiumstorageaccount1 logstorageaccount1 ReplicationPolicy WindowsAccount VMwareDRToAzurePs ASR-vnet Subnet-1
CentOSVM2 ConfigurationServer replicationstdstorageaccount1 N.v.t. ReplicationPolicy LinuxAccount VMwareDRToAzurePs ASR-vnet Subnet-1

#Get the target resource group to be used
$ResourceGroup = Get-AzResourceGroup -Name "VMwareToAzureDrPs"

#Get the target virtual network to be used
$RecoveryVnet = Get-AzVirtualNetwork -Name "ASR-vnet" -ResourceGroupName "asrrg" 

#Get the protection container mapping for replication policy named ReplicationPolicy
$PolicyMap  = Get-AzRecoveryServicesAsrProtectionContainerMapping -ProtectionContainer $ProtectionContainer | where PolicyFriendlyName -eq "ReplicationPolicy"

#Get the protectable item corresponding to the virtual machine CentOSVM1
$VM1 = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $ProtectionContainer -FriendlyName "CentOSVM1"

# Enable replication for virtual machine CentOSVM1 using the Az.RecoveryServices module 2.0.0 onwards to replicate to managed disks
# The name specified for the replicated item needs to be unique within the protection container. Using a random GUID to ensure uniqueness
$Job_EnableReplication1 = New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure -ProtectableItem $VM1 -Name (New-Guid).Guid -ProtectionContainerMapping $PolicyMap -ProcessServer $ProcessServers[1] -Account $AccountHandles[2] -RecoveryResourceGroupId $ResourceGroup.ResourceId -logStorageAccountId $LogStorageAccount.Id -RecoveryAzureNetworkId $RecoveryVnet.Id -RecoveryAzureSubnetName "Subnet-1"

# Alternatively, if the virtual machine CentOSVM1 has CMK enabled disks, enable replication using Az module 3.3.0 onwards as below
# $diskID is the Disk Encryption Set ID to be used for all replica managed disks and target managed disks in the target region
$Job_EnableReplication1 = New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure -ProtectableItem $VM1 -Name (New-Guid).Guid -ProtectionContainerMapping $PolicyMap -ProcessServer $ProcessServers[1] -Account $AccountHandles[2] -RecoveryResourceGroupId $ResourceGroup.ResourceId -logStorageAccountId -DiskEncryptionSetId $diskId $LogStorageAccount.Id -RecoveryAzureNetworkId $RecoveryVnet.Id -RecoveryAzureSubnetName "Subnet-1"

#Get the protectable item corresponding to the virtual machine Win2K12VM1
$VM2 = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $ProtectionContainer -FriendlyName "Win2K12VM1"

# Enable replication for virtual machine Win2K12VM1
$Job_EnableReplication2 = New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure -ProtectableItem $VM2 -Name (New-Guid).Guid -ProtectionContainerMapping $PolicyMap -RecoveryAzureStorageAccountId $PremiumStorageAccount.Id -LogStorageAccountId $LogStorageAccount.Id -ProcessServer $ProcessServers[0] -Account $AccountHandles[1] -RecoveryResourceGroupId $ResourceGroup.ResourceId -RecoveryAzureNetworkId $RecoveryVnet.Id -RecoveryAzureSubnetName "Subnet-1"

#Get the protectable item corresponding to the virtual machine CentOSVM2
$VM3 = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $ProtectionContainer -FriendlyName "CentOSVM2"

# Enable replication for virtual machine CentOSVM2
$Job_EnableReplication3 = New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure -ProtectableItem $VM3 -Name (New-Guid).Guid -ProtectionContainerMapping $PolicyMap -RecoveryAzureStorageAccountId $ReplicationStdStorageAccount.Id  -ProcessServer $ProcessServers[1] -Account $AccountHandles[2] -RecoveryResourceGroupId $ResourceGroup.ResourceId -RecoveryAzureNetworkId $RecoveryVnet.Id -RecoveryAzureSubnetName "Subnet-1"

Zodra de inschakelende replicatietaak is voltooid, wordt de initiële replicatie gestart voor de virtuele machines. De initiële replicatie kan enige tijd duren, afhankelijk van de hoeveelheid gegevens die moet worden gerepliceerd en de bandbreedte die beschikbaar is voor replicatie. Nadat de initiële replicatie is voltooid, wordt de virtuele machine verplaatst naar een beveiligde status. Zodra de virtuele machine een beveiligde status heeft bereikt, kunt u een testfailover uitvoeren voor de virtuele machine, deze toevoegen aan herstelplannen, enzovoort.

U kunt de replicatiestatus en replicatiestatus van de virtuele machine controleren met de cmdlet Get-ASRReplicationProtectedItem.

Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $ProtectionContainer | Select FriendlyName, ProtectionState, ReplicationHealth
FriendlyName ProtectionState                 ReplicationHealth
------------ ---------------                 -----------------
CentOSVM1    Protected                       Normal
CentOSVM2    InitialReplicationInProgress    Normal
Win2K12VM1   Protected                       Normal

Failover-instellingen configureren

Failover-instellingen voor beveiligde machines kunnen worden bijgewerkt met behulp van de cmdlet Set-ASRReplicationProtectedItem. Enkele van de instellingen die via deze cmdlet kunnen worden bijgewerkt, zijn:

  • Naam van de virtuele machine die moet worden gemaakt bij failover
  • VM-grootte van de virtuele machine die moet worden gemaakt bij failover
  • Virtueel Azure-netwerk en -subnet waarmee de NIC's van de virtuele machine moeten worden verbonden bij failover
  • Failover naar beheerde schijven
  • Azure Hybrid Use Benefit toepassen
  • Wijs een statisch IP-adres toe vanuit het virtuele doelnetwerk dat moet worden toegewezen aan de virtuele machine bij failover.

In dit voorbeeld werken we de VM-grootte van de virtuele machine bij die moet worden gemaakt bij failover voor de virtuele machine Win2K12VM1 en geven we op dat de virtuele machine beheerde schijven gebruikt bij failover.

$ReplicatedVM1 = Get-AzRecoveryServicesAsrReplicationProtectedItem -FriendlyName "Win2K12VM1" -ProtectionContainer $ProtectionContainer

Set-AzRecoveryServicesAsrReplicationProtectedItem -InputObject $ReplicatedVM1 -Size "Standard_DS11" -UseManagedDisk True
Name             : cafa459c-44a7-45b0-9de9-3d925b0e7db9
ID               : /Subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/VMwareDRToAzurePs/providers/Microsoft.RecoveryServices/vaults/VMwareDRToAzurePs/replicationJobs/cafa459
                   c-44a7-45b0-9de9-3d925b0e7db9
Type             :
JobType          : UpdateVmProperties
DisplayName      : Update the virtual machine
ClientRequestId  : b0b51b2a-f151-4e9a-a98e-064a5b5131f3 ActivityId: ac2ba316-be7b-4c94-a053-5363f683d38f
State            : InProgress
StateDescription : InProgress
StartTime        : 11/24/2017 2:04:26 PM
EndTime          :
TargetObjectId   : 88bc391e-d091-11e7-9484-000c2955bb50
TargetObjectType : ProtectionEntity
TargetObjectName : Win2K12VM1
AllowedActions   :
Tasks            : {Update the virtual machine properties}
Errors           : {}

Een testfailover uitvoeren

  1. Voer als volgt een noodherstelanalyse (testfailover) uit:

    #Test failover of Win2K12VM1 to the test virtual network "V2TestNetwork"
    
    #Get details of the test failover virtual network to be used
    TestFailovervnet = Get-AzVirtualNetwork -Name "V2TestNetwork" -ResourceGroupName "asrrg" 
    
    #Start the test failover operation
    $TFOJob = Start-AzRecoveryServicesAsrTestFailoverJob -ReplicationProtectedItem $ReplicatedVM1 -AzureVMNetworkId $TestFailovervnet.Id -Direction PrimaryToRecovery
    
  2. Zodra de testfailovertaak is voltooid, ziet u dat een virtuele machine met het achtervoegsel '-Test' (Win2K12VM1-Test in dit geval) is gemaakt in Azure.

  3. U kunt nu verbinding maken met de virtuele machine waarvoor de test is mislukt en de testfailover valideren.

  4. Schoon de testfailover op met behulp van de cmdlet Start-ASRTestFailoverCleanupJob. Met deze bewerking wordt de virtuele machine verwijderd die is gemaakt als onderdeel van de testfailoverbewerking.

    $Job_TFOCleanup = Start-AzRecoveryServicesAsrTestFailoverCleanupJob -ReplicationProtectedItem $ReplicatedVM1
    

Failover naar Azure

In deze stap voeren we een failover uit van de virtuele machine Win2K12VM1 naar een specifiek herstelpunt.

  1. Haal een lijst met beschikbare herstelpunten op die moeten worden gebruikt voor de failover:

    # Get the list of available recovery points for Win2K12VM1
    $RecoveryPoints = Get-AzRecoveryServicesAsrRecoveryPoint -ReplicationProtectedItem $ReplicatedVM1
    "{0} {1}" -f $RecoveryPoints[0].RecoveryPointType, $RecoveryPoints[0].RecoveryPointTime
    
    CrashConsistent 11/24/2017 5:28:25 PM
    
    
    #Start the failover job
    $Job_Failover = Start-AzRecoveryServicesAsrUnplannedFailoverJob -ReplicationProtectedItem $ReplicatedVM1 -Direction PrimaryToRecovery -RecoveryPoint $RecoveryPoints[0]
    do {
            $Job_Failover = Get-ASRJob -Job $Job_Failover;
            sleep 60;
    } while (($Job_Failover.State -eq "InProgress") -or ($JobFailover.State -eq "NotStarted"))
    $Job_Failover.State
    
    Succeeded
    
  2. Zodra een failover is uitgevoerd, kunt u de failoverbewerking doorvoeren en omgekeerde replicatie van Azure terug naar de on-premises VMware-site instellen.

Volgende stappen

Meer informatie over het automatiseren van meer taken met behulp van de Naslaginformatie over Azure Site Recovery PowerShell.