在 RHEL 7、RHEL 8 和 RHEL 9 中使用 virt-v2v工具 将虚拟机从其他虚拟化平台转换为 KVM支持的虚拟机

目录

 

一、介绍

支持的转换

支持进行转换的客户机操作系统

支持转换的虚拟机管理程序

V2V 转换支持的其他注意事项

如何进行V2V转换?

二、 将 VMware vCenter Linux 虚拟机转换为 KVM

先决条件

程序

第 1 步

步骤 2

步骤 3

步骤 4

步骤 5

二、将 VMware vCenter Windows 虚拟机转换为 KVM

先决条件

程序

第 1 步

步骤 2

步骤 3

步骤 4

步骤 5

步骤 6

三、将虚拟机从 VMware 导出为 OVA 文件,并将其导入到 KVM 中 

先决条件

程序

第 1 步

步骤 2

步骤 3

步骤 4

步骤 5

步骤 6

四、将 Citrix Xen Linux 虚拟机转换为 KVM

先决条件

程序

第 1 步

步骤 2

步骤 3

步骤 4

步骤 5

步骤 6

步骤 7

步骤 8


 

一、介绍

virt-v2v 工具从外部虚拟机管理程序转换虚拟机 (VM),包括其磁盘映像和元数据,以便与带有 libvirt 管理的 KVM 的 Red Hat Enterprise Linux、Red Hat Virtualization 和 Red Hat OpenStack Platform 一起使用。virt-v2v 可以转换在 Xen 和 VMware ESXi 环境中运行的 Red Hat Enterprise Linux 和 Windows 虚拟机。

本文概述了 VM 转换,并提供了指向特定类型转换过程的链接。

virt-v2v 包含在 Red Hat Enterprise Linux 7 (RHEL 7)、Red Hat Enterprise Linux 8 (RHEL 8) 和 Red Hat Enterprise Linux 9 (RHEL 9) 中,并与 virt-v2v 软件包一起安装。在 Red Hat Enterprise Linux 7 中,virt-v2v 也可以从 Red Hat OpenStack Platform 频道获得。

重要提示:virt-v2v 目前仅在 AMD64 和 Intel 64 架构(也称为 x86_64)上受支持。v2v 转换不支持所有其他体系结构,包括 IBM Z、IBM POWER 和 64 位 ARM。

支持的转换

支持进行转换的客户机操作系统

virt-v2v 只能将运行特定虚拟机操作系统的虚拟机转换为在 KVM 上运行。在 RHEL 7、RHEL 8 和 RHEL 9 上使用 virt-v2v 时,这也有所不同:

Guest OSRHEL 7 hostRHEL 8 hostRHEL 9 host
Red Hat Enterprise Linux 5

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Red Hat Enterprise Linux 6

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supported
Red Hat Enterprise Linux 7

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Red Hat Enterprise Linux 8Not supported

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Red Hat Enterprise Linux 9Not supportedNot supported

1f69d7a8dcb3c20a48d2c495e181f16c.png

SUSE Linux Enterprise Server 11, SP4 and later [1]

1f69d7a8dcb3c20a48d2c495e181f16c.png

 On RHEL 7.7 and later
Not supportedNot supported
SUSE Linux Enterprise Server 12

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

SUSE Linux Enterprise Server 15

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Windows 8

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Windows 8.1

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Windows 10

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Windows 11Not supported

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Windows Server 2008

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Windows Server 2008 R2

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Windows Server 2012

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Windows Server 2012 R2

1f69d7a8dcb3c20a48d2c495e181f16c.png

Not supportedNot supported
Windows Server 2016

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Windows Server 2019

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Windows Server 2022Not supported

1f69d7a8dcb3c20a48d2c495e181f16c.png

1f69d7a8dcb3c20a48d2c495e181f16c.png

Debian [2]Technology Preview in RHEL 7.4 and laterTechnology PreviewTechnology Preview
Ubuntu [2]Technology Preview in RHEL 7.4 and laterTechnology PreviewTechnology Preview

[1] 使用 X 图形和 SUSE Linux Enterprise Server 11 操作系统的虚拟机应在转换后重新调整,以使图形正常工作。为此,请在迁移完成后在客户机操作系统中使用 sax2 分发工具。
[2] 作为技术预览,不支持转换 Debian 和 Ubuntu 虚拟机。此外,此转换目前存在以下已知问题:
virt-v2v 无法更改 GRUB2 配置中的默认内核,并且在转换过程中,即使虚拟机上有更优化的内核版本,虚拟机中配置的内核也不会更改。
* 将 linux 虚拟机转换为 KVM虚拟机 后,虚拟机的网络接口名称可能会更改,因此需要手动配置。

