Centos7.4安装openvswitch

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.4安装openvswitch相关的知识,希望对你有一定的参考价值。


    openvSwitch是一种基于开源Apache 2许可证的多层软件交换机。openvSwitch非常适合在VM环境中用作虚拟交换机。除了将标准控制和可视化接口暴露给虚拟网络层之外,它还旨在支持跨多个物理服务器的分发。Open vSwitch支持多种基于Linux的虚拟化技术,包括Xen / XenServer,KVM和VirtualBox。

    

     其主要组成部分是:

  • ovs-vswitchd,一个实现交换机的守护程序,以及用于基于流的切换的配套Linux内核模块。

  • ovsdb-server是一个轻量级数据库服务器,ovs-vswitchd查询以获取其配置。

  • 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相关的软件包


    [[email protected] ~]# cat /etc/redhat-release
    CentOS Linux release 7.4.1708 (Core)
    [[email protected] ~]# yum install gcc pkgconfig autoconf automake libtool  git make python-devel openssl-devel         kernel-devel kernel-debug-devel -y


    2.克隆openvswitch源


    [[email protected] ~]#  git clone https://github.com/openvswitch/ovs.git


   3.运行boot.sh以构建“configure”脚本


    [[email protected] ovs]# ./boot.sh


    4.编译并安装源码包


    [[email protected] ovs]# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc

    [[email protected] ovs]# ./configure CC=gcc

    [[email protected] 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

    我们把它的软连接删除,重新生成一个新的链接。

    [[email protected] 3.10.0-693.el7.x86_64]# rm build

    [[email protected] 3.10.0-693.el7.x86_64]# ln -s /usr/src/kernels/3.10.0-693.2.2.el7.x86_64/    build

    在执行以下刚才编译的命令。

    [[email protected] ovs]# make -j 4 && make install


    5.加载所需的内核模块


    [[email protected] ovs]# modprobe openvswitch
    [[email protected] ovs]# lsmod | grep openvswitch


    6.启动openvswitch相关应用程序


    [[email protected] ovs]# export PATH=$PATH:/usr/local/share/openvswitch/scripts
    [[email protected] ovs]# ovs-ctl start


   7.创建数据库


    [[email protected] ovs]# mkdir -p /usr/local/etc/openvswitch

    [[email protected] ovs]# ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema

    [[email protected] 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

    [[email protected] ovs]# ovs-vsctl --no-wait init
    [[email protected] ovs]# ovs-vswitchd --pidfile --detach --log-file
    

    8.创建br0


    [[email protected] ovs]# ovs-vsctl add-br br0 

    [[email protected] ovs]# ifconfig ens33 0 

    [[email protected] ovs]# ovs-vsctl add-port br0 ens33
    [[email protected] ovs]# ifconfig br0 192.168.3.101 netmask 255.255.255.0
    [[email protected] ovs]# route add default gw 192.168.3.1 br0 

    [[email protected] 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,UP,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,MULTICAST,UP,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,MULTICAST,UP,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

    [[email protected] 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"

    

    

    

    

    

    

    

  

   




    





本文出自 “若不奋斗,何以称王” 博客,请务必保留此出处http://wangzc.blog.51cto.com/12875919/1968227

以上是关于Centos7.4安装openvswitch的主要内容,如果未能解决你的问题,请参考以下文章

使用KickStart进行CentOS7.4 的自动部署安装

centos7.4安装oracle11.2.0.4

centos7.4安装oracle11.2.0.4

CentOS7.4 源码编译安装LNMP

在centos7.4上安装python2.6

阿里云centos7.4安装nexus