1. Perform RAID operations on disks

  • Boot into the BIOS

  • To configure raid

  • Advanced configuration

  • Select the RAID level and required disks

  • Creating a Virtual Disk

  • Name the virtual drive

  • Confirm the configuration

  • complete

2. Install the OPERATING system

  • Manual installation

  • Select the series and version you want to install and the boot order

  • Restart the installation.

3. Configure and install the basic system environment

1. Configure the yum source yum.cloud.com Edit the yum configuration file vim /etc/yum.repos.d/my.repo

name=CentOS-$releasever - Base
#released updates
name=CentOS-$releasever - Updates
name=CentOS-$releasever - Extras
name=CentOS-$releasever - Plus
Copy the code

2. Configure NTP time synchronization

Install the NTP software package
yum install ntp
# modify config file:
vim /etc/ntp.conf
# first syncThe ntpdate - u the code

3. Install the KVM basic environment

  1. Installing software Packages
yum install -y  qemu-kvm.x86_64 qemu-kvm-tools.x86_64 libvirt bridge-utils avahi virt-install libguestfs-tools
Copy the code
  1. Set the automatic start and stop of related services
service messagebus restart
service libvirtd restart
service avahi-daemon restart
systemctl enable messagebus
systemctl enable libvirtd
systemctl enable avahi-daemon
systemctl stop firewalld
systemctl stop NetworkManager
systemctl disable firewalld
systemctl disable NetworkManager
Copy the code
  1. Configure the bridge device

Example Modify the eth0 vim /etc/sysconfig/network-scripts/ifcfg-eth0 physical NIC

Copy the code

Create a bridge device br0 vim /etc/sysconfig/network-scripts/ifcfg-br0

IPADDR=172.0. 03.
NETMASK=255.255255.. 0
Copy the code

systemctl restart network

4. Perform common operations on KVM VMS

1. Create a VM instance

In the test environment, the IP address of the host (Dawn server) is Assume that the VM installation image is centos-7-x86_64-everything-1804.iso, and that the vm Domain name is centos-7-u5 and the disk size is 100 GB, perform the following operations

# mkdir -p /export/{isos,kvm}
/export/ ├ ─ ─ the isos storage installation CD ISO image └ ─ ─ KVM virtual machine image file storage (virtual machine hard disk file)/etc/libvirt / └ ─ ─ qemu to store the virtual machine configuration fileCopy the code
  • Create a VM image file

Create a 100 GB VM image file named centos-7-u5.img.

qemu-img create -f qcow2 /export/kvm/CentOS-7-u5.img 100G
Copy the code
  • Creating a VM

Create a VM named centos-7-U5 with four Core/Mem 8G/HD 100G, the bridge network is BR0, and the VNC port is 5901.

virt-install -n CentOS-7-u5 \
--os-type=linux --os-variant=rhel7 \
--vcpus 4 -r 8192 \
--disk path=/export/kvm/CentOS-7-u5.img,format=qcow2,size=100 \
--cdrom=/export/ isOS/centos-7-x86_64-everything-1804. Iso \ --network bridge=br0 \ --noautoconsole \ -- VNC --vnclisten= --vncport=5901Copy the code
  • Run VNC Viewer

Enter the host IP address and VNC port number If VNC blinks, adjust the color mode, as shown in the following figure.

2. Clone the VM

The VM centos-7-U5 created in the previous section is used as a template. To copy a vm with the domain name station101.pbC. gov, perform the following steps:

  • cloning
virt-clone    -o CentOS-7-u5 \
-n station101.pbc.gov \
-f /export/kvm/station101.pbc.gov.img
Copy the code
  • Initialization Clears the common information and sets the system host name of the VM
virt-sysprep -d station101.pbc.gov -h station101.pbc.gov
Copy the code

3. Other daily management operations

Note All VM management operations must be performed on the host. Therefore, log in to the host as user root. In the test environment, the IP address of the host (Dawn Server) is, the IP address of the example VM is, and the Domain name is station101.pbC.gov.

Check the vm domain name and status
virsh list --all
# Start the VM
virsh start station101.pbc.gov
# Shut down the VMVirsh shutdown station101.pbc.gov Note: If the shutdown command is supported, ensure that the ACPI service is installed and enabled on the VM.# Forcibly shut down the VM
virsh destroy station101.pbc.gov
Log in to the VM from the console
virsh console station101.pbc.gov
Note: The console command is supported. You must ensure that the vm starts with the kernel parameter console=ttyS0
Exit the console
# use Ctrl-]
# Adjust the number of cpus currently used by the VM (do not reduce the number of cpus during hot add)
virsh setvcpus station101.pbc.gov 8 [--maximum] --current
virsh setvcpus station101.pbc.gov 8 [--maximum] --config
Adjust the actual memory size of the VM (after the VM is shut down)
virsh setmaxmem station101.pbc.gov 16g --config
# Change the size of memory currently used by the virtual machine (this value cannot be greater than maxmem)
virsh setmem station101.pbc.gov 16g --current
virsh setmem station101.pbc.gov 16g --config
Add a virtual NIC
virsh attach-interface station101.pbc.gov --type bridge --source br0 \
[--model virtio] [--config]
# Delete a virtual NIC
virsh detach-interface station101.pbc.gov --type bridge \
--mac <VM_MAC> [--config]
# Add a virtual disk
virsh attach-disk station101.pbc.gov \
--source /export/kvm/station101.pbc.gov.2.img \
--target vdb [--config]
Delete the virtual disk (after shutting down the VM)
virsh detach-disk station101.pbc.gov --target vdb --config
# Add virtual drive
virsh attach-disk station101.pbc.gov \
--source /export/iso/windows.iso \
--target hdc --type=cdrom --mode=readonly [--config]
Check the device name of the disk
virsh domblklist station101.pbc.gov
# Replace the CD-ROM image
virsh change-media --domain station101.pbc.gov \
hdc /export/iso/windows2.iso
Copy the code

Official Reference Manual

Full virtualization suite QEMU

Vm management tool libvirt

Other tools yum’s official site info < Package_Name > | grep URL