创建虚拟机时报hvm错误

在使用KVM的virt-install命令安装Ubuntu时,可能会遇到找不到HVM内核的错误。文章指出,如果使用--cdrom选项,将无法配合--extra-args参数。为了解决这个问题,需要使用--location参数,并且提到ISO文件实际上是压缩文件。提供了解决该问题的线索,即理解ISO文件的性质并寻找替代方法。

  1. kvm使用virt-install安装ubuntu的时候(或大部分ubuntu的时候),会报错Couldn't find hvm kernel for Ubuntu tree
    这个问题国内大部分解决方案并不适用,引用国外的一句话

If you use --cdrom in replace of --location you will loose some options like --extra-args ! This useful parameter could not be used in cooperation with --cdrom ! If you want to use --extra-args you must use --location ! If you like this parameter you must overcome to this problem such a different way! If you want to overcome to this problem, you must know that .iso files are a type of compressed files, first of all! Yes! They are some special type of compressed files like .zip or .rar, .tar.gz and so etc.

  1. 顺便挂一个可用的ubuntu20 iso Ubuntu Server 20.04.1 LTS (Focal Fossa)
在 KVM 环境中,结合 **OCFS2(Oracle Cluster File System 2)** 和 **SCSI 存储** 创建虚拟机,通常涉及共享存储的配置与虚拟化资源的管理。OCFS2 是一种集群文件系统,适用于需要共享访问相同存储设备的高可用性场景,而 SCSI 存储设备则可作为底层物理存储被多个 KVM 主机访问。 ### 1. 环境准备 - **硬件要求**:确保所有节点(KVM 主机)能够访问共享的 SCSI 存储设备,例如通过 SAN 或 iSCSI 配置的共享磁盘。 - **软件要求**: - 安装 `ocfs2-tools` 和 `ocfs2console` 工具包。 - 安装 `libvirt`、`qemu-kvm` 等 KVM 虚拟化相关组件。 - **网络配置**:确保各节点之间有稳定的内部网络连接,用于 OCFS2 的集群通信。 ### 2. 配置 OCFS2 文件系统 将共享的 SCSI 存储设备格式化为 OCFS2 文件系统,并挂载到所有 KVM 节点上。 ```bash # 格式化设备为 OCFS2 mkfs.ocfs2 /dev/sdX1 # 创建挂载点 mkdir -p /mnt/ocfs2 # 挂载 OCFS2 文件系统 mount -t ocfs2 /dev/sdX1 /mnt/ocfs2 ``` 确保所有节点上的 `/etc/ocfs2/cluster.conf` 文件一致,定义集群节点信息,以便实现集群一致性。 ### 3. 配置 libvirt 使用 OCFS2 存储池 在每个 KVM 节点上配置 libvirt 存储池,指向挂载的 OCFS2 目录。 ```xml <!-- /etc/libvirt/storage/ocfs2-pool.xml --> <pool type="dir"> <name>ocfs2-pool</name> <target> <path>/mnt/ocfs2/vm_images</path> </target> </pool> ``` 应用存储池配置: ```bash virsh pool-define /etc/libvirt/storage/ocfs2-pool.xml virsh pool-start ocfs2-pool virsh pool-autostart ocfs2-pool ``` ### 4. 创建虚拟机镜像 使用 `qemu-img` 创建虚拟机磁盘镜像文件,并将其存放在 OCFS2 共享目录中: ```bash qemu-img create -f qcow2 /mnt/ocfs2/vm_images/vm1.img 20G ``` 该镜像文件可在集群中的任意节点被访问,便于虚拟机迁移和高可用部署。 ### 5. 定义并启动虚拟机 创建虚拟机 XML 定义文件,指向共享存储中的磁盘镜像: ```xml <domain type='kvm'> <name>vm1</name> <memory unit='KiB'>2097152</memory> <vcpu placement='static'>2</vcpu> <os> <type arch='x86_64' machine='pc-i440fx-2.9'>hvm</type> <boot dev='hd'/> </os> <devices> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/mnt/ocfs2/vm_images/vm1.img'/> <target dev='vda' bus='virtio'/> </disk> <interface type='network'> <source network='default'/> <model type='virtio'/> </interface> </devices> </domain> ``` 应用并启动虚拟机: ```bash virsh define vm1.xml virsh start vm1 ``` ### 6. 高可用性与迁移 由于 OCFS2 支持多节点并发访问,可以结合 Pacemaker 或其他集群管理工具实现虚拟机的自动故障转移和实时迁移。 ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值