快速安装OVN 和OVS

话不多说,直接上脚本

环境是linux debian 11

#!/usr/bin/env bash
#set -euo pipefail

set -eux
set -o pipefail


__DIR__=$(cd "$(dirname "$0")";pwd)
cd ${__DIR__}

prepare(){

  sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list
  sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list
  apt update -y

  apt install -y git curl python3 python3-pip python3-dev wget   sudo file
  apt install -y libssl-dev ca-certificates

  apt install -y  \
  git gcc clang make cmake autoconf automake openssl python3 python3-pip unbound libtool  \
  openssl netcat curl  graphviz libssl-dev  libcap-ng-dev uuid uuid-runtime
  apt install -y net-tools
  apt install -y kmod iptables

}
test $(dpkg-query -l graphviz | wc -l) -eq 0 && prepare

# 使用代理加速下载源码。假如你能流畅访问github,设置代理这一步,并不需要
proxy_server_url=http://192.168.3.26:8015
curl --proxy $proxy_server_url --head HEAD   https://github.com
code=$?
if  test $code -ne 0
then
  echo 'proxy is no running';
  exit 0;
fi

export no_proxy="localhost,127.0.0.0/8,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12"
export https_proxy=$proxy_server_url
export http_proxy=$proxy_server_url


cpu_nums=$(nproc)
cpu_nums=$(grep "processor" /proc/cpuinfo | sort -u | wc -l)

if test -d ovn
then
    cd ${__DIR__}/ovn/
    git   pull --depth=1 --progress --rebase
    cd ${__DIR__}/ovs/
    git   pull --depth=1 --progress --rebase
else
    git clone -b master https://github.com/openvswitch/ovs.git --depth=1 --progress
    git clone -b main https://github.com/ovn-org/ovn.git --depth=1 --progress
fi

cd ${__DIR__}/ovs/
./boot.sh
cd ${__DIR__}/ovs/


./configure --enable-ssl
make -j $cpu_nums
sudo make install

cd ${__DIR__}/ovn/

#test -d build &&  rm -rf build
#mkdir build
./boot.sh
cd ${__DIR__}/ovn/
./configure  --enable-ssl \
--with-ovs-source=${__DIR__}/ovs/ \
--with-ovs-build=${__DIR__}/ovs/

make -j $cpu_nums
sudo make install


cd ${__DIR__}
rm -rf ${__DIR__}/ovn
rm -rf ${__DIR__}/ovs


参考文档

  1. ovn source code
  2. ovs source code
  3. ovn-ovs-demo-in-container example

下一篇OVN启动 ovn-central 和 ovn-controller

posted @ 2022-08-11 10:34  jingjingxyk  阅读(466)  评论(0编辑  收藏  举报