• 欢迎访问速搜资源吧,如果在网站上找不到你需要的资源,可以在留言板上留言,管理员会尽量满足你!

【速搜问答】KVM虚拟机是什么

问答 admin 2年前 (2020-08-24) 434次浏览 已收录 0个评论

汉英对照:
Chinese-English Translation:

KVM虚拟机是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,所以相对于Xen,其核心源码很少。KVM已成为学术界的主流VMM之一。

KVM virtual machine is an open source system virtualization module, which has been integrated into various major Linux distributions since Linux 2.6.20. It uses Linux’s own scheduler for management, so its core source code is very few compared with Xen. KVM has become one of the mainstream VMS in academia.

KVM 虚拟机(Kernel-based Virtual Machine)是一个开源的系统虚拟化模块,自 Linux 2.6.20 之后集成在 Linux 的各个主要发行版本中。它使用 Linux 自身的调度器进行管理,所以相对于 Xen,其核心源码很少。KVM 已成为学术界的主流 VMM 之一。

KVM (kernel based virtual machine) is an open source system virtualization module, which has been integrated into various major distributions of Linux since Linux 2.6.20. It uses Linux’s own scheduler for management, so its core source code is very few compared with Xen. KVM has become one of the mainstream VMS in academia.

KVM 的虚拟化需要硬件支持(如 Intel VT 技术或者 AMD V 技术)。是基于硬件的完全虚拟化。而 Xen 早期则是基于软件模拟的 Para-Virtualization,新版本则是基于硬件支持的完全虚拟化。但 Xen 本身有自己的进程调度器,存储管理模块等,所以代码较为庞大。广为流传的商业系统虚拟化软件 VMware ESX 系列是基于软件模拟的 Full-Virtualization。

KVM virtualization requires hardware support (such as Intel VT technology or AMD V Technology). It’s hardware based full virtualization. The early Xen is based on software simulation of para virtualization, the new version is based on hardware support of full virtualization. But Xen itself has its own process scheduler, storage management module, so the code is relatively large. The widely circulated commercial system virtualization software, VMware, is full virtualization based on software simulation.

安装方法

Installation method

一、安装准备

1、 Installation preparation

1.确定机器有 VT

1. Make sure the machine has vt

终端输入命令: grep vmx /proc/cpuinfo (INTEL 芯片)

Terminal input command: grep VMX / proc / cpuinfo (Intel chip)

grep svm /proc/cpuinfo (AMD 芯片)

Grep SVM / proc / cpuinfo (AMD chip)

不知道芯片的生产厂商则输入:egrep ‘(vmx|svm)’ /proc/cpuinfo

If you don’t know the manufacturer of the chip, input: egrep ‘(vmx|svm)’ / proc / cpuinfo

如果 flags: 里有 vmx 或者 svm 就说明支持 VT;如果没有任何的输出,说明你的 cpu 不支持,将无法成功安装 KVM 虚拟机。

If there is VMX or SVM in flags: it indicates that VT is supported; if there is no output, it means that your CPU does not support it, and KVM virtual machine cannot be successfully installed.

2. 确保 BIOS 里开启 VT

2. Make sure VT is turned on in BIOS

Intel(R) Virtualization Tech [Enabled]

Intel(R) Virtualization Tech [Enabled]

如有必要,还需在 BIOS 中开启 VT-d

If necessary, open vt-d in BIOS

3. 确保内核版本较新,支持 KVM

3. Ensure that the kernel version is newer and support KVM

用 uname -r 查看内核版本,如果在 2.6.20 以下的 linux 版本,需升级内核。

Use uname – r to check the kernel version. If the kernel version is lower than 2.6.20, you need to upgrade the kernel.

二、安装 KVM

2、 Install KVM

下面就 Ubuntu 和 CentOS 下安装使用 KVM 虚拟机做介绍:

The following describes the installation and use of KVM virtual machine under Ubuntu and CentOS:

Ubuntu 中用 guest 登陆,安装 KVM 的命令为:

Login with guest in Ubuntu. The command to install KVM is as follows:

