openvswitch手动编译方法

手动编译

编译环境:Linux ubuntu 4.4.0-87-generic

编译安装

1
2
3
apt-get update
apt-get install -y dh-autoreconf libssl-dev libcap-ng-dev openssl python python-pip
pip install six
1
2
wget http://openvswitch.org/releases/openvswitch-2.7.0.tar.gz
tar zxvf openvswitch-2.7.0.tar.gz && cd openvswitch-2.7.0
1
2
3
4
5
./boot.sh
./configure --with-linux=/lib/modules/$(uname -r)/build
make -j
make install
make modules_install

加载启动服务

1
2
3
4
5
6
7
8
9
10
/sbin/modprobe openvswitch
mkdir -p /usr/local/etc/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
mkdir -p /usr/local/var/run/openvswitch
mkdir -p /usr/local/var/log/openvswitch
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach --log-file
ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --detach --log-file
export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl start

停止服务

1
2
3
kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl stop

开启服务

1
2
3
4
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach --log-file
ovs-vswitchd --pidfile --detach --log-file
export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl start

编译deb数据包

使用此方法在4.4.0-87-generic系统下编译openvswitch-2.6.1 、openvswitch-2.7.0和 openvswitch-2.8.0

1
2
3
4
5
apt-get install build-essential fakeroot
dpkg-checkbuilddeps
# 已经编译过,需要首先clean
# fakeroot debian/rules clean
DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary