1. Configure the bridge br0
2. Restart the network
3. View Network Connections
4. Check whether ip Forwarding is enabled.
5. Install virtual machinesvirt-install --name=tomcat_01 --ram 8192 --vcpus=2 /--disk path=/var/lib/libvirt/images/tomcat_01.img,size=20,format=raw,bus=virtio /--cdrom /var/iso/CentOS-6.7-x86_64-minimal.iso --network bridge=br0,model=virtio /--vnc --accelerate --force --autostart
Here we will explain the meanings of the main parameters:
-- Name indicates the Virtual Machine name -- Memory allocated to the Virtual Machine by ram, in MB -- number of CPUs allocated to the Virtual Machine by vcpus -- cdrom specifies the full path of the installation file -- disk specifies the imgfile path of the virtual machine, if the virtual machine uses the lvm partition, the size of the Virtual Machine file will be directed to the lvm partition here. The unit is the bus type used by the GB bus Virtual Machine disk. In order to make the Virtual Machine achieve good performance, here we use the cache type of the virtio cache Virtual Machine disk -- network bridge to specify the bridge Nic model Nic mode. Here we also use virtio -- graphics parameters with better performance.
Here, the name of the virtual machine I installed is tomcat_01. Next, check its vnc Port:
ps aux | grep qemu | grep tomcat_01
At that time, we set the minimum vnc port to 5900, Which is 5902.
Next, use vnc-viewer in windows to connect to 172.16.57.24: 5902, and enter the set password to install it.
Common Operations1. Host Machine Management VM
To switch and manage a virtual machine, you need to install acpid service on the Virtual Machine and start it.
2. clone a VM
Generally, a common Virtual Machine template is created. you can clone the template directly next time you install the template.
Virt-clone -- connect qemu: /// system -- original = tomcat_01 -- name = tomcat_02 -- file = // var/lib/libvirt/images/tomcat_02.img -- virtual machine object cloned by original -- name new Virtual Machine name cloned by name
3. Add a disk
Generally, the disk structure of a virtual machine adds a data disk to the system disk. When the system fails, you can create a new system disk without losing the data disk.
Add disk operation:
Cd/var/lib/libvirt/images/enter the disk storage directory qemu-img create-f raw test_add.img 100G to create a G disk virsh attach-disk tomcat_01/var/lib/libvirt /images/test_add.img vdb -- cache none Dynamic Disk Addition
This method dynamically adds disks, but the xml configuration file does not change. To prevent the disk to be added from being invalid at the next startup, perform the following operations:
Virsh dumpxml tomcat_01> tomcat_01.xml redirects the latest virtual machine configuration to its configuration file virsh define tomcat_01.xml
In this way, the new disk will not be lost.
4. operations on the virsh command
Autostart automatically starts a domain Create to Create a domain Define from an XML file and defines it from an XML file (but does not start) edit a domain to edit the XML configuration of a domain shutdown to close the start of a domain (previously defined) inactive domain reboot restart a domain suspend a domain resume a domain vncdisplay vnc display
From: http://www.linuxeye.com/Linux/2897.html
Address: http://www.linuxprobe.com/linux-command-kvm.html