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

172.0.0.2 yum.cloud.com Edit the yum configuration file vim /etc/yum.repos.d/my.repo

[base]
name=CentOS-$releasever - Base
baseurl=https://yum.cloud.com/centos/7/os/$basearch/
gpgcheck=0
enabled=1
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://yum.cloud.com/centos/7/updates/$basearch/
gpgcheck=0
enabled=1
[extras]
name=CentOS-$releasever - Extras
baseurl=https://yum.cloud.com/centos/7/extras//$basearch/
gpgcheck=0
enabled=1
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://yum.cloud.com/centos/7/centosplus//$basearch/
gpgcheck=0
enabled=1
[centos7_virt_kvm-common]
name=centos7_virt_kvm-common
baseurl=https://yum.cloud.com/centos/7/virt/x86_64/kvm-common
gpgcheck=0
enabled=1
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 172.0.0.2Copy 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

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
BRIDGE=br0
Copy the code

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

DEVICE=br0
BOOTPROTO=none
ONBOOT=yes
TYPE=Bridge
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 172.0.0.3. 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=0.0.0.0 --vncport=5901Copy the code
  • Run VNC Viewer

Enter the host IP address and VNC port number 172.0.0.3:5901. 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 172.0.0.3, the IP address of the example VM is 11.4.243.101, 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