1. 程式人生 > >CentOS6.5下安裝Open vSwitch

CentOS6.5下安裝Open vSwitch

準備

yum install openssl-devel redhat-rpm-config kernel-devel -y

#yum install kvm libvirt python-virtinst qemu-kvm virt-viewer

編譯

wget http://openvswitch.org/releases/openvswitch-1.9.3.tar.gz

#tar -zxf openvswitch-1.9.3.tar.gz

# cd openvswitch-1.9.3

cp ../openvswitch-1.9.3.tar.gz ~/rpmbuild/SOURCES/

cp rhel/openvswitch-kmod.files ~/rpmbuild/SOURCES/

cp rhel/openvswitch.spec ~/rpmbuild/SPECS/

rpmbuild  -ba ~/rpmbuild/SPECS/openvswitch.spec

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%]

使用openvswitch

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  ]

NewImage

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"

NewImage

KVM中使用OVS

yum install bridge-utils tunctl

[[email protected] ~]# 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.

如果不在命令列指定bridgeopenvswitch型別libvirt會嘗試linux預設的bridge,而virt-install又不支援openvswitch

詳細參考

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

NewImage

NewImage

NewImage

virsh # edit centos65

增加

<interface type='bridge'>

 <source bridge='br0'/>

 <virtualport type='openvswitch' />

 <model type='virtio'/>

</interface>

virsh # start centos65

NewImage

配置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/
本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連線,否則保留追究法律責任的權利。