删除服务器并禁用保护Remove servers and disable protection

本文介绍了如何从恢复服务保管库中取消注册服务器,以及如何禁用对计算机的 Site Recovery 保护。This article describes how to unregister servers from a Recovery Services vault, and how to disable protection for machines protected by Site Recovery.

取消注册配置服务器Unregister a configuration server

如果将 VMware VM 或 Windows/Linux 物理服务器复制到 Azure,则可从保管库中注销未连接的配置服务器,如下所示:If you replicate VMware VMs or Windows/Linux physical servers to Azure, you can unregister an unconnected configuration server from a vault as follows:

  1. 禁用对虚拟机的保护Disable protection of virtual machines.
  2. 取消关联或删除复制策略。Disassociate or delete replication policies.
  3. 删除配置服务器Delete the configuration server

取消注册 VMM 服务器Unregister a VMM server

  1. 停止在要删除的 VMM 服务器上复制云中的虚拟机。Stop replicating virtual machines in clouds on the VMM server you want to remove.
  2. 删除由需要删除的 VMM 服务器上的云使用的任何网络映射。Delete any network mappings used by clouds on the VMM server that you want to delete. 在“Site Recovery 基础结构” > “对于 System Center VMM” > “网络映射”中,右键单击网络映射 >“删除”。In Site Recovery Infrastructure > For System Center VMM > Network Mapping, right-click the network mapping > Delete.
  3. 记下 VMM 服务器的 ID。Note the ID of the VMM server.
  4. 取消复制策略与要删除的 VMM 服务器上的云的关联。Disassociate replication policies from clouds on the VMM server you want to remove. 在“Site Recovery 基础结构” > “对于 System Center VMM” > “复制策略”中,右键单击关联的策略。In Site Recovery Infrastructure > For System Center VMM > Replication Policies, double-click the associated policy. 右键单击云“取消关联” 。Right-click the cloud > Disassociate.
  5. 删除 VMM 服务器或主动节点。Delete the VMM server or active node. 在“Site Recovery 基础结构” > “对于 System Center VMM” > “VMM 服务器”中,右键单击服务器 >“删除”。In Site Recovery Infrastructure > For System Center VMM > VMM Servers, right-click the server > Delete.
  6. 如果 VMM 服务器处于“已断开连接”状态,请对 VMM 服务器下载并运行清理脚本If your VMM server was in a Disconnected state, then download and run the cleanup script on the VMM server. 使用“以管理员身份运行” 选项打开 PowerShell,以更改默认 (LocalMachine) 范围的执行策略。Open PowerShell with the Run as Administrator option, to change the execution policy for the default (LocalMachine) scope. 在脚本中,指定要删除的 VMM 服务器的 ID。In the script, specify the ID of the VMM server you want to remove. 脚本会从服务器中删除注册和云配对信息。The script removes registration and cloud pairing information from the server.
  7. 在所有辅助 VMM 服务器上,运行清理脚本。Run the cleanup script on any secondary VMM server.
  8. 在任何其他被动 VMM 群集节点(已安装提供程序)上运行清理脚本。Run the cleanup script on any other passive VMM cluster nodes that have the Provider installed.
  9. 手动卸载 VMM 服务器上的提供程序。Uninstall the Provider manually on the VMM server. 如果有一个群集,请从所有节点删除。If you have a cluster, remove from all nodes.
  10. 若要将虚拟机复制到 Azure,需要在已删除的云中从 Hyper-V 主机中卸载 Azure 恢复服务代理。If your virtual machines were replicating to Azure, you need to uninstall the Azure Recovery Services agent from Hyper-V hosts in the deleted clouds.

取消注册 Hyper-V 站点中的 Hyper-V 主机Unregister a Hyper-V host in a Hyper-V Site

