~~~~~ KVM virtualization ~~~~~, Kvm Virtualization
KVM Virtualization
To use KVM, a graphical system must be installed in the system environment.
1. Check whether the machine supports virtualization.
View Intel CPU: cat/proc/cpuinfo | grep -- color vmx
View amd cpu: cat/proc/cpuinfo | grep -- color svm
Such as Intel CPU
Supports virtualized
2. Install the KVM Module
[Root @ localhost ~] # Yum-y install kvm virt-manager libvirt virt-viewer
Kvm: KVM virtualization Module
Virt-manager: KVM graphical management tool
Libvirt: virtualization Service
Virt-viewer: Minimum tool for displaying the graphical console of a Virtual Machine
1) Start the KVM Service
[Root @ localhost ~] # Service libmongod start
2) Set auto-start upon startup
[Root @ localhost ~] # Chkconfig libmongod on
3) confirm correct loading of the kvm Module
[Root @ localhost ~] # Lsmod | grep kvm
4) Check whether KVM is successfully installed. Run the virsh command to check the status of the VM.
[Root @ localhost ~] # Virsh list
3. Configure the KVM bridging function
Bridge Introduction: the Bridge device we often call is actually a Bridge device, which is equivalent to the current L2 Switch used to connect all machines in the same network segment, so our goal is to add the network device eth0 to br0. At this time, br0 becomes a so-called switch device, and the eth0 of our physical machine is also connected to the above.
1) Installation Package
[Root @ localhost ~] # Rpm-ivh/mnt/Packages/bridge-utils-1.2-10.el6.x86_64.rpm
2) bind eth0 to the br0 bridge device:
[Root @ localhost ~] # Cd/etc/sysconfig/network-scripts/
# Back up eth0
[Root @ localhost network-scripts] # cp ifcfg-eth0/tmp/
# Edit the configuration file as follows:
[Root @ localhost network-scripts] # vim ifcfg-eth0.
DEVICE = eth0
NM_CONTROLLED = yes
IPADDR = 192.168.200.111 # Delete the blue content.
NETMASK = 255.255.255.0
GATEWAY = 192.168.200.1
DNS1 = 192.168.200.1
ONBOOT = yes
TYPE = Ethernet
BOOTPROTO = none
IPV6INIT = no
USERCTL = no
PREFIX = 24
DEFROUTE = yes
20174_failure_fatal = yes
NAME = "eth0"
HWADDR = 00: 0C: 29: 12: EC: 1E
BRIDGE = "br0" # insert this line at the end of the file
3) create a bridge File
[Root @ localhost network-scripts] # cp ifcfg-eth0 ifcfg-br0
DEVICE = br0
NM_CONTROLLED = yes
ONBOOT = yes
IPADDR = 192.168.200.111
NETMASK = 255.255.255.0
GATEWAY = 192.168.200.1
DNS1 = 192.168.200.1
BOOTPROTO = none
TYPE = Bridge
IPV6INIT = no
USERCTL = no
Disable NetworkManager after configuration, and then restart the NIC
[Root @ localhost ~] # Service NetworkManager stop
[Root @ localhost ~] # Service network restart
Check the IP address
Upload the image file to the/var/lib/libvirt/images/directory.
Start Remote Desktop
You can use the vnc software to remotely connect to the server.
View bridging information:
[Root @ localhost ~] # Brctl show
Open the virtual terminal manager in VNC
[Root @ localhost ~] # Virt-manager
Right-click Create VM
Select the image path and installation version
Set the memory size and number of CPUs, which is similar to that installed in VMware.
Click Finish to create the virtual system.
The right side is the same as installing the system.
Virtual Machine installation completed
Virtual Machine Configuration
Common commands for KVM virtual machines
[Root @ localhost ~] # Virsh list # show only running virtual machines
[Root @ localhost ~] # Virsh list -- all # display all virtual machines, including virtual machines in disabled state
[Root @ localhost ~] # Virsh start server1 # start the strongserver Virtual Machine
[Root @ localhost ~] # Virsh shutdown server # Shut down the server Virtual Machine
Solve the problem that shutdown cannot shut down the KVM Virtual Machine
Install and start the acpi service in the Linux virtual machine of the installed KVM. The virsh shutdown command controls the power of the Virtual Machine by sending the acpi command, the acpi service is not installed by default when the kvm virtual machine is installed on the linux system, so it will not be processed.
Solution: you only need to install and enable the acpid service on the Virtual Machine. Execute the following command:
Configure the network yum Source
Install the httpd service on a real machine
[Root @ localhost ~] # Yum-y install httpd
[Root @ localhost ~] # Service httpd start
[Root @ localhost ~] # Mount/dev/cdrom/var/www/html, on a real machine, you can directly upload the image to the machine and mount it to the corresponding directory .)
Configure the KVM yum Source
[Root @ localhost ~] # Ssh 192.168.200.112
[Root @ localhost ~] # Cd/etc/yum. repos. d/
[Root @ localhost yum. repos. d] # vim rhel-source.repo.
[Root @ localhost yum. repos. d] # yum list all
[Root @ localhost yum. repos. d] # yum-y install acpid
[Root @ localhost yum. repos. d] # service acpid start
[Root @ localhost yum. repos. d] # chkconfig acpid on
Test on a real machine
[Root @ localhost ~] # Virsh list # view the running server status
[Root @ localhost ~] # Virsh shutdown server1 # disable server1 VM
[Root @ localhost ~] # Virsh autostart server1 # Set server1 to automatically start after the host is started
[Root @ localhost ~] # Virsh list viewing disabled
Author: compy Date: QQ: 2071959367