注意:在某些情况下,上述未列出的任何操作系统的 virt-v2v 转换可能有效,但 Red Hat 不支持。

支持转换的虚拟机管理程序

支持从以下虚拟机管理程序进行转换:

  • 红帽企业 Linux 5 Xen
  • VMware vSphere ESX(i) - 版本 6.0、6.5、6.7、7.0 和 8.0

注意:在某些情况下,从上面未列出的任何虚拟机管理程序进行 virt-v2v 转换可能有效,但 Red Hat 不支持。

V2V 转换支持的其他注意事项

使用 UEFI 固件的虚拟机目前仅支持转换为以下 KVM 虚拟机管理程序:

  • Red Hat Virtualization 4.2 及更高版本 - 这需要 virt-v2v 版本 1.39.12 或更高版本
  • RHEL 7、RHEL 8 和 RHEL 9
  • 红帽 OpenStack 平台

但请注意,在使用基础结构迁移解决方案时,这些功能受支持。

如何进行V2V转换?

准备和执行 v2v 转换的具体步骤可能因 VM 的客户机操作系统和原始虚拟机监控程序而异。有关特定转化的详细信息,请参阅以下内容之一:

二、 将 VMware vCenter Linux 虚拟机转换为 KVM

virt-v2v 工具从外部虚拟机管理程序转换虚拟机 (VM),包括其磁盘映像和元数据,以便与带有 libvirt 管理的 KVM 的 Red Hat Enterprise Linux、Red Hat Virtualization 和 Red Hat OpenStack Platform 一起使用。

本文提供有关将 Linux VM 从 VMware vCenter 虚拟机管理程序转换为在 Red Hat Enterprise Linux 7 KVM、Red Hat Enterprise Linux 8 KVM 和 Red Hat Enterprise Linux 9 KVM 上运行的说明。

有关 virt-v2v 工具、支持的转换以及指向其他类型的 VM 转换的链接的概述,请参阅在 RHEL 7、RHEL 8 和 RHEL 9 中使用 virt-v2v 将虚拟机从其他管理程序转换为 KVM

成功完成转换过程后,virt-v2v 会为转换后的虚拟机创建一个与原始虚拟机同名的新 libvirt 域 XML 文件。可以使用 libvirt 工具(如 virt-manager 或 virsh)启动 VM。

先决条件

  • virt-v2v 必须在 Red Hat Enterprise Linux 64 位主机系统上运行。

  • 请确保在运行转换过程之前停止 VM。

  • 以下最低系统资源必须可用:

    • 最低网络速度 1Gbps
    • 磁盘空间:足够的空间来存储 VM 的磁盘映像,外加 1 GB
    • 根据下表,VM 文件系统中有足够的可用空间:
File systemMinimum free space
Root file system100 MB
/boot50 MB
Every other mountable file system10 MB
  • 源 VM 必须具有 100 个或更多空闲索引节点 (inode)。如果 VM 没有足够数量的空闲 inode,例如,如果它使用 XFS 文件系统并包含非常多的文件,则转换将非常慢或失败。

程序

第 1 步

在主机系统上安装 virt-v2v 软件包及其依赖项:

# yum install virt-v2v
 

步骤 2

要转换 VMware Linux 虚拟机,请使用以下命令并将 vcenter.example.com/Datacenter/esxi 替换为 VMWare vCenter 的路径,并将 guestvm1 替换为要转换的 VM 的名称:

 
# virt-v2v -ic vpx://username@vcenter.example.com/Datacenter/esxi "guestvm1"

注意:如果 vpx 用户名包含反斜杠字符(例如 DOMAIN\USER),则必须为字符输入 URI 转义:DOMAIN%5cUSER。同样,必须使用 %20 代码输入数据中心名称中的空格。

有关 virt-v2v 参数的完整列表,请参见 virt-v2v 手册页。

步骤 3

对 VMware vCenter 服务器进行身份验证。

连接到 VMware vCenter 服务器需要身份验证。virt-v2v 在连接到 VMware vCenter 时支持密码认证。可以在转换过程中输入密码,也可以使用 --password-file 选项输入密码。

