1. KVM Related Software Installation
The code is as follows |
Copy Code |
sudo apt-get install QEMU-KVM libvirt-bin virt-manager bridge-utils
|
2, Bridge Network configuration
sudo vim/etc/network/interfaces edit the configuration file and modify the IP network information as follows:
The code is as follows |
Copy Code |
Auto Lo Iface Lo inet Loopback Auto Eth0 Iface eth0 inet Manual Auto Br0 Iface br0 inet Static Address 192.168.10.130 Network 192.168.10.0 Netmask 255.255.255.0 Broadcast 192.168.10.255 Gateway 192.168.10.1 Dns-nameservers 8.8.8.8 Bridge_ports eth0 BRIDGE_STP off BRIDGE_FD 0 Bridge_maxwait 0
|
The above IP according to their actual need to modify, if the network environment is DHCP access (in the production environment is rarely used, this also mentioned), you can modify the code as follows:
The code is as follows |
Copy Code |
Auto Lo Iface Lo inet Loopback Auto Eth0 Iface eth0 inet Manual Auto Br0 Iface br0 inet DHCP Bridge_ports eth0 BRIDGE_STP off BRIDGE_FD 0
|
Finally: sudo/etc/init.d/networking Restart restart the network service.
3. Route forwarding
Routing forwarding is used in NAT network, but I find that the KVM is installed in Ubuntu, and the default is to turn on the routing forwarding function, if it is not modified by the SYSCTL command.
The code is as follows |
Copy Code |
yang@yang-acer:/opt$ sudo sysctl-a|grep ' net.ipv4.ip_forward ' Net.ipv4.ip_forward = 1
|
4, qemu.conf and iptables
Edit/etc/libvirt/qemu.conf file, cancel Vnc_listen = "0.0.0.0" annotation, turn on VNC function, and sudo/etc/init.d/libvirt-bin Restart load new configuration, If the firewall is turned on, you also need to open the port through the following instructions:
The code is as follows |
Copy Code |
sudo iptables-a input-m tcp-p tcp--dport 5910-j ACCEPT
|
Note: On Ubuntu iptables Unlike CentOS, you can also use the UFW firewall configuration policy.
5, the guest host installation
To create a mirrored file and view file information:
The code is as follows |
Copy Code |
sudo qemu-img create-f qcow2-o preallocation=metadata centos.img 20G QEMU-IMG Info centos.img
|
Install guest host system with VNC:
The code is as follows |
Copy Code |
sudo virt-install--name centos--ram=1024--arch=x86_64--vcpus=1--os-variant=rhel6--disk path=/opt/centos.img,bus= Virtio,cache=none,format=qcow2--network bridge=br0,model=virtio--graphics vnc,password=361way,port=5913--cdrom=/ Opt/centos-6.5-x86_64-livecd.iso
|
Note: Here directly specify the QCOW2 format, and not the same as before, mirror file creation must also specify the Preallocation (pre-allocation) environment, or you can not directly format=qcow2 format installation.