In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what are the methods of building a KVM virtualization platform in CentOS7, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
KVM is a kernel-based virtual machine (Kernel-based Virtual Machine). It 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.
The overall structure of KVM:
From GUI to the Linux kernel, it includes the following five components:
1) virt-manager
A GUI/CUI user interface for managing VM; it uses libvirt api to invoke various functions of VM.
2) libvirt
A tool and interface, as a more general server virtualization software, which supports Xen,VMware ESXi/GSX and, of course, QEMU/KVM.
3) QEMU
A simulator that interacts with the KVM kernel module to handle a variety of client system requests such as Imax O; a QEMU process corresponds to a client system.
4) KVM kernel module
In a narrow sense, KVM is a Linux kernel module that processes the VM Exits of the client system and executes VM Entry instructions.
5) Linux kernel
Since QEMU runs as an ordinary user process, the scheduling of the corresponding client system is handled by the Linux kernel itself.
All components are open source software (OSS).
Installation of KVM:
Environmental requirements:
1. If it is a physical server, you need to turn on the virtualization feature (Virtualization Technology) in BIOS. General servers enable this feature by default.
2. If you are experimenting with VMware Workstation, check the virtualization feature in the CPU of the established virtual machine, so that the virtual machine will support KVM virtualization.
Installation method:
The easiest way to install the system is to install the virtualization feature when installing the system. Here, take CentOS7.3 as an example. When you select the installation package as shown below, select "Server with GUI", and check "Virtualization client", "Virtualization Hypervisor", "Virtualization tools".
If your system is minimally installed, you should install the following required software:
# yum groupinstall "GNOME Desktop" / / install GNOME Desktop Environment
Check whether cpu supports it.
# grep-E 'svm | vmx' / proc/cpuinfo- vmx is for Intel processors- svm is for AMD processors
Install virtualization softwar
# yum install epel-rpm-macros.noarch / / install epel source # yum install qemu qemu-img qemu-kvm libvirt libvirt-python libguestfs-tools virt-install# yum install virt-manager virt-viewer / / install graphical tool # systemctl enable libvirtd # systemctl start libvirtd
Check if the KVM module is installed
[root@localhost ~] # lsmod | grep kvmkvm_intel 174250 0 kvm 570658 1 kvm_intelirqbypass 13503 1 kvm
First, create a virtual machine using a graphical interface
1. Preparation before creating a virtual machine:
(1) operating system installation media: ISO file, copy the system image file to the / kvm/iso directory
[root@localhost ~] # mkdir / kvm/iso-p [root@localhost ~] # umount / dev/sr0 [root@localhost ~] # cp / dev/sr0 / kvm/iso/Centos7.iso
(2) disk space preparation:
Add a new disk
Create LVM
Create a file system and mount point, and set up boot automatic mount
Pvcreate / dev/sdbvgcreate kvm_vg/ dev/sdblvcreate-n kvm_lv-L 100G kvm_vgmkdir / kvm/vfsmount / dev/kvm_vg/kvm-lv / kvm/vfs
(3) using virt-manager graphical interface to create
Virt-manager is a graphical virtual machine management software based on libvirt. Enter the virt-manager command as root on the command line, and the virt-manager management interface appears
Create an image storage pool named iso with a directory of / kvm/iso, which will be used to place the iso CD image files used by KVM virtual machines in the future.
Create a storage pool named vfs, directory / kvm/vfs, and create a storage volume, which is actually the hard disk file of the KVM virtual machine
Select "New Virtual Machine" in Virtual system Manager and select "Local installation Media"
Select an ISO image file
Select memory size and number of CPU
Select virtual machine disk file
Name the virtual machine and click finish
After clicking finish, the virtual machine will be created, and then you can follow the operating system.
Second, create a virtual machine using command line mode
1. Use the qemu-img command to create disk files
Create a disk file in raw format
[root@localhost ~] # qemu-img create / kvm/vfs/vm1.raw 20g
Convert disk format to qcow2
[root@localhost] # qemu-img convert-f raw-O qcow2 / kvm/vfs/vm1.raw / kvm/vfs/vm1.qcow2
Directly create a disk file in qcow2 format
[root@localhost] # qemu-img create-f qcow2 / kvm/vfs/vm1.qcow2 20G
2. Use the virt-install command to create a virtual machine
General options:
-n NAME,-- name=NAME virtual machine name
-r MEMORY,-- memory allocated by ram=MEMORY for client events in MB
-- vcpus=VCPUS configure the number of virtual CPU (vcpu) of the virtual machine, such as:
-- vcpus 5
-- vcpus 5, maxcpus=10
-- vcpus socket=2,cores=4,threads=2
-- cpuset=CPUSET Set which physical CPUs domain can use.
-- cpu=CPU CPU models and features, such as:-- cpu coreduo,+x2apic
The readable VM description saved by description=DESCRIPTION in the generated XML.
-- security=SECURITY sets domain security drive configuration.
-- numatune=NUMATUNE adjusts the NUMA policy for domain processes.
Installation method options:
-c CDROM,-- cdrom=CDROM optical drive installation media
-l LOCATION,-- location=LOCATION
Installation source (for example: nfs:host:/path, http://host/path, ftp://host/path)
-- pxe boots from the network using the PXE protocol
Import builds the client in the disk image
-- livecd treats optical drive media as Live CD
-x EXTRA,-- extra-args=EXTRA
Parameters attached to the kernel booted with-- location
-- os-type=DISTRO_TYPE
Operating system type, 'linux',' unix', 'windows'
-- os-variant=DISTRO_VARIANT
Operating system version, such as' fedora6','rhel5', 'solaris10',' win2k'
-- install boot sequence, menu, permanent kernel boot, etc., after boot=BOOTOPTS optional configuration.
Storage configuration:
-- disk=DISKOPTS specifies storage with various options. Ex.
-- disk path=/my/existing/disk
-- disk path=/my/new/disk,format=qcow2,size=5,sparse (unit GB)
-- disk vol=poolname:volname,device=cdrom,bus=scsi,...
-- nodisks do not set any disks for this client.
-- filesystem=FILESYSTEMS
Pass the host directory to the virtual machine. For example:
-- filesystem / my/source/dir,/dir/in/guest
-- filesystem template_name,/,type=template
Networking configuration:
W NETWORK,-network=NETWORK
Configure the customer network interface. Ex:
-- network bridge=mybr0
-- network network=my_libvirt_virtual_net
-- network network=mynet,model=virtio,mac=00:11...
-- nonetworks do not create network interfaces for this object.
Drawing configuration:
-- graphics=GRAPHICS
Configure virtual machine display settings. For example:
-- graphics vnc
-- graphics spice,port=5901,tlsport=5902
-- graphics none
-- graphics vnc,password=foobar,port=5910,keymap=ja
Noautoconsole do not automatically attempt to connect to the client console
Device options:
-- serial=SERIALS configure virtual machine serial port device
-- parallel=PARALLELS configure virtual machine parallel port devices
-- channel=CHANNELS configure virtual machine communication channel
-- console=CONSOLES configures a text console connection between the virtual machine and the host
-- host-device=HOSTDEVS configures physical host devices connected to the customer
-- soundhw=SOUNDHW configuration customer sound equipment simulation
-- watchdog=WATCHDOG configure virtual machine watchdog device
-- video=VIDEO configures virtual machine video hardware.
-- smartcard=SMARTCARD configures virtual machine smart card devices.
For example:-- smartcard mode=passthrough
-- redirdev=REDIRDEV Configure a guest redirection device.
For example:-- redirdev usb,type=tcp,server=192.168.1.1:4000
Virtualization platform options:
-v,-- the hvm client should be a full virtual client
-p,-- paravirt this client is a semi-virtual client
-- container This guest should be a container guest
-- name of the hypervisor to be used by virt-type=HV_TYPE (kvm, qemu, xen)
-- CPU framework of arch=ARCH simulation
-- machine=MACHINE The machine type to emulate
-- noacpi disables ACPI for full virtual clients (overrides numeric values in os-type/os-variant db)
-u UUID,-- uuid=UUID client UUID.
Other options:
-- the domain starts automatically when autostart boots the host.
-- print-xml outputs the XML of the generated domain instead of defining the virtual machine.
-- print-step=XMLSTEP output specific installation steps
-- do not boot the virtual machine after noreboot is installed.
-- time to wait for wait=WAIT (in minutes)
-- dry-run completes the installation steps, but do not create devices or define virtual machines.
-- force forcibly answers' yes','to any application prompt to terminate other prompts
-Q,-- quiet prohibits error-free output
-- prompt requires the user to enter for ambiguous situations or required options
-d,-- debug enter troubleshooting information
3. Install the virtual machine using a pure command line
[root@localhost ~] # qemu-img create-f qcow2 / kvm/vfs/vm2.qcow2 20G [root@localhost ~] # virt-install-n vm2\ define virtual machine name
>-r 1024\ memory size
>-- number of vcpus 1\ CPU
>-l / kvm/iso/Centos7.iso\ ISO location
>-- disk path=/kvm/vfs/vm2.qcow2,format=qcow2\ disk file location and format
>-- nographics\ does not need to install graphically
>-x console=ttyS0 allows you to log in to the virtual machine using the console terminal
Execute the command to install the operating system, and adjust the following configuration parameters as needed
4. Create a virtual machine system by using VNC
[root@localhost ~] # qemu-img create-f qcow2 / kvm/vfs/vm3.qcow2 20G [root@localhost ~] # virt-install-n vm3\ define virtual machine name
>-r 1024\ memory size
>-- number of vcpus 1\ CPU
>-l / kvm/iso/Centos7.iso\ ISO location
>-- disk path=/kvm/vfs/vm3.qcow2,format=qcow2\ disk file location and format
>-- graphics vnc,listen=0.0.0.0,port=5924,\ vnc installation, using port 5924
>-- noautoconsole\ do not automatically attempt to connect to the client console
>-- accelerate\ accelerated installation
>-- automatically starts the domain when autostart boots the host
[root@localhost ~] # firewall-cmd-- add-port=5924/tcp allows vnc connections
Use vnc client software to connect to the installation
These are all the contents of the article "what are the ways to build a KVM virtualization platform in CentOS7?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.