# yum install openssl-devel redhat-rpm-config kernel-devel -yhtml
#yum install kvm libvirt python-virtinst qemu-kvm virt-viewerpython
# wget http://openvswitch.org/releases/openvswitch-1.9.3.tar.gzlinux
#tar -zxf openvswitch-1.9.3.tar.gzcentos
# cd openvswitch-1.9.3app
# cp ../openvswitch-1.9.3.tar.gz ~/rpmbuild/SOURCES/dom
# cp rhel/openvswitch-kmod.files ~/rpmbuild/SOURCES/ui
# cp rhel/openvswitch.spec ~/rpmbuild/SPECS/url
# rpmbuild -ba ~/rpmbuild/SPECS/openvswitch.specspa
# cp rhel/openvswitch-kmod-rhel6.spec ~/rpmbuild/SPECS/命令行
# ls ~/rpmbuild/RPMS/x86_64/ |grep open
kmod-openvswitch-1.9.3-1.el6.x86_64.rpm
openvswitch-1.9.3-1.x86_64.rpm
openvswitch-debuginfo-1.9.3-1.x86_64.rpm
# rpm -ihv openvswitch-1.9.3-1.x86_64.rpm kmod-openvswitch-1.9.3-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:kmod-openvswitch ########################################### [ 50%]
WARNING: /lib/modules/2.6.32-431.el6.x86_64/weak-updates/openvswitch/brcompat.ko needs unknown symbol ovs_dp_ioctl_hook
2:openvswitch ########################################### [100%]
# virsh net-destroy default
# virsh net-autostart --disable default
# service openvswitch start
/etc/openvswitch/conf.db does not exist ... (warning).
Creating empty database /etc/openvswitch/conf.db [ OK ]
Starting ovsdb-server [ OK ]
Configuring Open vSwitch system IDs [ OK ]
Inserting openvswitch module [ OK ]
Starting ovs-vswitchd [ OK ]
Enabling gre with iptables [ OK ]
# ovs-vsctl add-br br0
/etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSBridge BOOTPROTO=static IPADDR=172.16.213.131 NETMASK=255.255.255.0 GATEWAY=172.16.213.2 HOTPLUG=no |
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSPort OVS_BRIDGE=br0 BOOTPROTO=none HOTPLUG=no |
# service network restart
# ovs-vsctl show
1bc18f94-0b5c-44c2-afd5-ac7d370499f1
Bridge "br0"
Port "eth0"
Interface "eth0"
Port "br0"
Interface "br0"
type: internal
ovs_version: "1.9.3"
# yum install bridge-utils tunctl
[root@yinye ~]# virt-install --name=centos65 --ram 512 --vcpus=1 -f /root/kvm/centos65.qcow2 --cdrom /root/CentOS-6.5-x86_64-minimal.iso --graphics vnc,listen=0.0.0.0,port=5920, --network bridge=br0
WARNING KVM acceleration not available, using 'qemu'
開始安裝......
ERROR Unable to add bridge br0 port vnet0: Operation not supported
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///system start centos65
otherwise, please restart your installation.
若是不在命令行指定bridge爲openvswitch類型 ,libvirt會嘗試linux默認的bridge,而virt-install又不支持openvswitch。
詳細參考
https://www.redhat.com/archives/libvirt-users/2013-May/msg00043.html
# virt-install --connect qemu:///system --name=centos65 --ram 512 --vcpus=1 -f /home/kvm/centos65.qcow2 --cdrom /home/kvm/CentOS-6.5-x86_64-minimal.iso --graphicsvnc,listen=0.0.0.0,port=5920, --nonetworks
virsh # edit centos65
增長
<interface type='bridge'> <source bridge='br0'/> <virtualport type='openvswitch' /> <model type='virtio'/> </interface> |
virsh # start centos65
配置guest os的網卡
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
HWADDR=52:54:00:D8:D7:FB
BOOTPROTO=dhcp
#ifup eth0
做者:YY哥
出處:http://www.cnblogs.com/hustcat/ 本文版權歸做者和博客園共有,歡迎轉載,但未經做者贊成必須保留此段聲明,且在文章頁面明顯位置給出原文鏈接,不然保留追究法律責任的權利。