环境:centos6.4  

eth0--->接公司网络,用于远程连接操作

eth1--->接adsl拨号,单号多拨

kvm安装

yum install kvm virt-manager libvirt libvirt-python python-virtinst libvirt-client virt-viewer -y

启动libvirtd服务

service libvirtd start

检查是否安装kvm

lsmod | grep kvm

kvm_intel              45674  0

kvm                   291811  1 kvm_intel

配置桥接网络br0

vim /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE="br0"

ONBOOT=yes

TYPE=Bridge

BOOTPROTO=dhcp

STP=on

DELAY=0

配置eth1

vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

BOOTPROTO=none

ONBOOT=yes

BRIDGE=br0

NM_CONTROLLED="no"

配置eth0

DEVICE="eth0"

BOOTPROTO="static"

ONBOOT=yes

IPADDR=192.168.3.3

GATEWAY=192.168.3.254

HWADDR="00:25:90:AF:A0:28"

NM_CONTROLLED="no"

TYPE="Ethernet"

UUID="1e9d5a81-d216-4172-96ec-edffb99427f7"

更改img存放路径

查看卷的信息

virsh vol-info --pool kvm_p_w_picpathsguest1-rhel6.1

建立存储池的目录

mkdir /kvm/p_w_picpaths

定义一个存储池

virsh pool-define-as kvm_p_w_picpaths dir - - - - "/kvm/p_w_picpaths"

查看创建的存储池信息

virsh pool-list --all

使存储池生效

virsh pool-start kvm_p_w_picpaths

存储池自动运行

virsh pool-autostart kvm_p_w_picpaths

验证存储池

virsh pool-info kvm_p_w_picpaths

建立虚拟磁盘

virsh vol-create-as kvm_p_w_picpaths winser2010.img 50G --formatqcow2

命令创建虚拟机

virt-install --name winser2010 --ram 2048 --vcpus=1 --os-variant=win2k8 --accelerate --cdrom=/opt/iso/winser2010.iso --disk path=/kvm/p_w_picpaths/winser2010.img,size=10,format=qcow2,bus=virtio --bridge=br0,model=virtio --vnc --vncport=5991 --vnclisten=0.0.0.0