2012年6月1日 星期五

How to Install OpenvSwitch for CentOS 6.x + Xen4.x

前一陣子在CentOS6.x + Xen 4.x 上安裝 OpenvSwitch 遇到許多問題,雖說網路上有許多安裝範例,但是真的很多都沒辦法使用,都會遇到一些問題,索性就把安裝Openvswitch 的指令寫成Script 有興趣的朋友可以參考看看。


#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Program:
# Install-openvSwitch.sh
#

if [ $UID != "0" ]; then
echo " You must be root to run the script or run it with sudo"
exit 1;
fi

if [ $# -lt 1 ]; then
echo " Usage: $0 "
echo " if src path in ~/ovs/ then =ovs "
echo " The script assumes the guest being clone is a Red Hat based system"
exit 1;
fi
INSTALLPATH=$1

pushd $INSTALLPATH

echo "Prepare need package......"
yum -y install tunctl

echo "Start download vswitch source......."
wget http://openvswitch.org/releases/openvswitch-1.3.0.tar.gz
tar zxvf openvswitch-1.3.0.tar.gz


pushd openvswitch-1.3.0/
./configure --with-linux=/lib/modules/`uname -r`/build 1>/dev/null 2>> $(errlog)
make 1>/dev/null 2>> $(errlog) && make install 1>/dev/null 2>> $(errlog)

#
#
#
rmmod bridge
insmod datapath/linux/openvswitch_mod.ko
virsh net-destroy default
virsh net-undefine default
service libvirtd restart


mkdir -p /usr/local/etc/openvswitch

ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,manager_options \
--private-key=db:SSL,private_key \
--certificate=db:SSL,certificate \
--bootstrap-ca-cert=db:SSL,ca_cert \
--pidfile --detach
ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --detach

沒有留言 :