KVM virtualization platform deployment (hardware resource allocation and detailed operations, graphic details!)

KVM virtualization platform deployment

Experiment preparation

1. Virtual machine preparation

Related mirrors

Virtual machine hardware resources
Memory: 8G
CPU: dual-core dual-thread-------CPU virtualization turned on
Hard disk: 300G
Operating system: Centos 7.6 (1810)
Network card: NAT (enter system changes)
Insert picture description here
and then select Install CentOS7 to enter the following interface
Insert picture description here

Insert picture description here
Insert picture description here
After clicking Finish, click "Accept Changes", jump back to the installation information summary and click "Start Installation".
Insert picture description here
If the prompt is too simple, you can click twice to complete the root password, and the setting will be successful, and then wait for the virtual machine to slowly install successfully.
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
There is also a direct forward in the middle.
Insert picture description here
Skip and enter this interface. After setting the user name, click forward
Insert picture description here
Insert picture description here
and then you can use CentOS. The entered page is directly closed.
Insert picture description here
Insert picture description here
Enter the user name "root" and its password to log in to CentOS, and then start the following operating

2. Preparation in the system

(1) Modify the host name

Right-click to open the terminal

hostnamectl set-hostname kvm 
su

Insert picture description here

(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) Make 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 security mechanism

systemctl stop firewalld
systemctl disable firewalld
setenforce 0

Insert picture description here

Start experiment

1. Install KVM

(1) Install KVM basic components

Use yum to install it, there are a lot of pictures here, no more pictures.

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
#----------------------命令解释---------------------
# 安装 GNOME 桌面环境  如果装了图形界面可以不需要装
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

Check whether the CPU supports virtualization

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

Insert picture description here
Check whether the KVM module is installed

Lsmod: display the loaded system module

lsmod | grep 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

2. Set up the KVM network

Two modes of KVM network:

  • NAT: The default setting, data packets are transmitted through the host's interface by NAT, which 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. External machines can directly access the inside of the virtual machine, but need network card support (generally wired network cards support)
    use Bridge bridge mode for deployment
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

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.2.200
NETMASK=255.255.255.0
GATEWAY=192.168.2.2

Insert picture description here

systemctl restart network.service

Insert picture description here

3. KVM deployment and management

For other configurations of window sharing files to centos, please refer to my other blog: How to share files on windows to Linux

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

mkdir -p /data_kvm/iso
mkdir -p /data_kvm/store
mount.cifs //192.168.2.1/iso /mnt/

cd /mnt
cp -p CentOS-7-x86_64-DVD-1810-7.6.iso /data_kvm/iso/
ll /data_kvm/iso/

Insert picture description here

4. Use virtual system manager to manage virtual machines

Create ideas:

1) Create storage pool (ISO, STORE)
2) Add storage volume
3) Create virtual machine

virt-manager

Insert picture description here

(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
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
Then the following operation is actually to install centos7 normally, no more details, there may be stuck, because the allocated configuration is not too high
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_35456705/article/details/114867676