注意:如果 VMware vCenter 服务器未配置有效的 vCenter CA 证书,例如,如果它使用自签名证书,则连接到服务器将失败。在这种情况下,可以通过向连接 URI 添加来显式禁用证书检查,如下所示:?no_verify=1

... -ic vpx://username@vcenter.example.com/Datacenter/esxi.example.com?no_verify=1 ...

步骤 4

观察转换进度。成功的转换输出类似于以下内容:

 
# virt-v2v -ic vpx://username@vcenter.example.com/Datacenter/esxi?no_verify=1 "guestvm1"
[   0.0] Opening the source -ic vpx://username@esx.example.com/Datacenter/esxi
[   1.1] Creating an overlay to protect the source from being modified
[   1.7] Initializing the target
[   1.7] Opening the overlay
[  25.8] Inspecting the overlay
[  30.9] Checking for sufficient free disk space in the guest
[  30.9] Estimating space required on target for each disk
[  30.9] Converting Red Hat Enterprise Linux Server release 5.11 (Tikanga) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  45.4] Mapping filesystem data to avoid copying unused and blank areas
[  45.5] Closing the overlay
[  45.7] Checking if the guest needs BIOS or UEFI to boot
[  45.7] Assigning disks to buses
[  45.7] Copying disk 1/1 to /var/tmp/RHEL 5.11 Server-sda (qcow2)
[  93.0] Creating output metadata
[  93.0] Finished off

步骤 5

确认 VM 已正确导入:

 
# virsh list --all

如果此命令列出了新的 Linux VM,则表示已成功转换并导入了 VM。在删除原始 VM 或迁移活动服务之前,先启动 VM 的客户机操作系统并确认其全部功能。

二、将 VMware vCenter Windows 虚拟机转换为 KVM

virt-v2v 工具从外部虚拟机管理程序转换虚拟机 (VM),包括其磁盘映像和元数据,以便与带有 libvirt 管理的 KVM 的 Red Hat Enterprise Linux、Red Hat Virtualization 和 Red Hat OpenStack Platform 一起使用。

本文提供有关将 Windows VM 从 VMware vCenter 虚拟机管理程序转换为在 Red Hat Enterprise Linux 7 KVM、Red Hat Enterprise Linux 8 KVM 和 Red Hat Enterprise Linux 9 KVM 上运行的说明。

有关 virt-v2v 工具、支持的转换以及其他类型的虚拟机转换的链接的概述,请参阅在 RHEL 7、RHEL 8 和 RHEL 9 中使用 virt-v2v 将虚拟机从其他虚拟机管理程序转换为 KVM

成功完成转换过程后,virt-v2v 会为转换后的虚拟机创建一个与原始虚拟机同名的新 libvirt 域 XML 文件。可以使用 libvirt 工具(如 virt-manager 或 virsh)启动 VM。

先决条件

  • virt-v2v 必须在 Red Hat Enterprise Linux 64 位主机系统上运行。

  • 在运行转换过程之前,请确保虚拟机已正常且完全关闭,而不是处于快速重启或休眠模式,否则将出现此问题

  • 如果尝试使用 virt-v2v 实用程序转换 Windows 7 或 Windows Server 2008 R2 虚拟机 (VM),则必须将对 VM 应用对 SHA-2 签名证书的支持。有关执行此操作的说明,请参阅Microsoft安全公告3033929。如果未应用 SHA-2 支持,则转换后的 VM 将无法正常工作。

  • 以下最低系统资源必须可用:

    • 最低网络速度 1Gbps
    • 磁盘空间:足够的空间来存储 VM 的磁盘映像,外加 1 GB
    • 根据下表,VM 文件系统中有足够的可用空间:
文件系统最小可用空间
Root file system or c:\100 兆字节
所有其他可挂载的文件系统10 兆字节
  • 源 VM 必须具有 100 个或更多空闲索引节点 (inode)。如果 VM 没有足够数量的空闲 inode,例如,如果它使用 XFS 文件系统并包含非常多的文件,则转换将非常慢或失败。

程序

第 1 步

在主机系统上安装 virt-v2v 和 virtio-win 软件包及其依赖项:

 
# yum install virt-v2v virtio-win

步骤 2

