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 deploy kvm Virtualization Technology on Centos6.5

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

Share

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

This article introduces the knowledge of "how to deploy kvm virtualization technology on Centos6.5". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is KVM?

The full name of KVM is kernel-based virtual machine (Kernel-based Virtual Machine), which is a kernel module of a Linux that turns Linux into a Hypervisor:

It was developed by Quramnet, which was acquired by Red Hat in 2008. It supports x86 (32 and 64-bit), s390, Powerpc and other CPU. It has been included as a module in the Linux kernel since Linux 2.6.20. It requires a CPU that supports virtualization extensions. It is completely open source.

KVM architecture

KVM is an open source Linux native full virtualization solution based on X86 hardware of virtualization extensions (Intel VT or AMD-V). In KVM, the virtual machine is implemented as a regular Linux process, which is scheduled by the standard Linux scheduler, and each virtual CPU of the virtual machine is implemented as a conventional Linux process. This allows KMV to use the existing features of the Linux kernel.

However, KVM itself does not perform any hardware simulation, and requires the client space program to set up the address space of a client virtual server through the / dev/kvm interface, provide it with a simulated Imando O, and map its video display back to the host display screen. The current application is QEMU.

User space, kernel space, and virtual machines on Linux:

Guest: client systems, including CPU (vCPU), memory, drivers (Console, network card, Imax O device driver, etc.), are run in a restricted CPU mode by KVM. KVM: runs in kernel space, providing virtual levels of CPU and memory, as well as the client's Imax O interception. After being intercepted by KVM, the Guest's Icano is handed over to QEMU for processing. QEMU: modified QEMU code for use in KVM virtual machines, running in user space, providing hardware I dev/kvm O virtualization, and interaction with KVM through IOCTL / dev/kvm devices.

KVM function

The features supported by KVM include:

Support for CPU and memory hyper-score (Overcommit) support for paravirtualized Imax O (virtio) support for hot swappable (cpu, block devices, network devices, etc.) support for symmetric multiprocessing (Symmetric Multi-Processing) SMP) supports real-time migration (Live Migration) supports direct allocation of PCI devices and single Imax O virtualization (SR-IOV) supports kernel on-page merging (KSM) supports NUMA (Non-Uniform Memory Access, inconsistent storage access structure)

Common tools for KVM

Libvirt: a virtualized API that operates and manages KVM virtual machines, written in C, and can be called by Python,Ruby, Perl, PHP, Java, and other languages. Can operate including KVM,vmware,XEN,Hyper-v, LXC and other Hypervisor. Virsh: libvirt-based command line tool (CLI) Virt-Manager: libvirt-based GUI tool virt-v2v: virtual machine format migration tool virt-* tool: including Virt-install (command line tool for creating KVM virtual machine), Virt-viewer (tool for connecting to virtual machine screen), Virt-clone (virtual machine cloning tool), virt-top and other sVirt: security tools

KVM installation

Check to see if CPU supports virtualization before installation

Lntel CPU: [root@localhost ~] # cat / proc/cpuinfo | grep vmx

If the above operations have output, it means that CPU supports virtualization.

Experimental environment

KVM:Centos6.5 64-bit operating system memory 4GB hard disk 20g

Enable CPU virtualization support:

Installation dependency

[root@localhost ~] # yum-y install qemu-kvm qemu-kvm-tools python-virtinst.noarch qemu-img bridge-utils libvirt virt-manager

