openvSwitch是一种基于开源Apache 2许可证的多层软件交换机。openvSwitch非常适合在VM环境中用作虚拟交换机。除了将标准控制和可视化接口暴露给虚拟网络层之外,它还旨在支持跨多个物理服务器的分发。Open vSwitch支持多种基于Linux的虚拟化技术,包括Xen / XenServer,KVM和VirtualBox。
其主要组成部分是:
ovs-vswitchd,一个实现交换机的守护程序,以及用于基于流的切换的配套Linux内核模块。
ovs-dpctl是配置交换机内核模块的工具。用于构建Citrix XenServer和Red Hat Enterprise Linux的RPM的脚本和规范。XenServer RPM允许将Open vSwitch安装在Citrix XenServer主机上,作为替代其交换机的附加功能。
ovs-vsctl,用于查询和更新ovs-vswitchd的配置的实用程序。
ovs-appctl,一个向运行Open vSwitch守护程序发送命令的实用程序。
1.安装openvswitch相关的软件包
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost ~]# yum install gcc pkgconfig autoconf automake libtool gitmake python-devel openssl-devel kernel-devel kernel-debug-devel -y
2.克隆openvswitch源
[root@localhost ~]# git clone https://github.com/openvswitch/ovs.git
3.运行boot.sh以构建“configure”脚本
[root@localhost ovs]# ./boot.sh
4.编译并安装源码包
[root@localhost ovs]# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
[root@localhost ovs]# ./configure CC=gcc
[root@localhost ovs]# ./configure --with-linux=/lib/modules/$(uname -r)/build
在这里安装报错了:configure: error: source dir /lib/modules/3.10.0-693.el7.x86_64/build doesn't exist
[root@localhost 3.10.0-693.el7.x86_64]# rm build
[root@localhost 3.10.0-693.el7.x86_64]# ln -s /usr/src/kernels/3.10.0-693.2.2.el7.x86_64/ build
在执行以下刚才编译的命令。
[root@localhost ovs]# make -j 4 && make install
5.加载所需的内核模块
[root@localhost ovs]# modprobe openvswitch
[root@localhost ovs]# lsmod | grep openvswitch
6.启动openvswitch相关应用程序
[root@localhost ovs]# export PATH=$PATH:/usr/local/share/openvswitch/scripts
[root@localhost ovs]# ovs-ctl start
7.创建数据库
[root@localhost ovs]# mkdir -p /usr/local/etc/openvswitch
[root@localhost ovs]# ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
[root@localhost ovs]# ovsdb-server /usr/local/etc/openvswitch/conf.db \
> --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 --log-file
[root@localhost ovs]# ovs-vsctl --no-wait init
[root@localhost ovs]# ovs-vswitchd --pidfile --detach --log-file
8.创建br0
[root@localhost ovs]# ovs-vsctl add-br br0
[root@localhost ovs]# ifconfig ens33 0
[root@localhost ovs]# ovs-vsctl add-port br0 ens33
[root@localhost ovs]# ifconfig br0 192.168.3.101 netmask 255.255.255.0
[root@localhost ovs]# route add default gw 192.168.3.1 br0
[root@localhost ovs]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
link/ether 00:0c:29:30:31:a1 brd ff:ff:ff:ff:ff:ff
inet6 fe80::99d:9685:6ef2:750c/64 scope link
valid_lft forever preferred_lft forever
3: ens34: <BROADCAST,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:30:31:ab brd ff:ff:ff:ff:ff:ff
inet 10.10.10.20/24 brd 10.10.10.255 scope global ens34
valid_lft forever preferred_lft forever
inet6 fe80::3133:4e5c:41dc:a507/64 scope link
valid_lft forever preferred_lft forever
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether fa:49:7c:ae:d8:c8 brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
link/ether 00:0c:29:30:31:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.101/24 brd 192.168.3.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe30:31a1/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ovs]# ovs-vsctl show ffad5abb-4aab-42e5-a6bc-29dd5fb86352 Bridge "br0" Port "br0" Interface "br0" type: internal Port "ens33" Interface "ens33" ovs_version: "2.8.90"
原文链接:https://www.f2er.com/centos/375766.html