• Open vSwitch系列之二 安装指定版本ovs


    在ovs学习过程中,如果自己想要安装一个ovs交换机其实一条简单的命令 apt  install openvswitch 就可以了,但是这种方法只能安装低版本的ovs。在特殊情况下需要安装指定版本,例如需要下发meters表时需要ovs2.8以上的版本,那么就需要下载安装包手动安装。看似一个复杂的过程,其实也是比较简单的。下面就一起来看看如果手动安装一个指定版本ovs交换机。

    准备工作

    安装python

    [root@localhost ~]# yum -y install python

    安装python-pip

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

    [root@localhost ~]# yum -y install epel*
    [root@localhost ~]# yum -y install python-pip

    下载指定版本,可以看到这种安装的好处是你可以指定任何一种版本

    http://www.openvswitch.org/download/      #下载地址
    [root@localhost ~]# tar xf openvswitch-2.8.1.tar.gz 

    生成makefile文件

    [root@localhost ~]# cd openvswitch-2.8.1
    [root@localhost openvswitch-2.8.1]# yum -y install python-six
    [root@localhost openvswitch-2.8.1]# ./configure

    make 编译文件

    [root@localhost openvswitch-2.8.1]# make && make install

    .检查模块

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

    [root@localhost openvswitch-2.8.1]# make modules_install 
    make: 对“modules_install”无需做任何事。

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

    [root@localhost openvswitch-2.8.1]# /sbin/modprobe openvswitch
    [root@localhost openvswitch-2.8.1]# /sbin/lsmod |grep openvswitch
    openvswitch           106996  0 
    nf_nat_ipv6            14131  1 openvswitch
    nf_defrag_ipv6         35104  2 openvswitch,nf_conntrack_ipv6
    nf_nat_ipv4            14115  2 openvswitch,iptable_nat
    nf_nat                 26787  4 openvswitch,nf_nat_ipv4,nf_nat_ipv6,nf_nat_masquerade_ipv4
    nf_conntrack          133387  9 openvswitch,nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_netlink,nf_conntrack_ipv4,nf_conntrack_ipv6
    libcrc32c              12644  4 xfs,openvswitch,nf_nat,nf_conntrack

    启动

    [root@localhost openvswitch-2.8.1]# export PATH=$PATH:/usr/local/share/openvswitch/scripts
    [root@localhost openvswitch-2.8.1]# ovs-ctl start
    /usr/local/etc/openvswitch/conf.db does not exist ... (warning).
    Creating empty database /usr/local/etc/openvswitch/conf.db [  OK  ]
    Starting ovsdb-server [  OK  ]
    system ID not configured, please use --system-id ... failed!
    Configuring Open vSwitch system IDs [  OK  ]
    Starting ovs-vswitchd [  OK  ]
    Enabling remote OVSDB managers [  OK  ]

    启动ovsdb-server服务

    [root@localhost openvswitch-2.8.1]# export PATH=$PATH:/usr/local/share/openvswitch/scripts
    [root@localhost openvswitch-2.8.1]# ovs-ctl --no-ovs-vswitchd start
    ovsdb-server is already running.
    Enabling remote OVSDB managers [  OK  ]

    启动ovs-vswitchd服务

    [root@localhost openvswitch-2.8.1]# export PATH=$PATH:/usr/local/share/openvswitch/scripts
    [root@localhost openvswitch-2.8.1]# ovs-ctl --no--ovsdb-server start
    /usr/local/share/openvswitch/scripts/ovs-ctl: unknown option "--no--ovsdb-server" (use --help for help)
    ovsdb-server is already running.
    ovs-vswitchd is already running.
    Enabling remote OVSDB managers [  OK  ]

    配置ovsdb的数据库 

    [root@localhost openvswitch-2.8.1]# mkdir -p /usr/local/etc/openvswitch
    [root@localhost openvswitch-2.8.1]# ovs-ctl --no--ovsdb-server start
    /usr/local/share/openvswitch/scripts/ovs-ctl: unknown option "--no--ovsdb-server" (use --help for help)
    ovsdb-server is already running.
    ovs-vswitchd is already running.
    Enabling remote OVSDB managers [  OK  ]

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

    [root@localhost openvswitch-2.8.1]# mkdir -p /usr/local/var/run/openvswitch
    [root@localhost openvswitch-2.8.1]# 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
    2019-12-30T12:30:01Z|00001|vlog|INFO|opened log file /usr/local/var/log/openvswitch/ovsdb-server.log
    ovsdb-server: /usr/local/var/run/openvswitch/ovsdb-server.pid: already running as pid 45678, aborting

    使用ovs-vsctl初始化数据库

    [root@localhost openvswitch-2.8.1]# ovs-vsctl --no-wait init
    [root@localhost openvswitch-2.8.1]# ovs-vswitchd --pidfile --detach --log-file
    2019-12-30T12:31:39Z|00001|vlog|INFO|opened log file /usr/local/var/log/openvswitch/ovs-vswitchd.log
    ovs-vswitchd: /usr/local/var/run/openvswitch/ovs-vswitchd.pid: already running as pid 45688, aborting

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

    [root@localhost openvswitch-2.8.1]# ovs-vsctl show 
    b9da3f20-b407-40fa-8944-df970f4ca3ad
        ovs_version: "2.8.1"
  • 相关阅读:
    [buuctf] pwn-第五空间2019pwn
    [buuctf] pwn-[OGeek2019]babyrop
    [buuctf] pwn-ciscn_2019_c_1
    [buuctf] pwn-jarvisoj_level0
    wamp集成环境配置php7.x连接mssql
    EXCEL小技巧之单击单元格实现自增
    Asuhe博客转移
    数据链路层中的最小帧长是如何计算出来的?
    CSMA/CD协议中如何确定数据重传时机?
    Cache设计
  • 原文地址:https://www.cnblogs.com/liujunjun/p/12121579.html
Copyright © 2020-2023  润新知