Check to see if the KVM module [root@localhost ~] # lsmod | grep kvmkvm_intel 54285 0kvm 333172 1 kvm_intel runs the KVM network in libvirt. There are two ways: NAT and bridge. The default is NAT. Bridge (bridging mode) will be taken as an example. [root@localhost ~] # ip A1: lo:mtu 16436 qdisc noqueue state UNKNOWN link/loopback 0012 qdisc pfifo_fast state UP qlen 0000 link/ether 00:0c:29:88:85:64 brd ff:ff:ff:ff:ff:ff:: 1 scope host lo inet6 128 scope host valid_lft forever preferred_lft forever2: eth0:mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:88:85:64 brd ff:ff:ff:ff:ff:ff Inet 192.168.2.113 scope global eth0 inet6 fe80::20c:29ff:fe88:8564/64 scope link valid_lft forever preferred_lft forever3 24 brd 192.168.2.255 scope global eth0 inet6 fe80::20c:29ff:fe88:8564/64 scope link valid_lft forever preferred_lft forever3: pan0:mtu 1500 qdisc noop state DOWNlink/ether c2:34:e0:1c:77:37 brd ff:ff:ff:ff:ff:ff [root@localhost ~] # cd / etc/sysconfig/network-scripts/ [root@localhost network-scripts] # cp ifcfg-eth0 ifcfg-br0 [root@localhost network -scripts] # vim ifcfg-br0DEVICE=br0HWADDR=00:0c:29:88:85:64TYPE=BridgeONBOOT=yesNM_CONTROLLED=noBOOTPROTO=staticIPADDR=192.168.2.113NETMASK=255.255.255.0 [root@localhost network-scripts] # vim ifcfg-eth0 DEVICE=eth0HWADDR=00:0c:29:88:85:64TYPE=EthernetONBOOT=yesNM_CONTROLLED=noBOOTPROTO=staticBRIDGE= "br0" # bridging Virtual Network Card name [root@localhost ~] # / etc/init.d/network restart

[root@localhost ~] # ip a

Install KVM

[root@localhost ~] # mkdir-pv / data_kvm/ {store,iso} mkdir: created directory "/ data_kvm" mkdir: created directory "/ data_kvm/store" mkdir: created directory "/ data_kvm/iso"

Enter the graphical interface

[root@localhost ~] # virt-manager

There is an error in the connection, just restart

Restart libvirtd

[root@localhost ~] # / etc/init.d/libvirtd start [root@localhost ~] # virt-manager

Add Pool

Double-click localhost {QEMU}-Storage-"+" to add a pool

Select Browse-find the directory you just created-done

Create a storage volum

The KVM01 pool just created on a stand-alone machine-create a new volume

New virtual machine

The specific installation process is the same as installing the Linux system (linux system installation tutorial)

View the configuration file storage directory of KVM

[root@localhost ~] # ls / etc/libvirt/qemucentos6.5.xml networks

View virtual machine status

[root@localhost ~] # virsh list-all Id name status-2 centos6.5 running (enabled)

Virtual machine shutdown, boot self-boot and other operations

To ensure that the acpid service is installed and running [root@localhost ~] # yum-y install acpid

[root@localhost ~] # / etc/init.d/acpid start [root@localhost ~] # / etc/init.d/haldaemon stop is shutting down the HAL daemon: [OK] [root@localhost ~] # / etc/init.d/acpid start [root@localhost ~] # / etc/init.d/haldaemon start starts the HAL daemon: [confirm] [root@localhost ~] # / etc/init.d/acpid statusacpid (pid 1417) is running. Shutdown KVM virtual machine [root@localhost ~] # virsh shutdown centos6.5 domain centos6.5 is disabled [root@localhost ~] # virsh destroy centos6.5 domain centos6.5 is deleted

[root@localhost ~] # virsh list-- all Id name status-centos6.5 shuts down the boot KVM virtual machine [root@localhost ~] # virsh start Centos6.5 domain centos6.5 has started [root@localhost ~] # virsh list-- all Id name status-4 centos6.5 running virtual machine companion host since Dynamic start [root@localhost ~] # virsh autostart centos6.5 domain centos6.5 marked to automatically start [root@localhost ~] # ls / etc/libvirt/qemuautostart centos6.5.xml networks export virtual machine configuration [root@localhost ~] # virsh dumpxml centos6.5 > / etc/libvirt/qemu/centos6.5_bak.xml delete virtual machine [root@localhost ~] # virsh undefine centos6.5 modify virtual machine configuration information [root@localhost ~] # virsh edit centos6.5

