In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to install and deploy VMware Virtualization kvm", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to install and deploy VMware Virtualization kvm.
Virtualization
1. Environment
Centos7.3
Turn off selinux, turn off firewall
2. Virtualized environment configuration
2.1 kvm deployment installation
1. VMware configure bridging mode
2. Bios enables the virtual machine. Take the local desktop as an example.
Restart the computer and press the Del key all the time to enter the BIOS setting. For details, refer to
Https://jingyan.baidu.com/article/4e5b3e190066c091901e2482.html
Check if virtual machines are supported
# egrep'(vmx | svm)'--color=always / proc/cpuinfo
3. Configure epel yum source
4. Install kvm software package
Yum install qemu-kvm qemu-kvm-tools libvirt virt-manager virt-install openssh-askpass-y//qeum virtualization software, can virtualize different CPU, and analog network cards, sound cards, PCI devices, etc. / / libvirt tools for managing KVM / / virt-install command line installation virtual machine tools / / virt-manager graphical management virtual machine tools / / openssh-askpass remote connection to the KVM host
5. Start the libvirt management KVM tool
# systemctl enable libvirtd.service# systemctl start libvirtd.service
Upload ios files to the corresponding directory and create / opt/images (customizable location) directory to place disk space files
Default kvm profile location
/ etc/libvirt/qemu/
Disk space
There are two disk formats in the KVM virtual machine:
Raw format: directly occupies physical disk, fast writing, excellent performance, but takes up space (default format)
Qcow2 format: use as many disks as you want, and support compression, snapshot and mirroring
2.2 create a kvm virtual machine
Xshell uses the command
The host uses the Virt-manager command to enter the graphical interface to install
Note that when using virt-manager management tools to manage virtual machines, it may occur that the keys entered on the keyboard are different from those displayed.
At this point, you only need to modify the Keymap attribute in the VNC column in the virtual machine details, and change the content to en-us.
The virtual machine needs to be restarted after modification.
If the modification is not successful while the virtual machine is running, shut down the virtual machine, and then modify it while the virtual machine is off.
Step 1: create a new virtual machine named rhel7.2
1) in the Virtual system Manager, click the create New Virtual Machine button at the top left (as shown in figure-3).
Figure-3
2) Pop up the "New Virtual Machine" wizard, select "Local installation Media" (as shown in figure-4), and click forward.
Figure-4
3) next, "locate the installation media", please correctly specify the ISO CD image file location of the RHEL7 system (as shown in figure-5), make sure that the operating system type is automatically recognized, and click "forward".
Figure-5
4) Select the memory and CPU settings, it is recommended to allocate memory for the virtual machine not less than 1024MB (as shown in figure-6), and click forward.
Figure-6
5) enable storage for the virtual machine, such as allocating a disk for 40GiB (as shown in figure-7), and click forward.
Figure-7
6) name the virtual machine, set it to rhel7.2 (shown in figure-8), and click finish.
Figure-8
Step 2: install the operating system for the virtual machine rhel7.2
1) confirm that the new virtual machine boots from the CD
After all the above settings are completed, the new virtual machine will be automatically started and the installation process will begin (as shown in figure-9).
Figure-9
2) complete the subsequent manual installation process
The specific process is the same as the normal installation, pay attention to disable the firewall, disable the SELinux mechanism.
3) confirm the installation result
The newly installed virtual machine rhel7.2 can start and log in normally.
This virtual machine can also be seen in the Virtual system Manager (figure-10).
Figure-10
Close selinux
Sed-I's etc/selinux/configsetenforce GN / etc/selinux/configsetenforce 0
Turn off the firewall (test development environment)
Systemctl stop firewalld.servicesystemctl disable firewalld
Time synchronization
Yum install-y wget ntpdate net-toolsln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtime/usr/sbin/ntpdate cn.pool.ntp.orgecho "0 * / 3 * / usr/sbin/ntpdate cn.pool.ntp.org; / sbin/hwclock-w > / dev/null" > / var/spool/cron/root
Add Ali Cloud Yun source and epel source
Wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repowget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
Modify the maximum number of processes and maximum file openings
Vi / etc/security/limits.conf* soft nproc 65535 * hard nproc 65535 * soft nofile 65536 * hard nofile 65536
Noproc represents the maximum number of processes
Nofile is the maximum number of file openings.
Closes the current shell and reopens it. There is no need to restart the system.
Clear / etc/issue / etcissue.net and remove the screen display before login of the system and kernel version
Echo > / etc/issue
Echo > / etc/issue.net
3. The management of KVM virtual machine is mainly through virsh command.
1. View KVM virtual machine configuration files and running status
(1) default configuration file location of KVM virtual machine: / etc/libvirt/qemu/
The autostart directory is the configuration kvm virtual machine boot self-boot directory.
(2) virsh command help
# virsh-help
3.1 Common commands
1) virsh nodeinfo: view KVM node (server) information
2) virsh list-all to view the status of kvm virtual machines
3) boot the virsh start oeltest01 KVM virtual machine
4) shutdown of virsh shutdown oeltest01 KVM virtual machine
5) virsh destroy oeltest01 forcibly shuts down power
6) virsh reboot oeltest01 restarts the specified virtual machine
7) virsh create / etc/libvirt/qemu/wintest01.xml starts the virtual machine through the configuration file
8) virsh autostart oeltest01 configuration Boot self-booting Virtual Machine
9) virsh autostart-disable Name / shutdown the virtual machine starts with the system
10) virsh dumpxml wintest01 > / etc/libvirt/qemu/wintest02.xml exports the KVM virtual machine configuration file
11) virsh undefine wintest01 this command only deletes the configuration file of wintest01, not the virtual disk file 12) virsh dominfo virtual machine name: view the information of the specified virtual machine
13) virsh edit wintest01 edits KVM virtual machine configuration file
14) virsh suspend oeltest01 hangs server
15) virsh resume oeltest01 recovery server
3.2 expansion of VM virtual machine
There are two disk formats in the KVM virtual machine:
Raw format: directly occupies physical disk, fast writing, excellent performance, but takes up space
Qcow2 format: use as many disks as you want, and support compression, snapshot and mirroring
Note: raw does not support snapshots, Qcow2 supports snapshots, but the two file types can be converted to each other
Regardless of whether the disk is in raw qcow2 format, the idea of expansion is as follows
1. Add a new disk to the virtual host that needs to be expanded
two。 Extend using lvm logical volume management
1. View the virtual disks used by the current KVM virtual machine
[root@kvm-node1 ~] # virsh domblklist centos7u4-node1Target Source---vda / data/centos7u4-node1.qcow2
two。 Create a qcow2 virtual disk
[root@kvm-node1] # qemu-img create-f qcow2 / data/centos7u4-node1-disk2.qcow2 10G
3. Add a virtual disk online
/ / add [root@kvm-node1 ~] # virsh attach-disk centos7u4-node1 / data/centos7u4-node1-disk2.qcow2 vdb-- cache=none-- subdriver=qcow2Disk attached successfully// online to view the new disk status [root@kvm-node1 ~] # virsh domblklist centos7u4-node1Target Source---vda / data/centos7u4 -node1.qcow2vdb / data/centos7u4-node1-disk2.qcow2// modify configuration file To prevent the loss of new disks after restarting kvm, add the following configuration [root@kvm-node1 ~] # virsh edit centos7u4-node1
4. Connect KVM virtual machine through vnc to expand disk capacity
5. The steps to expand the capacity are as follows: add all vdb to the logical partition directly.
Mkfs.xfs / dev/sdb # formats the new hard drive
Pvcreate / dev/vdb # initializes physical volumes
Vgextend centos / dev/vdb # adds initialized partitions to the virtual volume group centos (the commands for volumes and volume groups can be done through vgdisplay)
Lvextend-l + 100%FREE / dev/centos/root extends the capacity of an existing volume is the size of the free viewed through vgdisplay)
Xfs_growfs / dev/centos/root # CentOS 7 due to the use of XFS
Resize2fs / dev/mapper/centos-root # CentOS 6 due to the use of XFS
3.3 VM virtual machine performance tuning
Increase the memory and the number of cpu
1. Turn off the virtual machine
# virsh shutdown vm
2. Edit the virtual machine configuration file and adjust
# virsh edit test01
Find the "memory" and "vcpu" tags and set the
Test01 2220a6d1-a36a-4fbb-8523-e078b3dfe795 1048576 1048576 1
Change to:
Centos73 2220a6d1-a36a-4fbb-8523-e078b3dfe795 2097152 2097152 2
3. Redefine the configuration to make it effective
# virsh define / etc/libvirt/qemu/test01.xml
4. Enable the virtual machine
# virsh start test01
Pre-adjustment virtual machine information
Adjusted virtual machine information
3.4 kvm cloning
3.4.1 Direct cloning of native virtual machines on KVM hosts
(the cloned machine must be turned off)
Virt-clone-o z7-013-251-template-n test01-f / kvm/test01.img
Description: use Z7-013-251-template as the source, clone test01 virtual machine, and create a virtual machine named test01, using disk file / kvm/test01.img
# virsh start test01 # start test01
Configure a boot-up virtual machine
# virsh autostart test01
Virt-manager enters the cloned virtual machine, modifies the IP address of the cloned machine (ping beforehand to make sure that IP can be used, and does not conflict with other IP), modifies the hostname hostname, etc.
Test template machine (modify time zone, time synchronization, turn off selinux, turn off firewall, turn off postfix service)
3.4.2 cloning through a graphical interface
Enter the command virt-manager in the host server to call out the graphical interface
Open the operation interface and right-click the existing virtual machine to clone
Virtual machine naming rules:
Test-014-004Mutual Gaia-Test
Dev-016-004Mutual Gaia-developer
U Open to modify the configuration, the address of the corresponding network segment, and select the appropriate vlan
U modify the disk file name on the host machine
# mv / kvm/z7-013-253-disk-001-clone.img / kvm/test01.img
# sed-I 's@/kvm/z7-013-253MustDiskMuy001Musclone.imgtogether KVM Greater KVM Greater Test01.imghands' / etc/libvirt/qemu/test01.xml
Then start the virtual machine
Enter the cloned virtual machine, modify the IP address of the cloned machine, etc.
3.5 Delete virtual machine or graphical interface operation
1) shut down the virtual machine: virsh destroy test01
2) Delete virtual machine files (related files under / var/lib/libvirtd/)
3) Delete definition: virsh undefine test01
4) virsh autostart-disable test01
3.6 kvm virtual machine migration
Migration is the migration realized by copying virtual disk files and configuration files of virtual machines to the target virtual host when the virtual machine is shut down.
Cross-host migration
(1) determine the shutdown status of the virtual machine
(2) prepare to migrate the test01 virtual machine and view the disk files configured by the virtual machine
# [root@kvm213 ~] # virsh domblklist test01Target Source---vda / kvm/test01.img
(3) Import virtual machine configuration file
# virsh dumpxml test01 > / root/test01.xml
(4) Scp copies configuration files and virtual disk files to the corresponding location of the target virtual host
On the target virtual host
View the virtual machine disk file and the directory structure is the same as that of the source virtual host.
Define a registered virtual host
Virsh define / etc/libvirt/qemu/test01.xml
Start the virtual host and confirm
3.7 kvm virtual machine snapshot backup
To use the mirroring feature, the disk format must be qcow2
(1) View disk format
# qemu-img info test01.img
(2) Snapshot management of virtual machines
# virsh snapshot-create test01
View the version of the virtual machine mirror snapshot
# virsh snapshot-list test01
View the version of the current virtual machine mirror snapshot
# virsh snapshot-current test01
(3) restore the snapshot of the virtual machine. You must shut down the virtual machine.
Perform a restore and confirm the restore version
# virsh snapshot-revert test01 version number
(4) Delete virtual machine snapshot
# virsh snapshot-delete test01 version number
These are all the contents of the article "how to install and deploy VMware Virtualization kvm". 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.