要转换 VMware Windows 虚拟机,请使用以下命令并将 vcenter.example.com/Datacenter/esxi 替换为 VMWare vCenter 的路径,并将 guestvm1 替换为要转换的 VM 的名称:

 
# virt-v2v -ic vpx://username@vcenter.example.com/Datacenter/esxi "guestvm1"

注意:如果 vpx 用户名包含反斜杠字符(例如 DOMAIN\USER),则需要为字符输入 URI 转义:DOMAIN%5cUSER。同样,必须使用 %20 代码输入数据中心名称中的空格。

有关 virt-v2v 参数的完整列表,请参见 virt-v2v 手册页。

步骤 3

对 VMware vCenter 服务器进行身份验证。

连接到 VMware vCenter 服务器需要身份验证。virt-v2v 在连接到 VMware vCenter 时支持密码认证。可以在转换过程中输入密码,也可以使用 --password-file 选项输入密码。

注意:如果 VMware vCenter 服务器未配置有效的 vCenter CA 证书,例如,如果它使用自签名证书,则连接到服务器将失败。在这种情况下,可以通过向连接 URI 添加来显式禁用证书检查,如下所示:?no_verify=1

 
... -ic vpx://username@vcenter.example.com/Datacenter/esxi.example.com?no_verify=1 ...

步骤 4

观察转换进度。成功的转换输出类似于以下内容:

 
# virt-v2v -ic 'vpx://username@vcenter.example.com/Datacenter/esxi/?no_verify=1' "windows_vm" -o local -os DIRECTORY
[   0.0] Opening the source -i libvirt -ic vpx://username@esx.example.com/Datacenter/esxi/?no_verify=1 windows_vm
Enter administrator's password for username@esx.example.com:
Enter host password for user 'administrator':
[  16.0] Creating an overlay to protect the source from being modified
[  18.0] Opening the overlay
[  50.0] Initializing the target -o local -os /conversions/
[  50.0] Inspecting the overlay
[ 511.0] Checking for sufficient free disk space in the guest
[ 511.0] Estimating space required on target for each disk
[ 511.0] Converting Windows 7 Enterprise to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 548.0] Mapping filesystem data to avoid copying unused and blank areas
[ 556.0] Closing the overlay
[ 556.0] Copying disk 1/1 to /conversions/windows_vm (raw)
[ 670.0] Creating output metadata
[ 670.0] Finished off

步骤 5

使用以下命令确认 VM 已正确导入:

 
# virsh list --all

如果此命令列出了新的 Windows VM,则表示已成功转换并导入了 VM。

步骤 6

启动 VM。

脱机转换完成后,转换的客户机尚未安装所有必要的驱动程序以正常工作。这些将在客户机首次启动时自动安装。

重要事项: 首次登录客户机时,请勿中断自动驱动程序安装过程,因为这可能会阻止客户机随后正确引导。

然后,在删除原始 VM 或迁移活动服务之前,请确认 VM 的全部功能。

三、将虚拟机从 VMware 导出为 OVA 文件,并将其导入到 KVM 中 

virt-v2v 工具从外部虚拟机管理程序转换虚拟机 (VM),包括其磁盘映像和元数据,以便与由 libvirt、Red Hat Virtualization 和 Red Hat OpenStack Platform 管理的 Red Hat Enterprise Linux KVM 一起使用。

本文提供有关将 VM 从导出为 OVA 文件的 VMware vCenter 虚拟机管理程序转换为在 Red Hat Enterprise Linux 7 KVM、Red Hat Enterprise Linux 8 KVM 和 Red Hat Enterprise Linux 9 KVM 上运行的说明。

有关 virt-v2v 工具、支持的转换以及指向其他类型的 VM 转换的链接的概述,请参阅在 RHEL 7、RHEL 8 和 RHEL 9 中使用 virt-v2v 将虚拟机从其他管理程序转换为 KVM

成功完成转换过程后,virt-v2v 会为转换后的虚拟机创建一个与原始虚拟机同名的新 libvirt 域 XML 文件。可以使用 libvirt 工具(如 virt-manager 或 virsh)启动 VM。

先决条件

  • virt-v2v 必须在 Red Hat Enterprise Linux 64 位主机系统上运行。

  • 以下最低系统资源必须可用:

    • 最低网络速度 1Gbps
    • 磁盘空间:足够的空间来存储 VM 的磁盘映像,外加 1 GB
    • 根据下表,VM 文件系统中有足够的可用空间:
