Create a VM in kvm
Background Environment: Minimize installed cenots 6.x 1. install the required component yum-y groupinstall 'virtualization ization' 'virtualization alization client''' Virtualization Platform ''virtualization alization Tools ''2. verify if the installation is successful after installation. lsmod | grep kvm PS: Sometimes you need to enable cpu Virtualization in bios. after completing the preceding two steps, use virt-install for installation. For example: virt-install -- connect = qemu: // system-n test [-B br0] -- vcpus 2-r 2048-f/dev/vgroup0/lv02-l/opt/software/rhel-server-6.5-x86_64-dvd.iso (-- extra-args console = ttyS0) -- nographics (added in parentheses for text installation on the kvm platform; otherwise, process information will not be visible at the beginning of installation) Common commands for virsh
Virsh list -- all (list all clients) virsh console name (connect to client console port) destroy force stop reboot restart reset power-off restart restore resume save shutdown start suspend setmaxmem reset maximum memory setmem reset memory setvcpus reset CPU count undefine delete a virtual machine virt-install parameter: required information: -- name = name vm name -- ram = memory cpu usage option: -- vcpus 5, maxcpus = 10 cpu count -- cpuset = CPUSET cpu type -- CPU = CPU cpu mode -- description = DESCRIPTION description remarks startup options: -- location = LOCATION installation file path -- pxe network startup -- import ?? ? -- Init = INIT ??? -- Extra-args = EXTRA Option System option added to the kernel: -- OS-type = [linux | unix | windows} -- OS-variant = DISTRO_VARIANT other options: -- filesystem = filesystems vm storage settings, which can be files or lvm volumes -- network = NETWORK network settings -- graphics = [vnc | none | spice] display settings
4. kvm can use multiple types of disk files as local disks. lvm partition example: lvcreate-L 100G-n lv01 vgroup01 virt-install -- connect = qemu: // system -- name = test -- ram = 2048 -- network bridge = br0 -- vcpus 2-f/dev/vgroup0/lv02-l/opt/software/rhel-server-6.5-x86_64-dvd.iso -- extra-args console = ttyS0 -- graphics = none -- description = tsest B. use the raw image file virt-install -- connect = qemu: // system -- name = 10.20 -- ram = 1024 -- network bridge = br0 -- vcpus 2 -- Disk =/vm/servers/10.20, size = 80-l/opt/software/CentOS-6.5-x86_64-minimal.iso -- extra-args console = ttyS0 -- graphics = none -- description = nginx 5. if the NIC Mode Supported by kvm is not explicitly specified during installation, virbr0 created by libvirt is used as the virtual mesh bridge by default, and the Internet is accessed through the shared host network through nat; you can use the network parameter to specify the bridge mode and the bridge used.