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

The case of Building KVM Virtualization platform in CentOS 7

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Xiaobian to share with you the case of building KVM virtualization platform in CentOS 7, I believe most people still do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

What is virtualization?

Virtualization is a technology that transforms hardware resources from physical to logical, breaks the original physical structure, enables users to flexibly manage these resources, and allows multiple operating systems to run simultaneously on a physical machine to maximize resource utilization and flexible management.

the benefits of virtualization

Reduce the number of servers and reduce hardware acquisition costs.

Maximize resource utilization

Reduce the cost of room space, heat dissipation and electricity consumption.

Hardware resources can be dynamically adjusted to improve enterprise IT business flexibility.

High availability.

Physical hardware adjustments without interruption of service.

Reduce administrative costs.

More efficient disaster preparedness.

KVM virtualization

KVM has been integrated directly into the Linux kernel since linux version 2.6.20 and relies on CPU virtualization instruction sets (such as Intel-VT and AMD-V) to achieve high-performance virtualization support. Due to its high degree of integration with the linux kernel, it has a good performance in performance, security, compatibility and stability.

Building KVM virtualization platform in CentOS 7

1. Environmental preparation

Enable CPU virtualization to add a disk for files generated by KVM virtual machines

cat /proc/cpuinfo |grep vmx //Intel Server Check CPU support for virtualization cat /proc/cpuinfo| grep smv //AMD server view with this command

lsmod |grep kvm //Check if KVM module is installed

2. Create disk partitions, format and mount disks

fdisk /dev/sdb //Use fdisk command to create primary partition mkfs -t xfs /dev/sdb1 //format disk mkdir /vdir //create folder mount disk mount /dev/sdb1 /vdir//mount formatted disk to folder df -h //View mount

3. Install the software required for KVM

yum install -y qemu-kvm qemu-kvm-tools virt-manager virt-install libvirt

Note:

qemu-kvm: virtualization software, virtual network and hard disk user mode

libvirt: Unified interface for virtualization tools (libvirt API, libvirt daemon, user-mode tools)

virsh, virt-manager, virt-viewer, virt-install, other-tools are user-mode tools of libvirt

4 Creating Virtual Machines with KVM

1. Use qemu-img command to create hard disk

qemu-img create -f raw /vdir/c1.raw 20G //Create a 20G hard drive named c1.raw

2. Use virt-install to create a virtual machine named c1 (custom), after placing the image of centos7 in the virtual machine.

virt-install --name c1 \ //VM name--virt-type kvm \ //Type--ram 2048 \ //Memory Size--cdrom=/opt/CentOS-7-x86_64-DVD-1708.iso \ //Mirror Path--disk path=/vdir/c1.raw \ //Disk Path--network network=default \ //Default NIC--graphics vnc,listen=0.0.0.0 \ //Start installation using VNC Connection--noautoconsole... Domain installation is still in progress. You can reconnect to the console to complete the installation process.

3. Turn off firewall and security features, and use TightVNC Viewer tool to connect to host 192.168.10.128

systemctl stop firewall d.servicesetenforce 0 //Turn off firewall and security features

Connect to a server using TightVNC Viewer

The installation steps are the same as the usual method of installing the operating system. After the installation is completed, restart, TightVNC Viewer will be broken. In linux, you can see that the state of virtual machine c1 is closed.

virsh list --all

start the virtual machine

virsh start c1

Then connect with TightVNC Viewer, you can log in with account password

The above is all the content of this article "Building KVM virtualization platform in CentOS 7", thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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