ubuntu14.04
.安装kvm
apt-get install qemu-kvm libvirt0 virtinst bridge-utils virt-viewer
.配置实体机网络
cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
address 10.0.*.*
netmask 255.255.0.0
gateway 10.1.0.1
type bridge
bridge_ports eth0
dns-nameservers 114.114.114.114
.创建一个虚拟机
virt-install --connect qemu:///system -n test01 -r 1024 -f /home/kvm/test01.qcow2 -s 20 -c /home/kvm/ubuntu-12.04.1-server-amd64.iso --vnc --noautoconsole --os-type linux --os-variant ubuntuPrecise --accelerate --network=bridge:br0
centos7
.安装kvm
yum install qemu-kvm libvirt virt-install bridge-utils
.配置实体机网络
cat ifcfg-enp7s0
DEVICE="enp7s0"
ONBOOT=yes
BOOTPROTO=static
UUID=96a09db3-9b06-4a50-8d0c-9868cf531b84
#HWADDR="08:60:6E:06:C7:1A"
TYPE=Ethernet
BRIDGE=br0
IPADDR=0.0.0.0
cat ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=static
TYPE=Bridge
IPADDR=10.1.*.*
PREFIX=16
GATEWAY=10.1.0.1
DNS1=223.5.5.5
查看 brctl show
.启动 libvirt
systemctl start libvirtd
systemctl enable libvirtd
.创建虚拟机
virt-install --virt-type kvm --name test01 --ram 1024 --vcpus 1
--cdrom=/home/kvm/CentOS-7.0-1406-x86_64-DVD.iso --disk
path=/home/kvm/test01.qcow2,size=10,format=qcow2 --network bridge=br0
--graphics vnc,listen=0.0.0.0 --noautoconsole --os-type=linux
--os-variant=rhel7
.连接道virth
virsh --connect qemu:///system
.virt-viewer
连接本机的虚拟机:virt-viewer -c qemu:///system 虚拟机名
连接远程的虚拟机:virt-viewer -c qemu+ssh://ip/system 虚拟机名
设置开机自启动 virsh autostart server01