未由 VMM 托管的 Hyper-V 主机将收集到 Hyper-V 站点中。Hyper-V hosts that aren't managed by VMM are gathered into a Hyper-V site. 在 Hyper-V 站点中删除主机,如下所示:Remove a host in a Hyper-V site as follows:

  1. 禁用位于主机上的 Hyper-V VM 的复制。Disable replication for Hyper-V VMs located on the host.

  2. 取消关联 Hyper-V 站点的策略。Disassociate policies for the Hyper-V site. 在“Site Recovery 基础结构” > “对于 Hyper-V 站点” > “复制策略”中,右键单击关联的策略。In Site Recovery Infrastructure > For Hyper-V Sites > Replication Policies, double-click the associated policy. 右键单击站点 >“取消关联” 。Right-click the site > Disassociate.

  3. 删除 Hyper-V 主机。Delete Hyper-V hosts. 依次转到“Site Recovery 基础结构” > “对于 Hyper-V 站点” > “Hyper-V 主机” ,右键单击服务器,再单击“删除” 。In Site Recovery Infrastructure > For Hyper-V Sites > Hyper-V Hosts, right-click the server > Delete.

  4. 从 Hyper-V 站点中删除所有主机后,将该站点删除。Delete the Hyper-V site after all hosts have been removed from it. 依次转到“Site Recovery 基础结构” > “对于 Hyper-V 站点” > “Hyper-V 站点” ,右键单击站点,再单击“删除” 。In Site Recovery Infrastructure > For Hyper-V Sites > Hyper-V Sites, right-click the site > Delete.

  5. 如果 Hyper-V 主机处于“已断开连接” 状态,请对已删除的每个 Hyper-V 主机运行以下脚本。If your Hyper-V host was in a Disconnected state, then run the following script on each Hyper-V host that you removed. 该脚本清理服务器上的设置,并从保管库中取消注册该服务器。The script cleans up settings on the server, and unregisters it from the vault.

    pushd .
    try
    {
         $windowsIdentity=[System.Security.Principal.WindowsIdentity]::GetCurrent()
         $principal=new-object System.Security.Principal.WindowsPrincipal($windowsIdentity)
         $administrators=[System.Security.Principal.WindowsBuiltInRole]::Administrator
         $isAdmin=$principal.IsInRole($administrators)
         if (!$isAdmin)
         {
            "Please run the script as an administrator in elevated mode."
            $choice = Read-Host
            return;       
         }
    
        $error.Clear()    
        "This script will remove the old Azure Site Recovery Provider related properties. Do you want to continue (Y/N) ?"
        $choice =  Read-Host
    
        if (!($choice -eq 'Y' -or $choice -eq 'y'))
        {
        "Stopping cleanup."
        return;
        }
    
        $serviceName = "dra"
        $service = Get-Service -Name $serviceName
        if ($service.Status -eq "Running")
        {
            "Stopping the Microsoft Azure Site Recovery service..."
            net stop $serviceName
        }
    
        $asrHivePath = "HKLM:\SOFTWARE\Microsoft\Azure Site Recovery"
        $registrationPath = $asrHivePath + '\Registration'
        $proxySettingsPath = $asrHivePath + '\ProxySettings'
        $draIdvalue = 'DraID'
        $idMgmtCloudContainerId='IdMgmtCloudContainerId'
    
        if (Test-Path $asrHivePath)
        {
            if (Test-Path $registrationPath)
            {
                "Removing registration related registry keys."    
                Remove-Item -Recurse -Path $registrationPath
            }
    
            if (Test-Path $proxySettingsPath)
        {
                "Removing proxy settings"
                Remove-Item -Recurse -Path $proxySettingsPath
            }
    
            $regNode = Get-ItemProperty -Path $asrHivePath
            if($regNode.DraID -ne $null)
            {            
                "Removing DraId"
                Remove-ItemProperty -Path $asrHivePath -Name $draIdValue
            }
            if($regNode.IdMgmtCloudContainerId -ne $null)
            {            
                "Removing IdMgmtCloudContainerId"
                Remove-ItemProperty -Path $asrHivePath -Name $idMgmtCloudContainerId
            }
            "Registry keys removed."
        }
    
        # First retrieve all the certificates to be deleted
        $ASRcerts = Get-ChildItem -Path cert:\localmachine\my | where-object {$_.friendlyname.startswith('ASR_SRSAUTH_CERT_KEY_CONTAINER') -or $_.friendlyname.startswith('ASR_HYPER_V_HOST_CERT_KEY_CONTAINER')}
        # Open a cert store object
        $store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My","LocalMachine")
        $store.Open('ReadWrite')
        # Delete the certs
        "Removing all related certificates"
        foreach ($cert in $ASRcerts)
        {
            $store.Remove($cert)
        }
    }catch
    {    
        [system.exception]
        Write-Host "Error occurred" -ForegroundColor "Red"
        $error[0]
        Write-Host "FAILED" -ForegroundColor "Red"
    }
    popd
    