KVM file management, converting raw format to qcow2 format

Virtual machine disk files are divided into raw and qcow2 formats, and the default format of KVM is raw bare devices.

Raw benefits: good performance, the fastest. Cons: some new features are not supported. Such as: mirror, zlib disk compression, AES encryption, etc.

Libguestfs-tools tool to realize format conversion

[root@localhost ~] # yum-y install libguestfs-tools

[root@localhost ~] # qemu-img info / data_kvm/store/KVM011.imgimage: / data_kvm/store/KVM011.imgfile format: rawvirtual size: 3.9g (4194304000 bytes) disk size: 3.9g [root@localhost ~] # virsh shutdown centos6.5 domain centos6.5 is turned off format conversion It takes some time for [root@localhost ~] # qemu-img convert-f raw-O qcow2 / data_kvm/store/KVM011.img / data_kvm/store/KVM011.qcow2 [root@localhost ~] # ls / data_kvm/store/KVM011.img KVM011.qcow2 [root@localhost ~] # ls / etc/libvirt/qemuautostart centos6.5_bak.xml centos6.5.xml networks [root@localhost ~] # virsh edit centos6.5 to edit the domain centos6.5 XML configuration. Modify the xml configuration file 2324Virt-cat command of centos6.5, which is similar to cat. You can view the file in the virtual machine and view the network file in the virtual machine. It takes some time to [root@localhost ~] # virt-cat-a / data_kvm/store/centos6.5.qcow2 / etc/sysconfig/network Virt-edit command to edit the file. Usage is basically the same as vim [root@localhost ~] # virt-edit-a / data_kvm/store/centos6.5.qcow2 / etc/sysconfig/networ Virt-df command to view virtual machine disk information [root@localhost ~] # virt-df-h centos6.5Filesystem Size Used Available Use%centos6.5:/dev/sda1 484M 33m 427m 7%centos6.5:/dev/sdb1 4.2G 4.2G 0 100%centos6.5:/dev/VolGroup/lv_root 3.0G 1.0G 1.8G 34%

Cloning of virtual machine

[root@localhost ~] # virsh destroy centos6.5 domain centos6.5 deleted [root@localhost ~] # virsh list-- all Id name status-centos6.5 Close cloning from centos6.5 to centos6.5-clome [root@localhost ~] # virt-clone-o centos6.5- n centos6.5-clome-f / data_kvm/store/KVM011-clone.qcow2 Clone 'centos6.5-clome' created successfully. [root@localhost ~] # virsh list-- all Id name status-centos6.5 off-centos6.5-clome off

Snapshot of the virtual machine

Create a snapshot [root@localhost ~] # virsh snapshot-create centos6.5Domain snapshot 1535644190 created 1535644190: version number of the snapshot (how many seconds have elapsed since January 1, 1970) View snapshot information [root@localhost ~] # virsh snapshot-list centos6.5 name Creation Time status-- -1535644190 2018-08-30 23:49:50 + 0800 shutoff restore snapshot [root@localhost ~] # virsh snapshot-list centos6.5 name Creation Time status-- -1535644190 2018-08-30 23:49:50 + 0800 shutoff 1535644574 2018-08-30 23:56:14 + 0800 shutoff [root@localhost ~] # virsh snapshot-revert centos6.51535644190 [root@localhost ~] # virsh snapshot-current centos6.51535644190shutoff delete snapshot [root@localhost ~] # virsh snapshot-delete centos6.5 1535644190Domain snapshot 1535644190 deleted [root@localhost ~] # virsh snapshot-list centos6. 5 name Creation Time status-1535644574 2018-08-30 23:56:14 + 0800 shutoff "how to deploy kvm Virtualization Technology on Centos6.5" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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