Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure KVM Virtualization platform

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Preface

The abbreviation of Kernel-based Virtual Machine is an open source system virtualization module that has been integrated in major releases of Linux since Linux 2.6.20. It is managed by Linux's own scheduler, so its core source code is relatively small compared to Xen. KVM has become one of the mainstream VMM in academic circles.

KVM virtualization requires hardware support (such as Intel VT technology or AMD V technology). Is full virtualization based on hardware. In the early days, Xen was based on software simulation of Para-Virtualization, while the new version was based on full virtualization supported by hardware. But Xen itself has its own process scheduler, storage management module and so on, so the code is relatively large. The widely spread business system virtualization software VMware ESX series is based on software simulation of Full-Virtualization. KVM Virtualization Architecture

The KVM module is directly integrated into the Linux kernel

KVM component KVM Driver virtual machine create virtual machine memory allocation virtual machine CPU register read-write virtual CPU run QEMU (simplified and modified) user control components that simulate PC hardware provide three modes of KVM virtualization: virtual machine user settings: set kernel mode: KVM Driver kernel mode

How KVM works

Experimental operation 1. Before booting the virtual machine, add a hard disk to the virtual machine, format the hard disk, and mount it to the / data/ directory

Enable virtualization of virtual machines

[root@localhost] # fdisk-l disk / dev/sdb:107.4 GB, 107374182400 bytes, 209715200 sector Units = sector of 1 * 512 = 512bytes sector size (logical / physical): 512byte / 512byte I size O (minimum / optimal): 512byte / 512byte disk / dev/sda:42.9 GB, 42949672960 bytes 83886080 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte bytes size (min / best): 512byte / 512byte disk label type: dos disk identifier: 0x000be35b device Boot Start End Blocks Id System/dev/sda1 * 2048 12584959 6291456 83 Linux/dev/sda2 12584960 5452799920971520 83 Linux/dev/sda3 54528000 62916607 4194304 82 Linux swap / Solaris/dev/sda4 62916608 83886079 10484736 5 Extended/dev/sda5 62918656 83886079 10483712 83 Linux [root@localhost] # fdisk / dev/sdb Welcome to fdisk (util-linux 2.23.2). The changes remain in memory until you decide to write them to disk. Think twice before using the write command. Device does not contain a recognized partition table uses the disk identifier 0xc2432934 to create a new DOS disk label. Command (enter m for help): nPartition type: P primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): P partition number (1-4, default 1): start sector (2048-209715199, default is 2048): the default value 2048Last sector will be used, + sector or + size {K Magne G} (2048-209715199, default is 209715199): partition 1 will be set to Linux type 209715199 Set the size to 100 GiB command (enter m for help): wThe partition table has been altered calling ioctl () to re-read partition table. Synchronizing disks. [root@localhost ~] # [root@localhost ~] # mkfs / dev/sdb1mke2fs 1.42.9 (28-Dec-2013) File system tag = OS type: Linux Block size = 4096 (log=2) Block size = 4096 (log=2) Stride=0 blocks, Stripe width=0 blocks6553600 inodes, 26214144 blocks1310707 blocks (5.00%) reserved for the super user first data block = 0Maximum filesystem blocks=4294967296800 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768,98304,163840,229376,294912,819200,884736,16056322654208 4096000, 7962624, 11239424, 20480000 23887872Allocating group tables: finish writing inode table: complete Writing superblocks and filesystem accounting information: complete [root@localhost ~] # mkdir / data [root@localhost ~] # mount / dev/sdb1 / data/ [root@localhost ~] # df-hT file system type capacity available available mount% Point / dev/sda2 xfs 20G 3.3G 17G 17% / devtmpfs devtmpfs 1.9G 0 1.9G 0 / devtmpfs tmpfs 1.9G 0 1.9G 0 / dev/shmtmpfs tmpfs 1.9G 9.0M 1.9G 1% / runtmpfs tmpfs 1.9G 0 1.9G 0 / sys/fs/cgroup/dev/sda5 Xfs 10G 37M 10G 1% / home/dev/sda1 xfs 6.0G 174M 5.9G 3% / boottmpfs tmpfs 378M 12K 378M 1% / run/user/42tmpfs tmpfs 378M 0378M 0% / run/user/0/dev/sdb1 ext2 99G 60M 94G 1% / data [root@localhost ~] # 2, Share the required image on the host And mount it to the virtual machine