sudo apt-get install kvm qemu qemu-kvm virt-manager kernel-package linux-source kqemu-source build-essential

sudo apt-get install kvm qemu qemu-kvm virt-manager kernel-package linux-source kqemu-source build-essential

kvm 安装成功后会有/dev/kvm,如果无需图形管理器,只需要安装前三个即可。

There will be / dev / KVM after successful installation of KVM. If you don’t need a graphics manager, you only need to install the first three.

再来查看下 KVM 是否安装成功,执行:virsh -c qemu:///system list

Then check whether KVM is successfully installed and execute: virsh – C QEMU: / / / system list

如果输入结果像下面这样的,那么成功了:

If the input result is like this, then it is successful:

Connecting to uri: qemu:///system

Connecting to uri: qemu:///system

Id Name State

Id Name State

———————————-

———————————-

注 1:CentOS 中安装时,先要选择 Selinux 为 enable,使用命令

Note 1: when installing in CentOS, first select SELinux as enable and use the command

#system-config-securitylevel-tui

#system-config-securitylevel-tui

可查看或修改 selinux 的状态。

You can view or modify the status of SELinux.

注 2: CentOS 中用 root 登陆时则安装命令为:

Note 2: when logging in as root in CentOS, the installation command is as follows:

yum install kvm kmod-kvm qemu

yum install kvm kmod-kvm qemu

再装入 kvm 模块:modprobe kvm-intel (Intel 机器) 或者 modprobe kvm-amd (amd 机器)

Then load the KVM module: modprobe KVM Intel (Intel machine) or modprobe KVM amd (AMD machine)

注 3:可以用以下命令来检查是否装入 kvm 模块:

Note 3: you can check whether the KVM module is loaded with the following command:

/sbin/lsmod | grep kvm

/sbin/lsmod | grep kvm

如果输出关于 kvm 版本的信息则已装入 kvm 模块

If you output information about the KVM version, the KVM module is loaded

注 4: 安装好后,可使用 qemu-kvm 命令,输入该命令,如果系统显示未知的命令,可查看/usr/libexec 中是否有 qemu-kvm 可执行文件,如果有,将其拷贝到/bin 目录下即可。如果确实按照上面的步骤进行了,却在/bin,/usr/libexec,/usr/bin,/usr/sbin 里都找不到 qemu-kvm 可执行文件,可执行以下命令:

Note 4: after installation, you can use the QEMU KVM command and enter the command. If the system displays an unknown command, you can check whether there is QEMU KVM executable in / usr / libexec. If so, copy it to the / bin directory. If the QEMU KVM executable is not found in / bin, / usr / libexec, / usr / bin and / usr / SBIN, you can execute the following command:

#yum provides “*/qemu-kvm”

#yum provides “*/qemu-kvm”

注 5:安装新内核后,可能有部分软件版本过低,不兼容。比如 firefox 因版本过低,无法启动。

Note 5: after installing the new kernel, some software versions may be too low and incompatible. For example, the version of firebox is too low to start.

CentOS 下可使用如下命令更新该软件(以 firefox 为例):

Under CentOS, the following commands can be used to update the software (taking firebox as an example)

#yum update firefox

#yum update firefox

三、在 KVM 下安装虚拟机

3、 Installing virtual machine under KVM

1.用 QEMU 创建磁盘镜像

1. Create disk image with QEMU

sudo qemu-img create –f qcow windows.img 8G

sudo qemu-img create –f qcow windows.img 8G

注:在 CentOS 和新版 Qemu 中为:qemu-img create –f qcow2 windows.img 8G

Note: QEMU img create – f qcow2 in CentOS and new QEMU windows.img 8G

2.使用 KVM 安装 Guest VM

2. Use KVM to install guest VM

光盘安装:

CD installation:

sudo kvm –localtime –cdrom /dev/cdrom -m 512 -boot d win2.img

sudo kvm –localtime –cdrom /dev/cdrom -m 512 -boot d win2.img

硬盘安装:

Hard disk installation:

sudo kvm –localtime –m 512 –hda windows.img –cdrom winxp.iso –boot d –clock –rtc –no-acpi

