ovn-org / ovn

Open Virtual Network
Apache License 2.0
514 stars 254 forks source link

How can I install ovn from source and install ovs from package? #197

Open ExploreScience opened 1 year ago

ExploreScience commented 1 year ago

I have installed ovs from package. Now, I want to install ovn,but it needs to specify the location of the OVS source code using –with-ovs-source like "./configure --with-ovs-source=/path/to/ovs/source". In this situation, where is the location of the OVS source? image

dceara commented 1 year ago

When building OVN from sources (assuming it's from a git repo) you need to follow the steps here to checkout the right OVS submodule version and compile those sources: https://github.com/ovn-org/ovn/blob/main/Documentation/intro/install/general.rst#bootstrapping

In short:

git submodule update --init
pushd ovs
./boot.sh
./configure
make
popd

Then you can simply configure and make OVN:

./boot.sh && ./configure && make

Does this work for you @ExploreScience?

Regards, Dumitru

ExploreScience commented 1 year ago

Thank you so much for your reply and advice. @dceara

I think your advice is useful for installing OVS from packages. But what I want to know is how to install OVN from sources (a git repo) In the case of installing OVS from package (yum install openvswitch)? Or, if I have already installed ovs from the package, can I install OVS from the source again, specifying when compiling OVN to use the OVS installed from the source? Whether ovs installed from a package will conflict with ovs installed from a source in one computer?

Regards, ExploreScience

dceara commented 1 year ago

Installing OVN from sources doesn't require installing OVS from sources. The full steps are probably something like this:

git clone https://github.com/ovn-org/ovn
pushd ovn
git submodule update --init
# Compile OVS from submodule but don't install it, it's just for libs needed by OVN:
pushd ovs
./boot.sh && ./configure && make
popd

# Compile OVN from sources and use OVS libraries from submodule.
# At runtime the OVS binaries (ovs-vswitchd/ovsdb-server) installed from distribution packages will be used.
./boot.sh && ./configure && make
sudo make install
popd

At this point your distro's OVS binaries are untouched, they'll be used. And you compiled and installed OVN from upstream sources.

jingjingxyk commented 1 year ago

prepare

OS : debian 11

  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 g++ clang make cmake autoconf automake openssl python3 python3-pip unbound libtool  \
  openssl netcat curl  graphviz libssl-dev   uuid uuid-runtime
  apt install -y net-tools
  apt install -y kmod iptables

download source code


    git clone -b v3.1.1 https://github.com/openvswitch/ovs.git --depth=1 --progress
    git clone -b v23.06.0 https://github.com/ovn-org/ovn.git --depth=1 --progress

build ovs


cd ovs 
./boot.sh
./configure --enable-ssl
make -j  $(nproc)
sudo make install

build ovn


cd ovn 
./boot.sh

./configure  --enable-ssl  \
--with-ovs-source=../ovs/ \
--with-ovs-build=../ovs/

make -j `grep "processor" /proc/cpuinfo | sort -u | wc -l`
sudo make install

start ovn central

central IP 192.168.3.243

export PATH=$PATH:/usr/local/share/openvswitch/scripts
export PATH=$PATH:/usr/local/share/ovn/scripts

ovn-ctl start_northd 

ovn-nbctl set-connection ptcp:6641
ovn-sbctl set-connection ptcp:6642

ovn-nbctl show
ovn-sbctl show

sleep 2

netstat -antp | grep 6641
netstat -antp | grep 6642

start ovn-controller

export PATH=$PATH:/usr/local/share/openvswitch/scripts
export PATH=$PATH:/usr/local/share/ovn/scripts

CENTRAL_IP=192.168.3.243

EXTERNAL_IP="192.168.3.100"
LOCAL_IP="192.168.3.100"
ENCAP_TYPE=geneve
id_file=system-id.conf
test -s $id_file || cat /proc/sys/kernel/random/uuid > $id_file

chassis_name=$(cat $id_file)
ovs-ctl start --system-id=${chassis_name}

ovs-vsctl set Open_vSwitch . \
external_ids:ovn-encap-ip="$EXTERNAL_IP" \
external_ids:local_ip="$LOCAL_IP" \
external_ids:ovn-encap-type="$ENCAP_TYPE" \
external_ids:system-id=${chassis_name} \
external_ids:ovn-remote="tcp:${CENTRAL_IP}:6642"

ovn-ctl start_controller

ovs-vsctl --columns external_ids list open_vswitch