文件系统最小可用空间
根文件系统100 兆字节
/靴子50 兆字节
所有其他可挂载的文件系统10 兆字节
  • 源 VM 必须具有 100 个或更多空闲索引节点 (inode)。如果 VM 没有足够数量的空闲 inode,例如,如果它使用 XFS 文件系统并包含非常多的文件,则转换将非常慢或失败。

程序

第 1 步

在主机系统上安装 virt-v2v 和 virtio-win 软件包及其依赖项:

# yum install virt-v2v virtio-win

步骤 2

将 VMware 虚拟机导出为 .ova 文件:“文件文件夹”(.ovf) 或“单个文件”(.ova) 都可以使用。.ova 文件实际上是未压缩的 .tar 文件,因此您可以使用命令(例如 tar tf VM.ova)来查看其内容。导出 VMware 虚拟机的方法因 VMware 产品而异。有关详细说明,请参阅 VMware 文档或联系您的供应商。在导出 .ova 文件之前,请确保虚拟机已正常关闭。对于 Windows,请确保操作系统确实已关闭,并且未进入休眠或快速启动模式,否则转换将因此问题而失败。

步骤 3

使用 scp 命令将创建的 .ova 文件传输到转换主机。

步骤 4

要从 .ova 文件转换虚拟机,请使用以下命令,将 guestvm1.ova 替换为要转换的 .ova 文件的名称:

# virt-v2v -i ova guestvm1.ova -of qcow2

OR

# virt-v2v -i ova “Folder of files(OVF)” -of qcow2

有关 virt-v2v 参数的完整列表,请参见 virt-v2v 手册页。

步骤 5

观察转换进度。成功的转换输出类似于以下内容:

# virt-v2v -i ova guestvm1.ova -of qcow2
[   0.0] Opening the source -i ova guestvm1.ova
[   0.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[   4.0] Initializing the target -o libvirt
[   4.0] Inspecting the overlay
[  10.0] Checking for sufficient free disk space in the guest
[  10.0] Estimating space required on target for each disk
[  10.0] Converting Red Hat Enterprise Linux release 8 to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  14.0] Mapping filesystem data to avoid copying unused and blank areas
[  14.0] Closing the overlay
[  14.0] Copying disk 1/1 to /guests/guestvm1-sda (qcow2)
    (100.00/100%)
[  28.0] Creating output metadata
Pool default refreshed

Domain guestvm1 defined from /tmp/v2vlibvirt4fe796.xml
[  28.0] Finishing off

步骤 6

确认 VM 已正确导入:

# virsh list --all

如果此命令列出了新的 Linux 虚拟机,则表示您已成功转换并导入了 VM。然后,启动 VM 并确认 VM 的全部功能,然后删除原始 VM 或迁移活动服务。

四、将 Citrix Xen Linux 虚拟机转换为 KVM

virt-v2v 工具从外部虚拟机管理程序转换虚拟机,包括其磁盘镜像和元数据,以便与带有 libvirt、Red Hat Virtualization 和 Red Hat OpenStack Platform 管理的 KVM 的 Red Hat Enterprise Linux 一起使用。

本文提供了从 Xen 虚拟机管理程序转换和导入 Red Hat Enterprise Linux 虚拟机以在 Red Hat Enterprise Linux 7 KVM、Red Hat Enterprise Linux 8 KVM 和 Red Hat Enterprise Linux 9 KVM 上运行的说明。

有关 virt-v2v 工具、支持的转换以及其他类型的虚拟机转换的链接的概述,请参阅在 RHEL 7、RHEL 8 和 RHEL 9 中使用 virt-v2v 将虚拟机从其他虚拟机管理程序转换为 KVM

成功完成转换过程后,virt-v2v 会为转换后的虚拟机创建一个与原始虚拟机同名的新 libvirt 域 XML 文件。可以使用 libvirt 工具(如 virt-manager 或 virsh)启动 VM。

先决条件

  • 确保在运行转换过程之前已停止虚拟机。

  • 以下最低系统资源必须可用:

    • 最低网络速度 1Gbps
    • 磁盘空间:足够的空间来存储 VM 的磁盘映像,外加 1 GB
    • 根据下表,VM 文件系统中有足够的可用空间:
文件系统最小可用空间
根文件系统100 兆字节
/靴子50 兆字节
所有其他可挂载的文件系统10 兆字节
  • 源 VM 必须具有 100 个或更多空闲索引节点 (inode)。如果 VM 没有足够数量的空闲 inode,例如,如果它使用 XFS 文件系统并包含非常多的文件,则转换将非常慢或失败。

