kvm virtualization installation and deployment (2)

First, open virtualization VT confirmation

  KVM itself also has some weaknesses, that is, compared to bare metal virtualization architecture of Xen, VMware ESX and HyperV, KVM is running sojourn Virtualized Architecture on top of the Linux kernel, will consume more computing resources; but for this , Intel, AMD has a dedicated VT-x and AMD-V extensions on the processor design, this feature will be updated each time hardware updates, often after each update, all have the virtualization performance and speed significantly improved, so in the long run, is not a big problem.
  KVM virtualization requires hardware support (requires processors support virtualization: as Intel vendors Intel-VT (vmx) technology && AMD vendors AMD-V (svm) technology is based on a fully virtualized hardware and early Xen is but Xen itself has a software-based simulation of paravirtualization (Para-virtualization), the new version is based on hardware support fully virtualized own process scheduler, memory management module, so the code is more substantial. your current CPU is support VT technology? when you are not sure whether the current CPU supports VT technology  1. can be used in windows cpu-z software to test   2. you can view the CPU in Linux believe the information to determine CPU virtualization brings us What are the benefits?  CPU virtualization technology can single-CPU simulation of multi-CPU parallel, allowing a platform to run multiple operating systems and applications and can run independently of each other in the independent space, and thus significantly improve the computer work efficiency virtualization technology Hyper-Threading technology and multi-tasking difference?  virtualization technology and multi-tasking and ultra-line Technology is completely different.
  


  

  
Multitasking refers to an operating system to run multiple programs in parallel, while in virtualization technology, you can run multiple operating systems simultaneously, and each one has its operating system to run multiple programs, each operating system running on a virtual CPU or virtual host; and Hyper-Threading technology CPU only a single CPU simulation run double to balance CPU performance, these two simulated is not isolated, only work before installation kvm preparation  1 determine processors have VT   command line: grep vmx / proc / cpuinfo ( INTEL chip)       grep SVM / proc / cpuinfo (AMD chip)       CAT / proc / cpuinfo | grep -e VMX -e -e NX SVM   does not know the production of chips Manufacturer enter: egrep '(vmx | svm) ' / proc / cpuinfo   If flags: there vmx or svm it shows support VT; if there is no output, indicating that your cpu does not support, will not be able to successfully install KVM virtual machine.   2. When you own the hardware support for virtualization, but the query parameters corresponding to no avail, please check the BIOS settings to make sure your BIOS to open the hardware virtualization support functions!   The following option is set to Enabled   Intel (R) Virtualization Tech [Enabled]
  








Two, KVM virtualization installation

1, mounted KVM requires
(1) 64bitCPU (virtualization-X or the AMD-the VT V)
(2) above 2G free memory, the memory size confirmed
  grep -e MemTotal / proc / meminfo
  Free -m
(. 3) 6GB free storage space
2, detects the installation and KVM
(1) YUM mounted KVM

yum -y install kvm virt-manager libvirt libvirt-python python-virtinst libvirt-client qemu-kvm qemu-img

(2) YUM to install KVM (simple version)

yum install kvm virt-manager libvirt* -y

(3) If you can not connect to the Internet, be able to create the source to complete the installation and avoid various associations. The establishment of a local YUM Source:

<RHEL disc mount> 
# Mount / dev / CDROM / mnt / CDROM
 <establishing a local source YUM> 
#cd / etc / yum .repos.d 
#vim kvms.repo 
kvms.repo the contents 
[KVMS] 
name = Red Hat 
BaseURL = File : /// mnt / CDROM / 
Enabled = . 1 
gpgcheck = 0

(4)kvm虚拟化所需组件介绍
  kvm:核心套件
  virt-manager:图形化 KVM 管理软件
  libvirt:提供虚拟机与宿主相互通信的机制
  libvirt-python:允许使用 libvirt API
  python-virtinst:CLI 下创建 KVM 的工具
  libvirt-client:提供 client 访问 kvm 服务器的机制 ,并包含 virsh 命令进行 管理和控制VMs
  qemu-kvm:提供用户级 KVM 环境
  qemu-img:VMs 磁盘管理
3、启动 KVM
  (1)modprobe kvm    加载 kvm 模块
  (2)lsmod | grep kvm   查看加载成功
  (3)systemctl start libvirtd  启动kvm
  (4)systemctl status libvirtd  查看kvm状态
4、启动并检测 KVM
  virsh list --all

  如出现
  Id Name State
  -------------------------------------------------------
  则安装成功

  virsh list  表示列出已开机的虚拟机
5、在 GUI 模式下安装虚拟机,启动虚拟系统管理器

三、KVM网络模式设置

1、NAT ( 默认上网 ):虚拟机利用 host 机器的 ip 进行上网。对外显示一个 ip;
  virbr0 是 KVM 默认创建的一个 Bridge,其作用是为连接其上的虚机网卡提供 NAT 访问外网的功能,默认ip为192.168.122.1


2、自带的Bridge:将虚拟机桥接到 host 机器的网卡上 ,vm和 host 机器都通过 bridge 上网 . 对外有同网段的不通 ip,此种方式host却不能和vm联通
3、Linux Bridge:基本原理就是创建一个桥接接口 br0 ,在物理网卡和虚拟网络接口之间传递数据。此种方式host也可以和vm连通


  Linux Bridge 是 Linux 上用来做 TCP/IP 二层协议交换的设备,其功能大家可以简单的理解为是一个二层交换机或者 Hub。多个网络设备可以连接到同一个 Linux Bridge,当某个设备收到数据包时,Linux Bridge 会将数据转发给其他设备
(1)添加 br0 网卡的配置文件

cd /etc/sysconfig/network-scripts
cp ifcfg-ens33 ifcfg-br0

(2)修改网卡配置文件

vim ifcfg-ens33
TYPE=Ethernet
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE=br0
vim ifcfg-br0
TYPE=Bridge
NAME=br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.11.12
PREFIX=24(NETMASK=255.255.255.0)
GATEWAY=192.168.11.2
DNS=192.168.11.2

(3)重启host:reboot
(4)检查
  # ethtool br0
  # brctl show
  # ifconfig br0

  #lsblk 命令用来查看block设备的信息

四、virt-manager创建虚拟机

(1)首先通过命令 virt-manager 启动图形界面:
  点下面的图标创建虚机

(2)给虚机命名为 kvm1,这里选择从哪里启动虚机。如果是安装新的 OS,可以选择第一项。如果已经有安装好的镜像文件,选最后一项(如下图)。


(3)接下来需要告诉 virt-manager 镜像的位置,点击 “Browser”


(4)需要在系统中上传一个镜像文件到属主机上,放到 /var/lib/libvirt/images/ 目录下,这是 KVM 默认查找镜像文件的地方。


(5)为虚拟机分配 CPU、内存和磁盘


(6)为虚拟机命名,并在安装前配置硬件参数,点击“Finish”。网络选择三节课创建的br0网桥,点击绿色“对勾”开始安装

(7)控制台弹出如下图,安装linux安装步骤安装即可:


virt-manager 可以对虚机进行各种管理操作,界面直观友好,很容易上手。 同时我们也可以用命令 virsh 管理虚机,比如查看宿主机上的虚机:

 

Guess you like

Origin www.cnblogs.com/renyz/p/11609479.html