In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
--
Virtualization
KVM (kernel-based virtual machine)
Xen kvm vmare esx openVZ Oracle VM VirtualBox vsphere
Enterprise applications: non-local
It is divided into two parts: first, host virtual machine
Second, the management terminal
The earliest virtualization: time-sharing operating system single-core CPU can only do one task at a time to run multiple processes or threads is a kind of virtualization
Cpu runs one process, interrupts, and then runs another. Because CPU runs fast, the user does not feel this switch. This switch is called context switching.
Common virtualization scenarios: game simulators: such as using CPU of X86 to simulate PSP or CPU of arcade, and hardware of X86 to simulate hardware of PSP or arcade
Virtual structure diagram of vmware workstation:
OS1 OS2
Vmware workstation
OS (kernel)
Hardware: CPU,mem,hd, etc.
-- the above structure: the operation of OS1 and OS2 needs to be transformed into a request for OS by a process through vmware, and then a request for hardware from OS.
If the other programs running in OS take up a lot of resources, it will inevitably result in less resource consumption and poor performance of vmware, because the processes of vmware and other processes are at the same level.
How to improve performance: skip the OS layer
Or virtualization is at the same level as os.
Or the hardware itself supports virtualization.
So it develops into the following virtual situations:
Semi-(quasi) Virtualization:
Full Virtualization:
Semi-(quasi) Virtualization:
The guest machine operating system must be modified to use paravirtualization.
Hardware virtualization technology.
Typical representative: Xen
Citrix: xen
Xen paravirtualized structure diagram:
Domain0 domain1 domain2...
Xen
Hardware: CPU,MEM,HD, etc.
-- the above structure: xend replaces OS,domain0 is a controller used to control xen (run hypervisor), domain1,domain2... Is a virtual operating system; in this way, the conversion efficiency will be much higher.
But it should be noted that the kernel interfaces such as domain1,domain2 in the upper layer must correspond to xen.
Xen needs to use a proprietary kernel that supports xen, but not the original kernel. The original kernel communicates directly with the hardware.
Open source linux,freebsd can be modified, but windows is not.
Xen has been added to the linux kernel, and xen has been in the kernel since 2.6.18.
Citrix bought xen, so instead of developing xen, redhat bought another kvm; and citrix is a platinum partner of Microsoft. It can ask MS to modify the source code to support xen, so only citrix's xen supports windows.
Hypervisor-- is an intermediate software layer that runs between the underlying physical server and the operating system, allowing multiple operating systems and applications to share hardware. It can also be called VMM (virtual machine monitor), or virtual machine monitor.
Hypervisors is a "meta" operating system in a virtual environment. They have access to all physical devices on the server, including disks and memory.
Hypervisors not only coordinates the access of these hardware resources, but also protects each virtual machine.
When the server starts and executes Hypervisor, it loads the operating system of all virtual machine clients and allocates the right amount of memory, CPU, network and disk to each virtual machine.
Full Virtualization:
Cpu must support hardware virtualization.
The client machine does not need to modify the kernel and can install any operating system in principle.
Intel # cat / proc/cpuinfo | grep vmx
AMD: svm
Typical representatives: kvm, VMware ESXi
KVM fully virtualized structure diagram:
OS1 OS2
KVM os
Hardware: CPU,MEM,HD, etc.
Require operating system vendors to write in accordance with its virtualization standards and rules
=
Red Hat official download path
Docs.redhat.com
Https://access.redhat.com/documentation/en-US/
KVM official installation documentation (english)
Red_Hat_Enterprise_Linux-6-Virtualization_Host_Configuration_and_Guest_Installation_Guide-en-US.pdf
Install kvm on the host
1. Configure yum
# vim / etc/yum.repos.d/rhel-source.repo
[rhel-source]
Name=rhel6.5
Baseurl= file:///yum/
Enabled=1
Gpgcheck=0
# yum groupinstall "Virtualization"
# yum groupinstall "Virtualization Client"
# yum groupinstall "Virtualization Platform"
# yum groupinstall "Virtualization Tools"
# service libvirtd restart
# chkconfig libvirtd on
# cat / proc/cpuinfo | grep-E "vmx | svm"-check whether CPU supports intel or AMD virtual technology
Vmx-intel
Svm-AMD
# modprobe kvm
# modprobe kvm_intel-if the vmx directive is not supported, loading is not supported
# lsmod | grep kvm
Kvm_intel 52570 0
Kvm 314739 1 kvm_intel
Start installing kvm
1, graphic installation
# virt-manager-the same command as xen to open the virtual machine manager
Installation name: kvm1-- name at will
Installation method:-- I choose the first one here and install it directly using iso.
Installation path: / share/soft/rhel-server-6.5-x86_64-dvd.iso-- the path where iso is written
OS type: linux
Red hat enterprise linux 6
Memory size: 1024m-if the memory is small, graphical installation cannot be used during installation, only text installation can be used.
Number of cpu: 2-cannot be greater than the number of cpu cores of the host machine
Hard disk size: 12G-- I define 12G size here and do not assign it immediately; its default path will be in / var/lib/libvirt/p_w_picpaths/kvm1.img; or you can customize the path.
Step 5: the network can only choose default now-this is a nat network (VPC), and the bridging network cannot be selected. It needs to be configured separately later.
2, command line interactive installation
[root@li] # virt-install-- prompt
What is the name of your virtual machine?
Kvm2
How much RAM should be allocated (in megabytes)?
eight hundred
What would you like to use as the disk (file path)?
/ var/lib/libvirt/p_w_picpaths/kvm2.img
How large would you like the disk (/ var/lib/libvirt/p_w_picpaths/kvm2.img) to be (in gigabytes)?
twelve
What is the install CD-ROM/ISO or URL?
/ share/soft/rhel-server-6.5-x86_64-dvd.iso
3, use the command line directly to install
# virt-install-hvm-n "kvm3"-r 800-vcpus 2-os-type= "linux"-os-variant= "rhel6"-disk path=/var/lib/libvirt/p_w_picpaths/kvm3.img,size=12-l / share/soft/rhel-server-6.5-x86_64-dvd.iso-network bridge=virbr0
Hvm means full virtualization
P means paravirtualization.
4, use kc.cfg to install automatically
# virt-install-- vnc-- noautoconsole-- arch=x86_64-- hvm-n "kvm3"-r 800-- vcpus 2-- os-type= "linux"-- os-variant= "rhel6"-- disk path=/var/lib/libvirt/p_w_picpaths/kvm3.img,size=12-- location= ftp://172.16.2.9/-- extra-args= "ks=nfs:172.16.2.9:/ks/ks.cfg"-- network bridge=virbr0
# virt-install-vnc-noautoconsole-arch=x86_64-hvm-n "kvm3"-r 800-vcpus 2-os-type= "linux"-os-variant= "rhel6"-disk path=/var/lib/libvirt/p_w_picpaths/kvm3.img,size=12-- location= ftp://172.16.2.9/-- extra-args= "ks= ftp://192.168.0.254/kvm.cfg"-- network bridge=virbr0
=
Main management commands:
Virsh help
Virsh help domain
Virsh help network
Virsh help monitor-because there are so many parameters, you can use keywords like domain,network,monitor to view only the parameter help related to the keyword
.
# virsh list
Id Name State
1 kvm1 running
# virsh list-all
Id Name State
1 kvm1 running
-kvm2 shut off
# virsh start kvm1-start a virtual machine
# virsh shutdown kvm1-normally shuts down a virtual machine after one minute (if none of them are logged in, it will shut down immediately)
# virsh reboot kvm1-A normal restart of a virtual machine will also take one minute to shut down
# virsh destroy kvm1-forcibly shuts down a virtual machine, similar to a power outage, which can shut down the virtual machine instantly
# virsh save kvm1 / etc/libvirt/qemu/kvm1.save-close kvm1 and save the current state as a file
# virsh restore / etc/libvirt/qemu/kvm1.save-restore the state of save at that time through saved files
# virsh suspend kvm1-pauses the status of kvm1
# virsh resume kvm1-- switch from pause to resume
# virt-viewer kvm1-connect to a started virtual machine and view it graphically
# virsh console kvm1-character connection to a virtual machine, but not now, because authorization from a serial port is required; example 8 below illustrates
Note here that the console connection will get stuck there; you can only kill the process to exit; but there is actually a shortcut key; it is ctrl+] (that is, the key in the middle right box) to exit.
Virtual machine related files:
Take kvm1 as an example:
The configuration file is at: / etc/libvirt/qemu/kvm1.xml
Disk file defaults to: / var/lib/libvirt/p_w_picpaths/kvm1.img
Command to delete a virtual machine (assuming kvm3)
Virsh destroy kvm3
Virsh undefine kvm3
Rm-rf / var/lib/libvirt/p_w_picpaths/kvm3.img
=
Network management
Console connection
Clone
Add or remove hardware
Remote virtual machine management
Transfer
Snapshot
=
Kvm network management
# virsh help network-only view network-related help parameters
# virsh net-list-all
Name State Autostart
-
Default active yes-this is a NAT network, private network
# virsh net-info default
Name default
UUID 704eb1b7-3feb-4a38-8642-9c3fe2f023bb
Active: yes
Persistent: yes
Autostart: yes
Bridge: virbr0
The path to the configuration file for the default segment is:
/ etc/libvirt/qemu/networks/default.xml
Virsh net-destroy default-stop the default network, check it by virsh net-list-- all, and change the status to inactive
Virsh net-start default-start the default network and change the status to active
Example 1: add private network to graphics
Virt-manager opens the drawing-- "edit--" connections details-- add a private network to the + sign in the lower left corner of the "virtual networks--" point (select name, network address range, dhcp allocation range)
-- Note: there are three types of networks in the last step:
1Jing isolated is the equivalent of vmware hostonly, without NAT and gateway
2Jing Nat has a gateway and a NAT, which can be accessed to the public network through the host
3Gramming routed is also equivalent to hostonly, which adds a gateway to isolated.
After completing the above steps, use ifconfig or virsh net-list-- all directly in the host, and you can see the newly added network
Example 2: manually add a VPC
1,# cp / etc/libvirt/qemu/networks/default1.xml / etc/libvirt/qemu/networks/default2.xml
# vim / etc/libvirt/qemu/networks/default2.xml
Default2-change the name to default2
243166ddb-e2fd-9983-1997-5e8efdc06c42-- uuid modify it casually
-- change virbr1 to virbr2
-- change the MAC address, only the last three digits
-- IP changed to 101
-- the dhcp address range is also changed to 101,
2Jing # virsh net-define / etc/libvirt/qemu/networks/default2.xml-define it, and then you can use virsh net-list-- all to check it. The status of inactive,autostart is no.
3Jing # virsh net-start default2-start
4Jing # ifconfig virbr2 | head-2-just check it out
Virbr2 Link encap:Ethernet HWaddr 52:54:00:AF:27:25
Inet addr:192.168.101.1 Bcast:192.168.101.255 Mask:255.255.255.0
# ls / etc/libvirt/qemu/networks/autostart/
Default1.xml default.xml
5Jing # virsh net-autostart default2-let him turn it on and start it automatically
# ls / etc/libvirt/qemu/networks/autostart/-there will be more default2.xml, which are actually soft links to network configuration files
Default1.xml default2.xml default.xml
The network configuration files you just added are all in the following directory
# ls / etc/libvirt/qemu/networks
Autostart default1.xml default2.xml default.xml
Example 3: modify a network
1,# vim / etc/libvirt/qemu/networks/default2.xml
Default2
243166ddb-e2fd-9982-1996-5e8efdc06c42
-- I changed the IP range of 192.168.101.0 to 192.168.102.0.
After saving, use ifconfig virbr1 to check, it is still 192.168.102.1, no change
You need to do the following three steps:
2Jing # virsh net-define / etc/libvirt/qemu/networks/default2.xml-define a network so that your changes are known to him
Network default2 defined from / etc/libvirt/qemu/networks/default3.xml
3Jing # virsh net-destroy default2-- stop this network
Network default2 destroyed
4Bing # virsh net-start default2-- restart the network
Network default2 started
Ifconfig virbr2 view, successfully modified to 192.168.102.1
The first and second steps above can be done in one step:
# virsh net-edit default2-use this command to open, modify, and then directly net-destroy and net-start without going to net-define
Example 4:
Graphics delete a network
Virt-manager opens the drawing-- "edit--" connections details-- "virtual networks--" to select the network you want to delete, and then in the lower left corner, stop first, and then delete it.
Delete a network with a command
# virsh net-destroy default2-stop the network to be deleted and use the virsh net-list-- all command to check the inactive status
# virsh net-undefine default2-this removes the network definition, and the physical configuration file is gone
Example 5: add a bridging network:
Bridge the physical network card eth0 to br0 (the name is self-defined)
There is a networkmanger service in rhel6 that can graphically manage all web links. However, this service does not support kvm bridging, so turn off the service, or add NM_CONTROLLED= "no" to the eth0 configuration file to keep eth0 out of the control of the networkmanger service.
1, create a bridging network on the host
# / etc/init.d/NetworkManager stop
# chkconfig NetworkManager off
# vim / etc/sysconfig/network-scripts/ifcfg-br0-this file does not exist, the name br0 is custom
DEVICE=br0-- names match.
TYPE=Bridge-the Birdge,B here should be capitalized, and the following irdge should be lowercase
BOOTPROTO=static
IPADDR=172.16.2.9
NETMASK=255.255.0.0
GATEWAY=172.16.1.1
ONBOOT=yes
2. Add a physical network card to a bridge network. Here, I add eth0 to br0.
# vim / etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE= "eth0"
BRIDGE=br0-- this is to bridge eth0 to br0.
NM_CONTROLLED= "no"-this sentence is to keep eth0 out of the control of networkmanager.
ONBOOT= "YES"
[root@li ~] # brctl show-- what happens before the network is restarted
Bridge name bridge id STP enabled interfaces
Virbr0 8000.5254004e4c3f yes virbr0-nic
Virbr1 8000.5254004cf4e4 yes virbr1-nic
3. Restart the network / etc/init.d/network restart
# brctl show-- View the situation after restarting the network
Bridge name bridge id STP enabled interfaces
Br0 8000.0030677653f7 no eth0
Virbr0 8000.5254004e4c3f yes virbr0-nic
Virbr1 8000.5254004cf4e4 yes virbr1-nic
With these networks, if you build a virtual machine again, there will be a variety of network options.
If you check the ifconfig on the host computer, you will have the br0 network card. There is an IP; and an eth0 network card, but it is normal without IP;.
Example 6: graphic modification of a virtual machine network card link
Virt-manager open the drawing and double-click the virtual machine you want to modify-"Click the one on the upper left!" Button show hardware detail-- > > find a network card and change it to the network you want to change (but it is reported here that you need to restart the virtual machine to take effect)
# virsh shutdown kvm1
# virsh start kvm1-after rebooting, it will be changed to the virtual network you want
-- question: some people may not see br0 when selecting graphics, but brctl show can see it, so you select specify shared device name when selecting, and then manually write br0 after bridge name below
Example 7: text modifies the network card connection of a virtual machine
1Bing # vim / etc/libvirt/qemu/kvm1.xml-- Open and modify directly
2Jing # virsh define / etc/libvirt/qemu/kvm1.xml-- define after modification of vim
# virsh edit kvm1-or use the edit command to open the modification, you can replace the previous step 1 and 2
40-change the interface type from network to bridge
forty-one
42-change the default network to bridge and the original network default to br0
forty-three
forty-four
# virsh shutdown kvm1
# virsh start kvm1-after restart, the virtual machine will be bridged to the network
-- KVM now modifies the type of a network card (such as NAT bridging), which requires a restart to take effect. However, if you add a network card or delete a network card, it does not need to be rebooted (tested in rhel6.5 environment, adding or deleting graphics network cards does not need to be restarted, but commands to add or delete network cards need to be restarted)
=
Example 8: resolve the error that the virsh console kvm1 cannot be connected
1, operate in the kvm1 virtual machine
Vim / boot/grub/grub.conf
Kernel / vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=f900cbb3-c0cf-440c-94f6-0c208f1da6e0 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet console=ttyS0,115200-add console=ttyS0,115200 to the kernel parameters to indicate that the serial port can be connected at a baud rate of 115200; note that the S in ttyS0 must be capitalized
If lowercase will prevent the virtual machine from starting, the solution:
1. Save the mode and modify it.
2. Use an interactive editing tool of virtualization
# yum install libguestfs-tools
# virt-edit-a / var/lib/libvirt/p_w_picpaths/kvm1.img / boot/grub/grub.conf to modify
By the same token, this tool can also be used in situations where the host machine has no graphics at all and cannot connect to the virtual machine through virt-viewer or ssh (because the IP of the virtual machine cannot be found) or virsh console.
You can first use virt-edit to modify and add the above console=ttyS0,115200;, and then use virsh console to connect
If the virt-edit above doesn't open, you can use # libguestfs-test-tool to debug errors. (I did a little experiment when I was talking about libraries here. I renamed / lib64/libselinux.so.1 to / lib64/libselinux.so.1.bak, and then use a soft link to link back. But here it will make a mistake. Solution: mv / lib64/libselinux.so.1.bak / lib64/libselinux.so.1)
2. Restart kvm1
# virsh reboot kvm1-Direct destroy and start may not work. It is recommended to restart it like this.
3, and then on the host machine
# virsh console kvm1-then enter and connect directly to your local virtual machine; the virtual machine can be connected without IP
4, the way to exit
Exit is just a user who logs out.
To exit the console connection completely, you need to use ctrl+] (that is, the key in the middle right box)
= =
Cloning of kvm
-- Note: cloning requires whether the source virtual machine is down or paused.
Example 9: graphic cloning
1, close kvm1 or virsh suspend kvm1 pause kvm1 first (restore using virsh resume kvm1)
2 kvm1-- kvm1---"right click" Select clone-- > modify the cloned name or other parameters-"click clone"
Example 10: text cloning
1. Copy configuration files and disk files
# cp / etc/libvirt/qemu/kvm1.xml / etc/libvirt/qemu/kvm3.xml
# cp / var/lib/libvirt/p_w_picpaths/kvm1.img / var/lib/libvirt/p_w_picpaths/kvm3.img
2. Modify the copied configuration file
# vim / etc/libvirt/qemu/kvm3.xml
Kvm3-change the name to kvm3
811d69e8-b1d8-cfbf-684a-69f2e0af6b88-- uuid change a few numbers at will
1048576
1048576
two
Hvm
Destroy
Restart
Restart
/ usr/libexec/qemu-kvm
-- change the disk path to the kvm3.img path
-- change the address of the network card casually, only the last three digits
-- the second network card is also changed casually.
3. After saving, if you cannot view it using virsh list-- all, you need to define it.
# virsh define / etc/libvirt/qemu/kvm3.xml
# virsh list-- all-- check again and you can see kvm3
Id Name State
-kvm1 shut off
-kvm1-clone shut off
-kvm2 shut off
-kvm3 shut off
# virsh start kvm3-- the cloned machine can be started
Example 11: command cloning
# virt-clone-o kvm1-n kvm4-f / var/lib/libvirt/p_w_picpaths/kvm4.img
Allocating kvm4.img 7% [-] 34 MB/s | 957 MB 05:29 ETA
-- Clone kvm1 into kvm4, and specify the disk path as / var/lib/libvirt/p_w_picpaths/kvm4.img;. If kvm1 has multiple hard disks, the corresponding path should also be cloned when cloning.
= =
Example 12: add a network card or hard disk
Virt-manager-- "double click to open kvm1--" click in the upper left corner! Click show hardware details-- "add add devices directly in the lower left corner, and write the relevant parameters (note the parameters, device type all select virtio, there is no need to restart the virtual machine, it can take effect directly, and the disk is called vda,vdb,vdc...; if you select IDE disk for the first time to add a hard disk, you need to restart, and the disk is called sda,sdb,sdc...).
-- Note: when the virtual machine (non-host) is in text mode, the devices added with the above graphical mode on the host are not added in the configuration file of the virtual machine and need to be added manually.
Example 13: add a hard disk device directly with the command
1. Create a disk file using the dd command
# dd if=/dev/zero of=/var/lib/libvirt/p_w_picpaths/kvm2-2.img bs=1M count=1 seek=4000000
-- seek refers to how many BS blocks are skipped. In this case, a 4T file is generated (the actual size is only 1m).
2. Edit the configuration file of the virtual machine
# virsh edit kvm2
By adding the following paragraph between and, you can also copy and modify the configuration definition of other disks.
-change the name to kvm1-2.img
-- change the disk name to vdb;bus bus if it is ide, then the disk name will be called sda (even if dev writes hda, fdisk will still see sda in the virtual machine); virtio bus will use vda,vdb... Named in this form.
-- change slot, too. Here, I change 0x09 to 0x10.
3, restart the virtual machine
# virsh define / etc/libvirt/qemu/kvm2.xml
# virsh reboot kvm2
=
Remote Management of kvm
Example: manage 192.168.0.252 on 192.168.0.254
1. Bind the host name of the other party (the managed host machine) in / etc/hosts first
2, do ssh equivalence
# ssh-keygen-directly enter three times
# ssh-add / root/.ssh/id_rsa-- add your own private key
Identity added: / root/.ssh/id_rsa (/ root/.ssh/id_rsa)
# scp / root/.ssh/id_rsa.pub 172.16.1.65:/root/.ssh/authorized_keys
-- pass your public key scp to the other party
3. All managed client hosts need to start the libvirtd service
4Pad the host IP (or hostname) to be connected remotely, but / etc/hosts binding is required for "file--" add connection--
5. After connecting, you can see that there are remote virtual clients, and double-click to access their graphics remotely.
-- or use commands to connect
# virt-viewer-c qemu+ssh://root@192.168.0.1/system kvm1
-- means to use root users (of course, the ssh equivalence you did earlier needs to be root users) to access the virtual machine called kvm1 on 192.168.0.1.
=
Migration:
Cold migration: there is a difference between this and cloning: cloning shuts down the source virtual machine, then all the data in memory is gone, while the migration is successful, and then when it is opened, the original memory data is maintained.
Hot migration:
Cold migration process:
1. Virtual machine kvm1 is enabled
2. Save the current running state
# virsh save kvm1 / etc/libvirt/qemu/kvm1.xml.save
Domain kvm1 saved to / etc/libvirt/qemu/kvm1.xml.save
3Jing SCP or rsync copies all the relevant files to the host to be migrated
# scp / etc/libvirt/qemu/kvm1.xml.save 172.16.1.65:/etc/libvirt/qemu/
# scp / etc/libvirt/qemu/kvm1.xml 172.16.1.65:/etc/libvirt/qemu/
# scp / var/lib/libvirt/p_w_picpaths/kvm1.img 172.16.1.65:/var/lib/libvirt/p_w_picpaths/
4, operate on 192.168.0.1 (that is, the target host of the migration)
# virsh define / etc/libvirt/qemu/kvm1.xml-- define, and then you can look it up with virsh list-- all
5,# virsh restore / etc/libvirt/qemu/kvm1.xml.save
Thermal migration process:
1. Shared storage is required for hot migration (that is, these virtual machines are installed on the shared storage devices of the host); we can only use nfs instead of
Remote01 remote02
\ /
\ /
\ /
Storage (0.254)
2. Export the disk file path of the virtual machine with nfs on the source host machine
# vim / etc/exports
/ var/lib/libvirt/p_w_picpaths * (rw,no_root_squash,sync)
# / etc/init.d/nfs restart-there is no portmap service in rhel6.x (instead of rpcbind service). Just start the nfs service directly
3. Mount the directory of the source share on the target host machine to ensure that the path is consistent
# mount-t nfs-o vers=3 172.16.2.9:/var/lib/libvirt/p_w_picpaths/ / var/lib/libvirt/p_w_picpaths/
4, to migrate, the following operation is done on the source 172.16.2.9 (check that the firewall and selinux are closed)
Order relocation
# virsh migrate-live kvm1 qemu+ssh://172.16.1.65/system
-- (there may be many problems: for example, if kvm1 has a bridging network, but 172.16.1.65 does not have it, an error will be reported: or kvm1 memory is large, and if there is not enough memory allocation on 172.16.1.65, it will also report an error, etc.; or it may be due to network problems, resulting in an unsuccessful one; after all, we are in the experimental environment @ _ @ to try several times.)
Graphic migration
Virt-manager-"right-click kvm1-- > Point Migration"
-- during the migration process, the source virtual machine can still continue to run, almost without stopping; after the migration is complete, the source will be closed (the source is no longer useful), and the target 172.16.1.65 has seamlessly taken over the state of the source virtual machine.
When hot migration, if the following error is reported
LibvirtError: internal error Attempt to migrate guest to the same host
Solution: operate on the target side 172.16.1.65
# uuidgen-generate a new uuid
596b0eb8-3a15-48da-bbba-11e136b7c893
# vi / etc/libvirt/libvirtd.conf-add the following line to this configuration file, and note that id must be enclosed in double quotation marks
Host_uuid = "596b0eb8-3a15-48da-bbba-11e136b7c893"
# / etc/init.d/libvirtd restart-restart the service
=
Kvm Snapshot
# virsh shutdown kvm1
# qemu-img info / var/lib/libvirt/p_w_picpaths/kvm1.img
P_w_picpath: / var/lib/libvirt/p_w_picpaths/kvm1.img
File format: raw
Virtual size: 12G (12884901888 bytes)
Disk size: 3.2G
# cd / var/lib/libvirt/p_w_picpaths/
# qemu-img convert-f raw-O qcow2 kvm1.img kvm1.qcow2.img
-- convert disk format from raw to qcow2
# ll-h kvm1*-- qcow2 format takes up less space
-rw- 1 root root 12G Dec 7 17:11 kvm1.img
-rw-r--r-- 1 root root 3.1G Dec 7 17:21 kvm1.qcow2.img
# virsh edit kvm1-Edit the kvm1 virtual master configuration file and replace the raw disk with the qcow2 disk
-- change row in type to qcow2
-- change the path to a file path converted to qcow2 format
# virsh start kvm1-- reboot to make it effective
# rm-rf / var/lib/libvirt/p_w_picpaths/kvm1.img-you can delete the original disk file in raw format
# virsh help snapshot-View commands related to snapshot operations
# virsh snapshot-list kvm1-column snapshot, which is not available by default
Name Creation Time State
# virsh snapshot-create-as-- domain kvm1 snap1-- description "my first test snapshot"-- create a snapshot of kvm1 called snap1
Domain snapshot snap created
# ll-h kvm1.qcow2.img-see this file growing during the construction of the snapshot
-rw-r--r-- 1 qemu qemu 3.6G Dec 7 17:48 kvm1.qcow2.img
# virsh snapshot-list kvm1
Name Creation Time State
Snap1 2013-12-07 17:52:42 + 0800 running
View help
Virsh help snapshot
View snapshot configuration
Virsh snapshot-current kvm1
Restore snapshot
Virsh snapshot-revert kvm1 snap1
Delete snapshot
Virsh snapshot-delete kvm1 snap1
-- restore snapshot Times error: error: revert requires force: Target controller type ide does not match source usb
Indicates that the kvm cannot be restored online and the virtual machine needs to be shut down before the snapshot is restored. If you want to restore the snapshot online, you need to add a parameter-- force.
It is written as follows:
Virsh snapshot-revert kvm1 snap1-force
It takes a long time to restore the snapshot. After the recovery, there will be some problems with the keyboard operation. You can restart it.
Virsh destroy kvm1
Virsh start kvm1
=
Exercise, prepare a new kvm virtual machine in qcow2 format, install the operating system (and do basic optimization, with yum, turn off iptables and selinux, etc.), and take a snapshot. If you want to use multiple sets in the future, you can clone them according to this one.
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.