Install Open vSwitch on CentOS

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Install Open vSwitch on CentOS相关的知识,希望对你有一定的参考价值。

转载:http://cloud-mate.org/2015/06/installing-open-vswitch-centos-cloudstack/

Installing Open vSwitch on CentOS 6.6

I would like to use Open vSwitch on my KVM nodes in my CloudStack deployment. I will download and build the Open vSwitch rpms on my deployment server, which is just a CentOS VM which i use for deploying packages etc.

Create a directory to download the Open vSwitch tar to (You can find the most recent OVS here:http://openvswitch.org/download/):

cd ~
mkdir -p rpmbuild/SOURCES
wget http://openvswitch.org/releases/openvswitch–2.3.1.tar.gz

技术分享

tar xvfz openvswitch–2.3.1.tar.gz

技术分享

cd openvswitch–2.3.1/
cp ../openvswitch–2.3.1.tar.gz ~/rpmbuild/SOURCES/
cp rhel/openvswitch-kmod.files ~/rpmbuild/SOURCES/

技术分享

Then to build the rpms. This can take a few minutes:

rpmbuild -bb rhel/openvswitch.spec
rpmbuild -bb rhel/openvswitch-kmod-rhel6.spec

如果没有rpmbuild命令,则yum install rpm-build 安装

Now the rpms are sitting on my deployment server ready to be copied to my KVM nodes.

技术分享

Copy the Open vSwitch rpms to the KVM node, using SCP.

scp -r [email protected]:/root/rpmbuild/RPMS/x86_64 .

技术分享

Change directory to x86_64/ by
cd x86_64/

Then install kmod-openvswitch-2.3.1-1.el16.x86_64.rpm using
yum -y localinstall kmod-openvswitch-2.3.1-1.e16.x86_64.rpm

技术分享

Install openvswitch-2.3.1-1.x86_64.rpm using
yum -y localinstall openvswitch-2.3.1-1.x86_64.rpm

技术分享

Once both rpms are installed reboot the host. Then to verify openvswitch is installed run ovs-vsctl -V and ovs-vsctl show.

技术分享

Once verified that Open vSwitch is installed we need to configure the network interfaces for use with CloudStack (This KVM node has 4 physical network adapters but i am only configuring two:

rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
echo “DEVICE=eth0” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “BOOTPROTO=none” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “IPV6INIT=no” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “NM_CONTROLLED=no” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “ONBOOT=yes” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “TYPE=OVSPort” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “DEVICETYPE=ovs” >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo “OVS_BRIDGE=cloudbr0” >> /etc/sysconfig/network-scripts/ifcfg-eth0
rm -f /etc/sysconfig/network-scripts/ifcfg-eth1
echo “DEVICE=eth1” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “BOOTPROTO=none” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “IPV6INIT=no” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “NM_CONTROLLED=no” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “ONBOOT=yes” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “TYPE=OVSPort” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “DEVICETYPE=ovs” >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo “OVS_BRIDGE=cloudbr1” >> /etc/sysconfig/network-scripts/ifcfg-eth1
rm -f /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “DEVICE=cloudbr0” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “ONBOOT=yes” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “DEVICETYPE=ovs” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “TYPE=OVSBridge” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “BOOTPROTO=static” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “IPADDR=10.20.28.181” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “GATEWAY=10.20.28.254” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “NETMASK=255.255.255.0” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “DNS1=10.20.16.15” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “DNS2=10.20.16.16” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
echo “HOTPLUG=no” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr0
rm -f /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo “DEVICE=cloudbr1” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo “ONBOOT=yes” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo “DEVICETYPE=ovs” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo “TYPE=OVSBridge” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo “BOOTPROTO=none” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo “HOTPLUG=no” >> /etc/sysconfig/network-scripts/ifcfg-cloudbr1
echo ‘blacklist bridge’ >> /etc/modprobe.d/blacklist.conf
echo “network.bridge.type=openvswitch” >> /etc/cloudstack/agent/agent.properties
echo “libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.OvsVifDriver” >> /etc/cloudstack/agent/agent.properties

References:
https://cwiki.apache.org/confluence/display/CLOUDSTACK/KVM+with+OpenVSwitch

以上是关于Install Open vSwitch on CentOS的主要内容,如果未能解决你的问题,请参考以下文章

群辉开启open vswitch

Open vSwitch使用案例扩展实验

open vswitch

open vswitch

Open vSwitch

LXC 与 Open vSwitch