CentOS 6.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  ]

CentOS 6.5下安装Open vSwitch

# 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"

CentOS 6.5下安装Open vSwitch

在KVM中使用OVS

# 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

CentOS 6.5下安装Open vSwitch

CentOS 6.5下安装Open vSwitch

CentOS 6.5下安装Open vSwitch

virsh # edit centos65

增加

<interface type='bridge'>

<source bridge='br0'/>

<virtualport type='openvswitch' />

<model type='virtio'/>

</interface>

virsh # start centos65

CentOS 6.5下安装Open vSwitch

配置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

相关推荐