禁用对 VMware VM 或物理服务器(VMware 到 Azure)的保护Disable protection for a VMware VM or physical server (VMware to Azure)

  1. 依次转到“受保护的项” > “复制的项” ,右键单击计算机,再单击“禁用复制” 。In Protected Items > Replicated Items, right-click the machine > Disable replication.

  2. 在“禁用复制” 页中,选择下列选项之一:In Disable replication page, select one of these options:

    • 禁用复制并删除(推荐) - 此选项从 Azure Site Recovery 中删除复制的项,并停止复制计算机。Disable replication and remove (recommended) - This option remove the replicated item from Azure Site Recovery and the replication for the machine is stopped. 此外,还将清理配置服务器上的复制配置,并停止对这个受保护的服务器收取 Site Recovery 费用。Replication configuration on Configuration Server is cleaned up and Site Recovery billing for this protected server is stopped. 请注意,此选项仅在配置服务器处于连接状态时使用。Note that this option can only be used when Configuration Server is in connected state.
    • 删除 - 只有在源环境已删除或无法访问(未连接)时,才应使用此选项。Remove - This option is supposed to be used only if the source environment is deleted or not accessible (not connected). 此选项会从 Azure Site Recovery 中删除复制的项(停止计费)。This removes the replicated item from Azure Site Recovery (billing is stopped). 不过,并不会 清理配置服务器上的复制配置。Replication configuration on the Configuration Server will not be cleaned up.

    备注

    这两个选项都不会从受保护的服务器中卸载移动服务,需要手动卸载。In both the options mobility service will not be uninstalled from the protected servers, you need to uninstall it manually. 如果打算使用相同的配置服务器重新保护服务器,可以跳过卸载移动服务这一步。If you plan to protect the server again using the same Configuration server, you can skip uninstalling the mobility service.

备注

如果已对 VM 进行了故障转移并且该 VM 正在 Azure 中运行,请注意,禁用保护不会删除/影响故障转移的 VM。If you have already failed over a VM and it is running in Azure, note that disable protection doesn't remove / affect the failed over VM.

禁用对 Azure VM 的保护(Azure 到 Azure)Disable protection for a Azure VM (Azure to Azure)

  • 依次转到“受保护的项” > “复制的项” ,右键单击计算机,再单击“禁用复制” 。In Protected Items > Replicated Items, right-click the machine > Disable replication.

    备注

    不会从受保护的服务器中卸载移动服务,需要手动卸载。mobility service will not be uninstalled from the protected servers, you need to uninstall it manually. 如果你打算再次保护服务器,可以跳过卸载移动服务的步骤。If you plan to protect the server again, you can skip uninstalling the mobility service.

禁用对 Hyper-V 虚拟机(Hyper-V 到 Azure)的保护Disable protection for a Hyper-V virtual machine (Hyper-V to Azure)

备注

