Tuesday, May 28, 2013

OpenStack中配置Floodlight作为网络后端插件

OpenStack中Quantum是网络部件,真正的网络逻辑功能则由各个后端插件完成。
下面讲使用Floodlight作为网络后端,该如何具体配置。


计算节点:配置ovs的控制器
首先所有的OpenvSwitch必须配置上控制器信息,可以在所有的nova-compute节点上利用如下的脚本来完成。
NETWORK_CONTROLERS=<comma-seperated-list-of-network-ctrls>
sudo ovs-vsctl \--no-wait \-\- \--if-exists del-br br-int
sudo ovs-vsctl \--no-wait add-br br-int
sudo ovs-vsctl \--no-wait br-set-external-id br-int bridge-id br-int
for ctrl in `echo ${NETWORK_CONTROLERS} \| tr ',' ' '`
do
 sudo ovs-vsctl set-controller br-int "tcp:${ctrl}:6633"
done
关闭quantum-plugin-openvswitch-agent服务。
service quantum-plugin-openvswitch-agent stop;
网络节点:关闭冲突的服务。
service quantum-l3-agent stop;
控制节点:创建数据库、安装新插件,更新quantumplugin配置
1、首先必须安装了MySQL,并创建restproxy_quantum表。
$ mysql -u root -p$PASS -e 'DROP DATABASE IF EXISTS restproxy_quantum;'
$ mysql -u root -p$PASS -e 'CREATE DATABASE IF NOT EXISTS restproxy_quantum;'
2、安装restproxy插件。
apt-get install quantum-plugin-bigswitch
3、编辑/etc/quantum/quantum.conf文件,修改core_plugin
[DEFAULT]
core_plugin = quantum.plugins.bigswitch.plugin.QuantumRestProxyV2
allow_overlapping_ips = False
lock_path = <path_to_which_quantum_process_can_write_to>
其中,lock_path仅在利用包安装的时候需要设置。当从devstack安装的时候,默认的lock_path值是允许的。
4、编辑修改/etc/default/quantum-server,修改QUANTUM_PLUGIN_CONFIG
QUANTUM_PLUGIN_CONFIG="/etc/quantum/plugins/bigswitch/restproxy.ini"
5、编辑/etc/quantum/plugins/bigswitch/restproxy.ini,设置为
[DATABASE]
sql_connection = mysql://<username>:<password>@<database_ip>:3306/restproxy_quantum?charset=utf8
[RESTPROXY]
servers=<controller_ip:port_num>,<controller_ip:port>
serverauth=<username>:<password>
serverssl=False
样例配置为
[DATABASE]
sql_connection = mysql://root:pass@127.0.0.1:3306/restproxy_quantum
[RESTPROXY]
servers=192.168.1.100:8080,192.168.1.101:8080
serverauth=user:pass
serverssl=False
修改完配置后关闭冲突的openvswitch-controller服务,并重启quantum-server服务。
service openvswitch-controller stop;
service quantum-server restart;
6、启动floodlight,可以查看计算节点上的ovs是否成功连接到floodlight
ant;
java -Dlogback.configurationFile=logback.xml -jar target/floodlight.jar -cf src/main/resources/quantum.properties



Monday, May 27, 2013

Ubuntu从源码安装/升级OpenvSwitch

Ubuntu从12.04开始已经自带了OpenvSwitch包,然而自带的包版本较低(1.4.0),如果想要尝试较新的版本,则需要进行手动安装。
需要注意ovs对linux kernel版本的要求。


 Open vSwitch   Linux kernel
   ------------   -------------
       1.4.x      2.6.18 to 3.2
       1.5.x      2.6.18 to 3.2
       1.6.x      2.6.18 to 3.2
       1.7.x      2.6.18 to 3.3
       1.8.x      2.6.18 to 3.4
       1.9.x      2.6.18 to 3.6

   Open vSwitch userspace should also work with the Linux kernel module
   built into Linux 3.3 and later.

   Open vSwitch userspace is not sensitive to the Linux kernel version.
   It should build against almost any kernel, certainly against 2.6.18
   and later.


apt-get update
apt-get install -y git python-simplejson python-qt4 python-twisted-conch automake autoconf gcc uml-utilities libtool build-essential git pkg-config libssl-dev

#Configure openvswitch
./boot.sh && ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --libdir=/usr/lib  --with-linux=/lib/modules/`uname -r`/build;

#modify utility/ovs-lib
mv utility/ovs-lib utility/ovs-lib.bak

#Compile and install openvswitch
make || print "make failed" && exit
sudo su;
make install;

 #should be the same already.
cp utility/ovs-lib /usr/share/openvswitch/scripts/


update system modules
rmmod bridge >/dev/null
rmmod openvswitch >/dev/null 2>&1
cp datapath/linux/openvswitch.ko /lib/modules/`uname -r`/updates/dkms/
cp datapath/linux/brcompat.ko /lib/modules/`uname -r`/updates/dkms/

insmod /lib/modules/`uname -r`/updates/dkms/openvswitch.ko || print "insmod failed, check dmesg" && exit
insmod /lib/modules/`uname -r`/updates/dkms/brcompat.ko || print "insmod failed, check dmesg" && exit

编辑/etc/default/openvswitch-switch中,开启brcompat。

service openvswitch-switch restart