Installing KVM virtualization on Linux Systems

Source: Internet
Author: User
Tags svm uuid

Installing KVM virtualization on Linux Systems

First CPU to support virtualization (Intel is Vmx,amd is SVM)
[Email protected] ~]# egrep ' (VMX|SVM) '--color/proc/cpuinfo
Make sure that VT is turned on in the BIOS, and if it cannot be installed there will be a hint that does not turn on the virtual Biso to open in the
Intel (R) Virtualization Tech [Enabled]


Install the virtualization suite, because the installation package is more, you should first configure the Yum library, and then use Yum to install the virtual-like four groups, finished loading can not be opened there may be you less package, check whether there is a typo.
[Email protected] ~]# Lang=en_us-utf8
[Email protected] ~]# yum-y groupinstall "Virtualization" "Virtualization Client" "Virtualization Platform" "Virtualiza tion Tools "
Start the service and set the service to run automatically after installation
[[email protected] ~]#/ETC/INIT.D/LIBVIRTD start
[Email protected] ~]# chkconfig LIBVIRTD on
Use Virt-manager to open the virtual manager (in the graphical desktop)
[Email protected] ~]# Virt-manager
Manually install the system yourself ...


Set up Host Network
[Email protected] ~]# cd/etc/sysconfig/network-scripts/
Establish a bridge network card, you can copy a network card file and then we will modify the content.
[email protected] network-scripts]# CP Ifcfg-eth0 IFCFG-BR0
[email protected] network-scripts]# cat Ifcfg-br0
Device=br0
Type=bridge//Connection type: Bridging
Onboot=yes
Nm_controlled=yes
Bootproto=none
ipaddr=172.30.6.149
PREFIX=24//Subnet mask
Arpcheck=no//Turn off ARP detection
[email protected] network-scripts]# cat Ifcfg-eth0
Device=eth0
hwaddr=00:0c:29:7e:df:4f
Type=ethernet
uuid=743094da-ab6c-406d-8238-a8e51be4a515
Onboot=yes
Nm_controlled=yes
Bootproto=none
BRIDGE=BR0//By BR0 net Mezzanine Bridge connection
If the NetworkManager service prevents the NIC from restarting, you can turn it off first
[[email protected] network-scripts]#/etc/init.d/networkmanager stop
[Email protected] network-scripts]# Chkconfig NetworkManager off
[Email protected] network-scripts]# service network restart
[Email protected] network-scripts]# Chkconfig Network on
[email protected] network-scripts]# reboot

KVM Virtual Machine Common Files
/var/lib/libvirt/images//Install KVM virtual machine default storage location
/etc/libvirt/qemu///KVM Virtual machine configuration file storage location

Manage commands
[[email protected] ~]# Virsh list//view open virtual machines
[[email protected] ~]# Virsh list--all//View all virtual machine lists
[[email protected] ~]# Virsh Version//view build number
[[email protected] ~]# Virsh start kvm_snap1//start KVM_SNAP1 virtual machine
[Email protected] ~]# Virsh create/etc/libvirt/qemu/kvm_snap1.xml
[Email protected] ~]#/etc/init.d/acpid restart
[Email protected] ~]# chkconfig acpid on
[[email protected] ~]# Virsh shutdown KVM_SNAP1//close KVM_SNAP1 virtual machine
[[email protected] ~]# Virsh destroy KVM_SNAP1//force shutdown KVM_SNAP1 Virtual machine
[[email protected] ~]# Virsh autostart kvm_snap1//Set KVM_SNAP1 self-boot
[[email protected] ~]# Virsh dumpxml kvm_snap1 > Kvm_snap1.xml//Export KVM_SNAP1 virtual machine configuration file
[[email protected] ~]# Virsh undefine kvm_snap1//Cancel KVM_SNAP1 definition
[[email protected] ~]# Virsh define Kvm_snap1.xml//Definition Kvm_snap1
[Email protected] ~]# Virsh dominfo kvm_snap1//Enumerate KVM_SNAP1 information
[[email protected] ~]# Virsh edit kvm_snap1//Edit KVM_SNAP1 configuration file

[[email protected] ~]# virt-clone-o rhel5.10-n rhel5.10-clone-f/data/images/rhel5.10-clone.img//Clone virtual machine
-o Specifies the template host
-N Specify clone virtual machine name
-F Specify clone out virtual machine storage location


Managing virtual host disks using LVM
1, creating the LV
[Email protected] ~]# Fdisk-l | Grep/dev/sda6
/dev/sda6 6170 39163 265015296 8e Linux LVM
[Email protected] ~]# Pvcreate/dev/sda6
[Email protected] ~]# vgextend Vg_data/dev/sda6
[Email protected] ~]# Vgdisplay | grep "Free PE"
Free Pe/size 12799/50.00 GiB
[Email protected] ~]# lvcreate-l 10g-n lv_kvm_node1 vg_data
2, using the created LV installation guest
[Email protected] ~]# virt-install \
--name kvm_node1 \//define Virtual machine name
--noautoconsole \//Use this option to specify that you do not automatically attempt to connect to the client console
--ram 1024 \//Specify virtual machine memory size, Unit m
--arch=x86_64 \//Specify CPU Architecture
--vcpus=1 \//Specify the number of virtual CPUs
--os-type=linux \//Specify installation system type
--OS-VARIANT=RHEL5 \//Specify a specific version
--HVM \//Using full virtualization
--accelerate \//Using the kernel acceleration function
--disk path=/dev/vg_data/lv_kvm_node1 \
--network bridge=br0 \
--location nfs:192.168.194.253:/var/ftp/pub/iso/redhat/5.9 \
--extra-args= "Ks=http://192.168.194.253/rhel-ks.cfg ip=192.168.194.10 netmask=255.255.255.0 gateway= 192.168.194.253 dns=192.168.194.253 Noipv6 "
3, set the template virtual machine, remove some personality information (in KVM_NODE1 operation)
[email protected] ~]# Touch/.unconfigured
4, Snapshot generation
LVM Snapshot
A snapshot is a record of the system information at that time, as if it were a photographic record. If there is any data change in the future, the original data is put into the snapshot area, and the area that is not changed is shared by the snapshot area and the file system.
Lvcreate-s-L 20g-n lv_node1/dev/vg_data/lv_data
[Email protected] ~]# lvcreate-s-n kvm_snap1-l 10g/dev/vg_data/lv_kvm_node1
5, defined to Virt-manager
[Email protected] ~]# Virsh dumpxml kvm_node1 >/root/kvm_snap1.xml
[Email protected] ~]# Uuidgen
d2d8fe52-d244-46e5-97fb-7da9440d785b
Modify the/root/kvm_snap1.xml file (name, UUID, disk location, MAC address, see figure.)
[Email protected] ~]# Virsh define/root/kvm_snap1.xml
6. Delete the virtual machine
[Email protected] ~]# Virsh undefine kvm_snap1


Managing KVM Virtual machine disks with Qcow2
Currently there are mainly those formats that are mirrored as virtual machines:
Raw default, snapshot not supported
Cow
Qcow
Performance of Qcow2 Qcow2 close to raw bare format
VMDK vmware Format
Vdi


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.