要在没有 VMM 服务器的情况下将 Hyper-V VM 复制到 Azure,请执行此过程。Use this procedure if you're replicating Hyper-V VMs to Azure without a VMM server. 若要使用 System Center VMM 到 Azure 方案复制虚拟机,请按照“禁用对使用 System Center VMM 到 Azure 方案复制的 Hyper-V 虚拟机的保护”中的说明操作If you are replicating your virtual machines using the System Center VMM to Azure scenario, then follow the instructions Disable protection for a Hyper-V virtual machine replicating using the System Center VMM to Azure scenario

  1. 依次转到“受保护的项” > “复制的项” ,右键单击计算机,再单击“禁用复制” 。In Protected Items > Replicated Items, right-click the machine > Disable replication.
  2. 在“禁用复制” 中,可以选择下列选项:In Disable replication, you can select the following options:
    • 禁用复制并删除(推荐) - 此选项从 Azure Site Recovery 中删除复制的项,并停止复制计算机。Disable replication and remove (recommended) - This option remove the replicated item from Azure Site Recovery and the replication for the machine is stopped. 此外,还将清理本地虚拟机上的复制配置,并停止对这个受保护的服务器收取 Site Recovery 费用。Replication configuration on the on-premises virtual machine will be cleaned up and Site Recovery billing for this protected server is stopped.

    • 删除 - 只有在源环境已删除或无法访问(未连接)时,才应使用此选项。Remove - This option is supposed to be used only if the source environment is deleted or not accessible (not connected). 此选项会从 Azure Site Recovery 中删除复制的项(停止计费)。This removes the replicated item from Azure Site Recovery (billing is stopped). 不过,并不会 清理本地虚拟机上的复制配置。Replication configuration on the on-premises virtual machine will not be cleaned up.

      备注

      如果选择“删除” 选项,请运行下面的一组脚本,清理本地 Hyper-V 服务器上的复制设置。If you chose the Remove option then run the following set of scripts to clean up the replication settings on-premises Hyper-V Server.

备注

如果已对 VM 进行了故障转移并且该 VM 正在 Azure 中运行,请注意,禁用保护不会删除/影响故障转移的 VM。If you have already failed over a VM and it is running in Azure, note that disable protection doesn't remove / affect the failed over VM.

  1. 在源 Hyper-V 主机服务器上,取消复制虚拟机。On the source Hyper-V host server, to remove replication for the virtual machine. 将 SQLVM1 替换为虚拟机名称,并通过管理 PowerShell 运行以下脚本Replace SQLVM1 with the name of your virtual machine and run the script from an administrative PowerShell

    $vmName = "SQLVM1"
    $vm = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ComputerSystem Where ElementName = '$vmName'"
    $replicationService = Get-WmiObject -Namespace "root\virtualization\v2"  -Query "Select * From Msvm_ReplicationService"
    $replicationService.RemoveReplicationRelationship($vm.__PATH)
    

禁用对使用 System Center VMM 到 Azure 方案复制到 Azure 的 Hyper-V 虚拟机的保护Disable protection for a Hyper-V virtual machine replicating to Azure using the System Center VMM to Azure scenario

  1. 依次转到“受保护的项” > “复制的项” ,右键单击计算机,再单击“禁用复制” 。In Protected Items > Replicated Items, right-click the machine > Disable replication.

  2. 在“禁用复制” 中,选择下列选项之一:In Disable replication, select one of these options:

    • 禁用复制并删除(推荐) - 此选项从 Azure Site Recovery 中删除复制的项,并停止复制计算机。Disable replication and remove (recommended) - This option remove the replicated item from Azure Site Recovery and the replication for the machine is stopped. 此外,还将清理本地虚拟机上的复制配置,并停止对这个受保护的服务器收取 Site Recovery 费用。Replication configuration on the on-premises virtual machine is cleaned up and Site Recovery billing for this protected server is stopped.

    • 删除 - 只有在源环境已删除或无法访问(未连接)时,才应使用此选项。Remove - This option is supposed to be used only if the source environment is deleted or not accessible (not connected). 此选项会从 Azure Site Recovery 中删除复制的项(停止计费)。This removes the replicated item from Azure Site Recovery (billing is stopped). 不过,并不会 清理本地虚拟机上的复制配置。Replication configuration on the on-premises virtual machine will not be cleaned up.

      备注

      如果选择“删除” 选项,请运行下面的脚本,清理本地 VMM 服务器上的复制设置。If you chose the Remove option, then tun the following scripts to clean up the replication settings on-premises VMM Server.

  3. 从源 VMM 服务器上的 VMM 控制台使用 PowerShell(需要管理员权限)运行此脚本。Run this script on the source VMM server, using PowerShell (administrator privileges required) from the VMM console. 将占位符 SQLVM1 替换为虚拟机名称。Replace the placeholder SQLVM1 with the name of your virtual machine.

    $vm = get-scvirtualmachine -Name "SQLVM1"
    Set-SCVirtualMachine -VM $vm -ClearDRProtection
    
  4. 上述步骤清理 VMM 服务器上的复制设置。The above steps clear the replication settings on the VMM server. 若要停止运行在 Hyper-V 主机服务器上的虚拟机的复制,请运行以下脚本。To stop replication for the virtual machine running on the Hyper-V host server, run this script. 将 SQLVM1 替换为虚拟机的名称,将 host01.contoso.com 替换为 Hyper-V 主机服务器的名称。Replace SQLVM1 with the name of your virtual machine, and host01.contoso.com with the name of the Hyper-V host server.

    $vmName = "SQLVM1"
    $hostName  = "host01.contoso.com"
    $vm = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ComputerSystem Where ElementName = '$vmName'" -computername $hostName
    $replicationService = Get-WmiObject -Namespace "root\virtualization\v2"  -Query "Select * From Msvm_ReplicationService"  -computername $hostName
    $replicationService.RemoveReplicationRelationship($vm.__PATH)
    

