backgroundBecause the server in the production environment does not install the desktop environment, a graphical installation of simple operations is not suitable for batch deployment installations. Therefore, I prefer to install the KVM virtual machine under the command. In combination with some information and personal use, I have outlined some basic and commonly used methods.
Installation Configuration
I. Introduction to the environmentOperating system: centos6.6 kernel Version: 2.6IP address: 172.16.57.24
Second, check the CPUUnlike Xen, KVM requires CPU support (Intel VT or AMD SVM) to check if the CPU provides virtual technology support before installing KVM
Egrep ' VMX|SVM '/proc/cpuinfo
Third, install the KVM1. Install some virtualized components here
Yum-y Install KVM python-virtinst libvirt bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v Libguestfs-tools-c
2, the following configuration for KVM:
Vim/etc/libvirt/libvirtd.conf Here is primarily the setting of the TCP connection at the end of the add as follows:
Listen_tls = 0listen_tcp = 1tcp_port = "16509" listen_addr = "172.16.57.24" unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0770" auth_tcp = "none" max_clients = 1024min_workers = 100max_workers = 200max_requests = 20max_client_requests = 50
Vim qemu.conf Here is primarily the setup of VNC, which is added at the end of the installation by Vnc-viewer connection
Vnc_listen = 0.0.0.0vnc_password = "Bigdata" #vnc连接密码remote_display_port_min = 5900 #vnc最小端口remote_display_port_ max = 65535 #vnc最大端口
3. Verify that the KVM installation is successful:
/ETC/INIT.D/LIBVIRTD restart
4. See if it starts:
Ps-ef | grep LIBVIRTD
5. Check if the KVM module is loaded properly:
Lsmod |grep KVM
Iv. Configuring Network Bridge Connectivity1, configure the bridge BR0
Vim/etc/sysconfig/network-scripts/ifcfg-br0
device=br0type=bridgeonboot=yesnm_controlled=yesbootproto=staticipaddr=172.16.57.24netmask= 255.255.255.0gateway=172.16.57.1dns1=202.96.209.133
Vim/etc/sysconfig/network-scripts/ifcfg-em1
Device=em1type=ethernetonboot=yesbridge=br0nm_controlled=yes
2. Restart the network
/etc/init.d/network restart
3. View Network Connections
Brctl Show If the configuration is successful, the following output will be available: Bridge Namebridge IDSTP Enabledinterfacesbr08000.14187745822enoem1vnet0vnet1vnet2vnet3vnet4vnet5vnet6virbr08000.5254005fcc0byesvirbr0-nic
4. Check if IP forwarding is turned on
cat/etc/sysctl.conf |grep Ip_forwardnet.ipv4.ip_forward = 1 if not enabled: vim/etc/sysctl.conf Modify Net.ipv4.ip_forward = 1/sbin/ Sysctl-p
v. Installation of virtual machines
Virt-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 is an explanation of the main parameter meanings:
--name give the virtual machine a name--ram the memory assigned to the virtual machine, the number of CPUs assigned to the virtual machine Mb--vcpus --cdrom The full path of the specified installation file--disk Specifies the virtual machine img file path, if the virtual machine uses LVM partitioning, this point points to the LVM partition on the line size of the virtual machine file sizes, the bus type used by the GB bus virtual machine disk, in order to achieve good performance of the virtual machine, Here you use the cache type of the Virtio cache virtual machine Disk--network Bridge to specify the bridging NIC model NIC mode, Here is also the use of better performance Virtio--graphics graphics parameters
Here I installed the virtual machine name tomcat_01, and then look at its VNC port:
PS aux | grep QEMU | grep tomcat_01
When we set the VNC port to a minimum of 5900, then this is the 5902 port. Next, you can install it by using Vnc-viewer in Windows to connect 172.16.57.24:5902 and entering a password for your settings.
Common Operations1, host management virtual machine to switch the virtual machine management, need to install Acpid service on the virtual machine, and start it. 2, cloning virtual machine general production of a common virtual machine template, the next installation can be directly to clone this template.
Virt-clone--connect qemu:///system--original=tomcat_01--name=tomcat_02--file=//var/lib/libvirt/images/tomcat_ 02.img--original cloned Virtual machine object--name clone of the new virtual machine name
3, add disk general virtual machine disk structure for the system disk plus data disk, when the system fails, you can re-build a system disk, and data disk will not be lost. To add a disk operation:
cd/var/lib/libvirt/images/into disk storage directory Qemu-img create-f Raw test_add.img 100G Create a 100G disk Virsh attach-disk tomcat_01/var/ Lib/libvirt/images/test_add.img VDB--cache None Dynamic Add disk
This method is to dynamically add the disk, and the XML configuration file does not change, in order to prevent the next startup of the added disk failure, do the following:
Virsh dumpxml tomcat_01 > Tomcat_01.xml redirect the latest virtual machine configuration to its configuration file Virsh define Tomcat_01.xml
This way, the new disk will not be lost. 4. Some operations of the Virsh command
Autostart automatically starts a domain create a domain from an XML file Define definition from an XML file (but does not start) a domain edit edit the XML configuration of a domain shutdown close a domain start one (formerly defined) non- Active domain reboot Restart a domain suspend suspend a domain resume redo a domain vncdisplay VNC display
Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/
Installation configuration and basic usage of Linux command-line KVM virtual machine