sudo kvm –localtime –m 512 –hda windows.img –cdrom winxp.iso –boot d –clock –rtc –no-acpi

注:官方推荐使用 -no-acpi 参数,原因是 qemu/kvm 不太支持,可能造成 cpu 的占用偏高。

Note: it is officially recommended to use the – no ACPI parameter because QEMU / KVM is not supported, which may cause high CPU consumption.

注 1:CentOS 下硬盘安装为 qemu-kvm –localtime –m 512 –hda windows.img –cdrom winxp.iso –boot d –no-acpi 即需要去掉了-clock rtc 选项,否则会出现无法初始化时钟。

Note 1: the hard disk under CentOS is QEMU KVM – Localtime – m 512 – HDA windows.img –cdrom winxp.iso – boot D – no ACPI needs to remove the – Clock RTC option, otherwise the clock cannot be initialized.

注 2:CentOS quest mouse: export SDL_VIDEO_X11_DGAMOUSE=0 可解决 VM 中无法识别 USB 鼠标的问题。

Note 2: CentOS quest mouse: export SDL_ VIDEO_ X11_ Dgamouse = 0 can solve the problem that USB mouse cannot be recognized in VM.

注 3: 安装 win 7 时,不能使用-no-acpi 选项。

Note 3: the – no ACPI option cannot be used when installing win 7.

使用

use

KVM 启动 Guest

KVM starts guest

① sudo kvm –boot c –m 512

① sudo kvm –boot c –m 512

–hda windows.img

–hda windows.img

② sudo kvm -boot c

② sudo kvm -boot c

-m 512

-m 512

-hda /home/lm/kvm/winxp.img

-hda /home/lm/kvm/ winxp.img

-localtime

-localtime

-net nic,vlan=0,macaddr=52-54-00-12-34-01 -net tap,vlan=0,df=h,ifname=tap0,script=no

-net nic,vlan=0,macaddr=52-54-00-12-34-01 -net tap,vlan=0,df=h,ifname=tap0,script=no

-clock rtc

-clock rtc

-soundhw es1370

-soundhw es1370

-smp 2

-smp 2

注意:在 KVM-87 下,请去掉 df=h

Note: under kvm-87, please remove DF = H

-m 512 分配 512MB 的内存

-M 512 allocates 512MB of memory

-hda /home/lm/kvm/winxp.img

-hda /home/lm/kvm/ winxp.img

-localtime 使用本地时间(一定要加这个参数,不然虚拟机时间会有问题)

-Local time uses local time (this parameter must be added, otherwise there will be problems with the virtual machine time)

-net nic,vlan=0,macaddr=52-54-00-12-34-01 -net tap,vlan=0,df=h,ifname=tapo,script=no

-net nic,vlan=0,macaddr=52-54-00-12-34-01 -net tap,vlan=0,df=h,ifname=tapo,script=no

使用网络,并连接到一个存在的网络设备 tap0,注意 mac 地址一定要自己编一个,特别是如果你虚拟了多个系统并且要同时运行的话,不然就 MAC 冲突了,在 KVM-87 下去掉 df=h

Use the network and connect to an existing network device tap0. Note that the MAC address must be programmed by yourself, especially if you have virtualized multiple systems and want to run at the same time, otherwise there will be MAC conflict. Remove DF = h under kvm-87

-boot d 从光盘启动 (从镜像启动也是用这个。从硬盘启动则为 -boot c )

-Boot D boot from CD (this is also used to boot from image). – boot C when booting from hard disk)

-smp 2 smp 处理器个数为 2 个,如果你是 4 核处理器,后面的数字就为 4

-The number of SMP 2 SMP processors is 2. If you are a 4-core processor, the following number is 4

-clock rtc

-clock rtc

使用 rtc 时钟(如果不开启此选项,WINXP 可能会很慢)

Use RTC clock (WinXP may be slow if this option is not turned on)


速搜资源网 , 版权所有丨如未注明 , 均为原创丨转载请注明原文链接:【速搜问答】KVM虚拟机是什么
喜欢 (0)
[361009623@qq.com]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址