将 VMware vCenter Linux 虚拟机转换为 KVM
virt-v2v 工具将虚拟机(VM),包括其磁盘镜像和元数据,从外部 hypervisor 转换为使用具有 libvirt、Red Hat Virtualization 和 Red Hat OpenStack Platform 管理的 KVM 的 Red Hat Enterprise Linux。
本文档提供了将 Linux 虚拟机从 VMware vCenter hypervisor 转换为在 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 )启动虚拟机。
先决条件
-
virt-v2v 必须在 Red Hat Enterprise Linux 64 位主机系统上运行。
-
确保在运行转换过程前虚拟机已停止。
-
必须提供以下最小系统资源:
- 最小网络速度 1Gbps
- 磁盘空间:存储虚拟机的磁盘镜像的足够空间,再加上 1 GB
- 根据下表,在虚拟机文件系统中有足够的可用空间:
| 文件系统 | 最小可用空间 |
|---|---|
| root 文件系统 | 100 MB |
| /boot | 50 MB |
| 其它可挂载的文件系统 | 10 MB |
- 源虚拟机必须有 100 个或更多可用的索引节点(inode)。如果虚拟机没有足够的可用 inode,例如,如果它使用 XFS 文件系统并包含大量文件,则转换会非常慢,或者将失败。
流程
第 1 步
在主机系统上安装 virt-v2v 软件包及其依赖项:
# yum install virt-v2v
第 2 步
要转换 VMware Linux 虚拟机,请使用以下命令,并将 vcenter.example.com/Datacenter/esxi 替换为 VMWare vCenter 的路径,将 guestvm1 替换为要转换的虚拟机的名称:
# 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 服务器需要身份验证。在连接到 VMware vCenter 时,virt-v2v 支持密码身份验证。可以在转换过程中输入密码,也可以使用 --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 步
确认虚拟机已正确导入:
# virsh list --all
如果这个命令列出了新的 Linux 虚拟机,则表示您已成功转换并导入了虚拟机。引导虚拟机的客户机操作系统,并在删除原始虚拟机或迁移活跃的服务前确认其完整的功能。
其他资源
有关在 RHEL 7 中使用 libvirt 管理虚拟机的更多信息,请参阅 Red Hat Enterprise Linux 7 虚拟化部署和管理指南。
有关在 RHEL 8 中使用 libvirt 管理虚拟机的更多信息,请参阅 RHEL 8 配置和管理虚拟化。
有关在 RHEL 9 中使用 libvirt 管理虚拟机的更多信息,请参阅 RHEL 9 配置和管理虚拟化。
有关使用 virt-v2v 转换虚拟机的更多信息,您可以查看以下文章:
- 将 VMware vCenter Linux 虚拟机转换为 KVM
- 将 VMware vCenter Windows 虚拟机转换为 KVM
- 转换 VMware 虚拟机,以导入到 Red Hat OpenStack Platform
- 将 VMware 中的虚拟机导出为 OVA 文件,并将其导入到 KVM 中
- 将 Xen Linux 虚拟机转换为 KVM
另外,您可以参考 virt-v2v 手册页和 virt-v2v 上游文档。
Comments