禁用对使用 System Center VMM 到 VMM 方案复制到辅助 VMM 服务器的 Hyper-V 虚拟机的保护Disable protection for a Hyper-V virtual machine replicating to secondary VMM Server using the System Center VMM to VMM scenario

  1. 依次转到“受保护的项” > “复制的项” ,右键单击计算机,再单击“禁用复制” 。In Protected Items > Replicated Items, right-click the machine > Disable replication.

  2. 在“禁用复制” 中,选择下列选项之一:In Disable replication, select one of these options:

    • 禁用复制并删除(推荐) - 此选项从 Azure Site Recovery 中删除复制的项,并停止复制计算机。Disable replication and remove (recommended) - This option remove the replicated item from Azure Site Recovery and the replication for the machine is stopped. 此外,还将清理本地虚拟机上的复制配置,并停止对这个受保护的服务器收取 Site Recovery 费用。Replication configuration on the on-premises virtual machine is cleaned up and Site Recovery billing for this protected server is stopped.

    • 删除 - 只有在源环境已删除或无法访问(未连接)时,才应使用此选项。Remove - This option is supposed to be used only if the source environment is deleted or not accessible (not connected). 此选项会从 Azure Site Recovery 中删除复制的项(停止计费)。This removes the replicated item from Azure Site Recovery (billing is stopped). 不过,并不会 清理本地虚拟机上的复制配置。Replication configuration on the on-premises virtual machine will not be cleaned up. 运行下面的一组脚本,清理本地虚拟机上的复制设置。Run the following set of scripts to clean up the replication settings on-premises virtual machines.

      备注

      如果选择“删除” 选项,请运行下面的脚本,清理本地 VMM 服务器上的复制设置。If you chose the Remove option, then tun the following scripts to clean up the replication settings on-premises VMM Server.

  3. 从源 VMM 服务器上的 VMM 控制台使用 PowerShell(需要管理员权限)运行此脚本。Run this script on the source VMM server, using PowerShell (administrator privileges required) from the VMM console. 将占位符 SQLVM1 替换为虚拟机名称。Replace the placeholder SQLVM1 with the name of your virtual machine.

    $vm = get-scvirtualmachine -Name "SQLVM1"
    Set-SCVirtualMachine -VM $vm -ClearDRProtection
    
  4. 在辅助 VMM 服务器上,运行下面的脚本,清理辅助虚拟机的设置:On the secondary VMM server, run this script to clean up the settings for the secondary virtual machine:

    $vm = get-scvirtualmachine -Name "SQLVM1"
    Remove-SCVirtualMachine -VM $vm -Force
    
  5. 在辅助 VMM 服务器上刷新 Hyper-V 主机服务器上的虚拟机,以便在 VMM 控制台中重新检测辅助 VM。On the secondary VMM server, refresh the virtual machines on the Hyper-V host server, so that the secondary VM gets detected again in the VMM console.

  6. 上述步骤清理 VMM 服务器上的复制设置。The above steps clear up the replication settings on the VMM server. 若要停止虚拟机的复制,请在主 VM 和辅助 VM 上运行以下脚本。If you want to stop replication for the virtual machine, run the following script oh the primary and secondary VMs. 将 SQLVM1 替换为虚拟机名称。Replace SQLVM1 with the name of your virtual machine.

    Remove-VMReplication -VMName "SQLVM1"