程序

第 1 步

安装 virt-v2v 软件包及其依赖项:

# yum install virt-v2v

步骤 2

如果 virt-v2v 转换服务器是 RHEL 9,则需要使用 RHEL 5 启用现代 ssh 实现:

2a.将以下 “Host” 节添加到您的 ~/.ssh/config 中:

Host xen.example.com
   KexAlgorithms                +diffie-hellman-group14-sha1
   MACs                         +hmac-sha1
   HostKeyAlgorithms            +ssh-rsa
   PubkeyAcceptedKeyTypes           +ssh-rsa
   PubkeyAcceptedAlgorithms         +ssh-rsa

2b.使用以下内容创建名为 $HOME/openssl-sha1.cnf 的文件:

   .include /etc/ssl/openssl.cnf
   [openssl_init]
   alg_section = evp_properties
   [evp_properties]
   rh-allow-sha1-signatures = yes

2c.将以下变量导出到 virt-v2v 进程的环境中:

OPENSSL_CONF=$HOME/openssl-sha1.cn

步骤 3

配置从 virt-v2v 转换服务器到远程 Xen 主机的无密码 SSH 访问。

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
# ssh-agent 
SSH_AUTH_SOCK=/tmp/ssh-36jmUA3rn2JS/agent.24318; export SSH_AUTH_SOCK;
SSH_AGENT_PID=24319; export SSH_AGENT_PID;
echo Agent pid 24319;
# SSH_AUTH_SOCK=/tmp/ssh-36jmUA3rn2JS/agent.24318; export SSH_AUTH_SOCK;
# SSH_AGENT_PID=24319; export SSH_AGENT_PID;
# echo Agent pid 24319;
Agent pid 24319
# ssh-add 
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

步骤 4

将 SSH 公钥添加到 Xen 主机上的 /root/.ssh/authorized_keys 文件中。

# ssh-copy-id root@xen-example-host.com
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@xen-example-host.com's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@xen-example-host.com'"
and check to make sure that only the key(s) you wanted were added.

步骤 5

测试 SSH 配置:

# ssh root@xen-example-host.com
Last login: Tue Nov  1 14:39:21 2016 from ovpn-123-45.brq.redhat.com

如果 SSH 配置成功,转换服务器将您登录到 Xen 主机,并且不会请求任何密码。

步骤 6

要转换 Xen Linux 虚拟机,请使用以下命令,并替换:
testguest 替换为已转换 VM
的预期名称 - $pool转换为后的 VM 应使用的
存储池 - $format转换为后的 VM 应使用的磁盘格式,例如 qcow2 或 raw

# virt-v2v -ic 'xen+ssh://root@xen.example.com' testguest -os $pool -of $format

有关 virt-v2v 参数的列表,请参见 virt-v2v 手册页。

步骤 7

观察转换进度。以下示例显示了 virt-v2v 转换在 Xen 主机上运行的 Red Hat Enterprise Linux 5 虚拟机的进度:

# virt-v2v -ic "xen+ssh://root@xen-sample-host.com" -os default rhel5-para -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://root@xen-sample-host. com rhel5-para
[   0.0] Creating an overlay to protect the source from being modified
[   0.0] Opening the overlay
[  69.0] Initializing the target -o libvirt -os default
[  69.0] Inspecting the overlay
[  80.0] Checking for sufficient free disk space in the guest
[  80.0] Estimating space required on target for each disk
[  80.0] Converting Red Hat Enterprise Linux Server release 5.11 to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 136.0] Mapping filesystem data to avoid copying unused and blank areas
[ 137.0] Closing the overlay
[ 137.0] Checking if the guest needs BIOS or UEFI to boot
[ 137.0] Copying disk 1/1 to /var/lib/libvirt/images/rhel5-para-sda (raw)
    (100.00/100%)
[ 599.0] Creating output metadata
Pool default refreshed

Domain rhel5-para defined from /tmp/v2vlibvirt8e77ed.xml

[ 599.0] Finishing off

步骤 8

确认 VM 已正确导入:

# virsh list --all

如果此命令列出了新的 Linux 虚拟机,则表示您已成功转换并导入了 VM。在删除原始 VM 或迁移活动服务之前,启动 VM 并确认其全部功能。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

技术瘾君子1573

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值