本文最后更新于331天前,其中的信息可能已经有所发展或是发生改变。
在ovs学习过程中,如果自己想要安装一个ovs交换机其实一条简单的命令 apt install openvswitch 就可以了,但是这种方法只能安装低版本的ovs。在特殊情况下需要安装指定版本,例如需要下发meters表时需要ovs2.8以上的版本,那么就需要下载安装包手动安装。看似一个复杂的过程,其实也是比较简单的。下面就一起来看看如果手动安装一个指定版本ovs交换机。
准备工作
安装python
apt install python

安装python-pip
如果不安装pip,在下面的过程会报错找不到six模块。
apt install python-pip

安装步骤
我们根据ovs的官方网站 http://www.openvswitch.org/ 的指导文档来一步一步的完成安装。

1.下载指定版本,可以看到这种安装的好处是你可以指定任何一种版本,不会被apt的安装方式限制了版本号。
http://www.openvswitch.org/download/


2.生成makefile文件



3.make 编译文件



4.make install 安装


5.检查模块
如果在安装的过程中生成了修改了内核模块,那么重新编译内核。

make modules_install

6.载入模块,载入openvswitch的模块到内核中

/sbin/modprobe openvswitch


7.启动

export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl start

8.启动ovsdb-server服务

export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl --no-ovs-vswitchd start

9.启动ovs-vswitchd服务

export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl --no--ovsdb-server start

10.配置ovsdb的数据库

mkdir -p /usr/local/etc/openvswitch ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema

11. 配置ovsdb-server以使用上面创建的数据库,监听Unix域套接字

mkdir -p /usr/local/var/run/openvswitch ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --pidfile --detach --log-file

12.使用ovs-vsctl初始化数据库
启动主Open vSwitch守护进程

ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --detach --log-file

接下来就可以使用了,使用ovs-vsctl show命令,查看ovs的版本号。

提供一个一次性执行完成的多行命令:
./configure make make install make modules_install /sbin/modprobe openvswitch export PATH=$PATH:/usr/local/share/openvswitch/scripts ovs-ctl start export PATH=$PATH:/usr/local/share/openvswitch/scripts ovs-ctl --no-ovs-vswitchd start export PATH=$PATH:/usr/local/share/openvswitch/scripts ovs-ctl --no--ovsdb-server start 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 ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --pidfile --detach --log-file ovs-vsctl --no-wait init ovs-vswitchd --pidfile --detach --log-file
点击数:6