[root@localhost ~] # mount.cifs / / 192.168.100.100/tools / mnt/Password for root@//192.168.100.100/tools: [root@localhost ~] # 3, Configure KVM must be environment package [root@localhost ~] # yum groupinstall "GNOME Desktop"-y # # install desktop environment [root@localhost ~] # yum install qemu-kvm- y # # KVM module [root@localhost ~] # yum install qemu-kvm-tools-y # # KVM debugging tool [root@localhost ~] # yum install virt-install-y # # command line tool for building virtual machines [root@localhost ~] # yum install qemu-img-y # # qemu components Create a disk, start the virtual machine [root@localhost ~] # yum install bridge-utils-y # # Network support tool [root@localhost ~] # yum install libvirt-y # # Virtual Machine Management tool [root@localhost ~] # yum install virt-manager-y # # Image manage virtual machine 4, and determine whether cpu supports virtualization. And check the virtual machine module [root@localhost ~] # lsmod | grep kvmkvm_intel 170086 0 kvm 566340 1 kvm_intelirqbypass 13503 1 kvm [root@localhost ~] # cat / proc/cpuinfo | grep svm # # AMD server available cat / proc/cpuinfo | grep vmx # # inter server available egrep'(vmx | svm)'/ proc/cpuinfo # # both are available 5. Enable the service And set the boot self-boot # boot service [root@localhost ~] # systemctl start libvirtd# boot self-boot [root@localhost ~] # systemctl enable libvirtd6, and set the required image Move the mounted software package to the / data/ directory [root@localhost ~] # cd / data/# to create two files [root@localhost data] # mkdir vdisk viso# copy and call to the background to run [root@localhost data] # cp-r / mnt/CentOS-7-x86_64-DVD-1708.iso / data/viso & [1] 29318 [root@localhost data] # [1] + complete cp-I-r / mnt / CentOS-7-x86_64-DVD-1708.iso / data/viso [root@localhost data] # ls viso/CentOS-7-x86_64-DVD-1708.iso [root@localhost data] # 7 、 Configure the bridge network card of the virtual machine # enter the network card file [root@localhost data] # cd / etc/sysconfig/network-scripts/# copy to create the br0 network card [root@localhost network-scripts] # cp-p ifcfg-ens33 ifcfg-br0# enter the ens33 network card Set bridging Command [root@localhost network-scripts] # vim ifcfg-ens33## Last Line add # bridging Command BRIDGE=br0# configure bridging Network Card Set the bridge network card to a static address [root@localhost network-scripts] # vim ifcfg-br0 TYPE=bridgePROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=staticDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=br0DEVICE=br0ONBOOT=yesIPADDR=192.168.52.134NETMASK=255.255.255.0GATEWAY=192.168.52.1 [root@localhost network-scripts] # systemctl restart network # # restart the network card [root@localhost network-scripts] # ifconfig # # View the network card information br0: flags=4163 mtu 1500 inet 192.168 . netmask 255.255.255.0 broadcast 192.168.52.255 inet6 fe80::69d9:68eb:e59e:c66f prefixlen 64 scopeid 0x20 ether 00:0c:29:eb:34:07 txqueuelen 1000 (Ethernet) RX packets 14 bytes 1274 (52.134 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 29 bytes 4473 (4.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33: flags=4163 mtu 1500 Ether 00:0c:29:eb:34:07 txqueuelen 1000 (Ethernet) RX packets 3356082 bytes 4925169168 (4.5 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 227829 bytes 18565675 (17.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 08, Enter the graphical management interface [root@localhost ~] # virt-manager

Select Storage, click Select to enter the storage control interface

Select create a new storage pool and enter a name

Then select forward, and then on the page that pops up inside, click Browse. Enter the following interface

Go to the vdisk folder under the data directory, and then select and click Open.

Click finish after exiting the interface to complete the creation of the new storage pool

Select add new volume on data, click enter and enter the name, and enter the interval size to be allocated on the storage volume quota below

In the same steps as above, create an iso storage pool, select the / image in viso/ in / data/ here, and then click Open

Then click finish to complete the addition of the address pool, view the created storage pool, and click close in the file.

Click on the file and select to generate a new virtual host

Proceed with the above selection, and then, when selecting the system image to install, select the image in iso

Mirror selection completed, click forward

The size of the allocated memory, generally according to the size of your actual memory.

Choose to create custom storage and select the Centos7 file you just created in vdisk

Click Select, customize the configuration before installation, and then click finish

In the boot option, start the virtual machine when you select the host to boot

Click to start the installation, which will be the same as the steps we used to install CentOS.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report