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 安装
※ openssl-devel is needed by openvswitch-2.5.0-1.x86_64,如果 没有openssl-devel,则yum install openssl-devel 安装
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 root@sgdeploy:/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
CentOS 7 – Installing Openvswitch 2.3.0 LTSCentOS 7 – Installing Openvswitch 2.3.0 LTS
https://n40lab.wordpress.com/2014/09/04/openvswitch-2-3-0-lts-and-centos-7/