Deployment of KVM virtualization platform

1. KVM virtualization architecture

1. Composition of KVM

KVM Driver

虚拟机创建
虚拟机内存分配
虚拟机CPU寄存器读写
虚拟CPU运行

QEMU (simplified and modified)

模拟PC硬件的用户控件组件
提供I/O设备模型及访问外设的途径

Three modes of KVM virtualization

客户模式: 虚拟机
用户设置: 设置
内核模式: KVM Driver 内核态

Insert picture description here

2. How KVM works

Insert picture description here

3. Case environment

使用一台物理机器,安装CentOS7.4的64位系统(即bdqn),test01是在宿主机上安装的虚拟机
主机	     操作系统                       	IP地址	                        主要软件
bdqn	CentOS7.4 x86_64  	192.168.45.129   	Xshell、Xmanager
test01	CentOS7.4 x86_64	    192.168.45.140	    Xshell、Xmanager

4. Case requirements

安装KVM
安装Linux虚拟机
使用KVM命令集管理虚拟机

5.KVM file management

查看当前磁盘格式
virt-cat命令
vrit-edit命令
virt-df命令

2. Build

虚拟机需求为内存最小为4G

1. Before starting the virtual machine, add a hard disk to the virtual machine, format the hard disk, and mount it under the /data/ directory
Insert picture description here
2. Mount the system image package we need to install to the virtual machine

#挂载软件包
mount.cifs //192.168.100.3/lzp /mnt

3. The environment package must be configured for KVM

#安装桌面环境
yum groupinstall "GNOME Desktop" -y

#KVM模块
yum install qemu-kvm -y

# 调试工具
yum install qemu-kvm-tools -y

#构建虚拟主机的命令工具
yum install virt-install -y

#qemu组件,创建磁盘,启动虚拟机
yum install qemu-img -y

#网络支持工具
yum install -y bridge-utils

#虚拟机管理工具
 yum install libvirt -y
 
#图形化管理虚拟机
yum install virt-manager -y

4. Determine whether the cpu supports virtualization. And view the virtual machine module

egrep '(vmx|svm)' /proc/cpuinfo

#查看,模块
lsmod | grep kvm

5. Turn on the service and set it to start automatically after booting

#开启服务
systemctl start libvirtd
#开机自启动
systemctl enable libvirtd

6. Move the software package, move the mounted software package to the /data/ directory

 cd /data/
#创建两个文件
mkdir vdisk viso
#复制并调到后台运行
cp -r /mnt/CentOS-7-x86_64-DVD-1708.iso /data/viso &

7. Configure the bridged network card of the virtual machine

#进入网卡文件
cd /etc/sysconfig/network-scripts/
#复制创建br0网卡
cp -p ifcfg-ens33 ifcfg-br0
#进入ens33网卡,设置桥接命令
vim ifcfg-ens33
#桥接命令
BRIDGE=br0

#配置桥接网卡,将桥接网卡设置为静态的地址
vim ifcfg-br0
TYPE=bridge
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.45.140
NETMASK=255.255.255.0
GATEWAY=192.168.45.2

#重启网卡
service network restart 

8. View the network card information
Insert picture description here
9. Enter the graphical management interface
Insert picture description here
10. Select storage, click select, enter the storage control interface
Insert picture description here
11. Select to create a new storage pool, and then enter the name
Insert picture description here
12. Then select forward, and then the page that pops up inside, Click Browse. Enter the following interface and click, the icon
Insert picture description here
13. Enter and select the vdisk folder under the data directory, and then click to open
Insert picture description here
14. After exiting the interface, click Finish to complete the creation of a new storage pool
. Select Add a new volume on dis, and click Enter Then enter the name, and enter the interval size to be allocated in the storage volume quota below

Insert picture description here
15. View the Centos7 volume created in dis
Insert picture description here
16. Follow the same steps as above to create an iso storage pool
Insert picture description here
17. Choose /data/ here z in the viso//mirror, and then click to open Insert picture description here
18. Then click Finish to complete the addition of the address pool, view the created storage pool, after creation, click exit in the
Insert picture description here
file 19. Click file, select generate New virtual host
Insert picture description here

20. In the above selection, afterwards, when selecting the system image to be installed, select the image in the iso
Insert picture description here

21. Mirror selection is complete, click forward
Insert picture description here

22. The size of the allocated memory is generally allocated according to the size of your actual memory
Insert picture description here

23. Choose to create a custom storage, choose the Centos7 file created in the vdisk you just created.
Insert picture description here
Insert picture description here
Insert picture description here
24. In the boot options, choose to start the virtual machine when the host boots.
Insert picture description here
Insert picture description here
25. Then the automatic installation starts, which can be viewed on the virtual machine manager To virtual usage
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45647891/article/details/112852556