KVM virtualization platform deployment (detailed graphic explanation)! !

Experiment preparation

KVM virtualization platform deployment steps

One, virtual machine resources

CPU: Dual-core dual-thread-CPU virtualization enabled
Memory: 8G
Hard disk: 300G
Network card: Single network card
Operating system: Centos 7.6 (1810)

Mirror address

Note: At this time, you need to reinstall a new virtual machine.

Insert picture description here

2. Experimental environment

Preparations in the system

1. Modify the host name

hostnamectl set-hostname kvm 
su

2. Set the mirrored disc to auto/permanently mount

vim /etc/fstab
/dev/cdrom /mnt iso9660 defaults 0 0

mount -a 
df -hT

Insert picture description here

Insert picture description here
3. Environmental optimization

Set DNS reverse resolution
Whether to reverse DNS resolution , set to NO can make the client connect to the server faster

vim /etc/ssh/sshd_config
#115行;取消DNS注释,改为NO
UseDNS no

Insert picture description here
4. Set up a local YUM warehouse

cd /etc/yum.repos.d/
mkdir repos.bak
mv CentOS-* repos.bak

vim kvm.repo
[kvm]
name=kvm
baseurl=file:///mnt
gpgcheck=0
enabled=1


yum clean all  && yum repolist

Insert picture description here
5. Turn off the firewall and core protection

[root@kvm yum.repos.d]# systemctl stop firewalld
[root@kvm yum.repos.d]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@kvm yum.repos.d]# setenforce 0

Insert picture description here

Three, install KVM

(1) Install KVM basic components

#安装 GNOME 桌面环境 如果 Centos 装了图形界面可以不需要装
yum groupinstall -y "GNOME Desktop"
#KVM 模块
yum -y install qemu-kvm
#安装KVM 调试工具,可不安装
yum -y install qemu-kvm-tools
#构建虚拟机的命令行工具
yum -y install virt-install
#qemu 组件,创建磁盘、启动虚拟机等
yum -y install qemu-img
#网络支持工具
yum -y install bridge-utils
#虚拟机管理工具
yum -y install libvirt
#图形界面管理虚拟机
yum -y install virt-manager
#以下是上面安装的内容的汇总
yum groupinstall -y "GNOME Desktop"
yum -y install qemu-kvm
yum -y install qemu-kvm-tools
yum -y install virt-install
yum -y install qemu-img
yum -y install bridge-utils
yum -y install libvirt
yum -y install virt-manager

Check whether the CPU supports virtualization

cat /proc/cpuinfo | grep vmx
# 查看CPU是否支持虚拟化

Insert picture description here
#Check whether the KVM module is installed

Lsmod:显示已载入的系统模块

[root@kvm yum.repos.d]#lsmod | grep kvm
kvm_intel             183621  0 
kvm                   586948  1 kvm_intel
irqbypass              13503  1 kvm

Insert picture description here

(2) Set the display mode of the startup interface

ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

Insert picture description here

Fourth, set up the KVM network

Two modes of KVM network

NAT: The default setting, the data packet is transmitted through the host interface by NAT, can access the external network, but cannot access the virtual machine network from the outside
Bridge: This mode allows the virtual machine to have a network like an independent host. The external machine can directly access the inside of the virtual machine, but it needs network card support (generally wired network card supports)

Deploy using Bridge mode

vim /etc/sysconfig/network-scripts/ifcfg-ens33

BOOTPROTO=none
IPV6INIT=no
ONBOOT=yes
BRIDGE=br0			#删除原先地址,设置为网桥模式,关联br0网卡

Insert picture description here
Create and edit bridged network cards

[root@kvm yum.repos.d]#vim /etc/sysconfig/network-scripts/ifcfg-br0

TYPE=Bridge
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.182.77
NETMASK=255.255.255.0
GATEWAY=192.168.182.2

Insert picture description here

systemctl restart network   #重启网卡

Insert picture description here

Five, KVM deployment and management

Create a directory for KVM storage and mirroring data, upload a centos7 mirror

 mkdir -p  /data/data_kvm/iso

 mkdir -p /data/data/_kvm/store

Insert picture description here

Note: I use the windows shared directory for linux here, and use the mirror file in windows directly

mount.cifs //192.168.182.1/AOLIGEI /data
cd /data

cp -p CentOS-7-x86_64-DVD-1708.iso /data_kvm/iso &  
ll /data_kvm/iso/

This is the location of my windows image file
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here

Six, use the virtual system manager to manage virtual machines

Create ideas:

  • Create storage pool (ISO, STORE)
  • Add storage volume
  • Create a virtual machine
virt-manager

![Bold style

(1) Create a storage pool

Insert picture description here
Insert picture description here

(2) Create a storage volume

Insert picture description here
Insert picture description here

(3) Create a virtual machine

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
The subsequent operation is actually to install centos7 normally, so I won’t go into details, it may be stuck because the allocated configuration is not too high.

Insert picture description here

Guess you like

Origin blog.csdn.net/panrenjun/article/details/114874873