------------恢复内容开始------------
参考网址:https://docs.openvswitch.org/en/latest/intro/install/general/#installation-requirements
1、ubuntu 可以直接使用apt-get install openvswitch-switch openvswitch-common
2、在centos安装如下
#、yum -y install gcc pkgconfig autoconf automake libtool git make python39 openssl-devel kernel-devel kernel-debug-devel (python39 这个可以通过yum search python查看支持的版本)
以上这些软件必须要安装,要不然后续会存在问题
#、wget http://openvswitch.org/releases/openvswitch-2.16.1.tar.gz
第一种方法:
tar zxvf openvswitch-2.16.1.tar.gz
cd openvswitch-2.16.1
./boot.sh(如果第一步安装软件失败,这一步就会失败)
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
./configure CC=gcc
./configure --with-linux=/lib/modules/$(uname -r)/build(kernel support is limited to 5.8 and below,可以通过 cat /etc/redhat-releas查看,一般不需要执行)
make -j 4 && make install
modprobe openvswitch
lsmod | grep openvswitch
[root@localhost openvswitch-2.16.1]# lsmod | grep openvswitch
openvswitch 163840 0
nf_conncount 16384 1 openvswitch
nf_nat 45056 2 openvswitch,nft_chain_nat
nf_conntrack 172032 4 nf_nat,nft_ct,openvswitch,nf_conncount
nf_defrag_ipv6 20480 2 nf_conntrack,openvswitch
libcrc32c 16384 4 nf_conntrack,nf_nat,openvswitch,xf
第二种方法:(未有机会验证)
#mkdir -p ~/rpmbuild/SOURCES
#cp openvswitch-2.16.1.tar.gz ~/rpmbuild/SOURCES/
#tar xfz openvswitch-2.16.1.tar.gz
#sed 's/openvswitch-kmod, //g' openvswitch-2.16.1/rhel/openvswitch.spec > openvswitch-2.16.1/rhel/openvswitch_no_kmod.spec
Build RPM: #rpmbuild -bb --nocheck ~/openvswitch-2.5.1/rhel/openvswitch_no_kmod.spec
安装RPM:
#ls -l ~/rpmbuild/RPMS/x86_64/
#yum localinstall ~/rpmbuild/RPMS/x86_64/openvswitch-2.5.1-1.x86_64.rpm
Start the OVS service and enable it for the next boot
安装后设置:
# mkdir -p /etc/openvswitch
# ovsdb-tool create /etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
安装Policycoreutils:
#yum install policycoreutils-python.x86_64 0:2.2.5-11.el7
#restorecon -Rv /etc/openvswitch
启动 OVS:
#systemctl start openvswitch.service
#systemctl -l status openvswitch.service
ovs已经安装完成
启动ovs
rm -rf /etc/openvswitch/
rm -rf /var/run/openvswitch
rm -rf /var/log/openvswitch
mkdir -p /etc/openvswitch
mkdir -p /var/run/openvswitch
mkdir -p /var/log/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema(vswitch.ovsschema可以通过 find / -name vswitch.ovsschema查看目录,也可以自己指定,但是要将vswitch.ovsschema拷贝到对应目录或自己创建该文件)
ovsdb-server --remote=punix:/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 (此处可能存在open目录失败或目录找不到的情况,创建目录就可以)
ovs-vsctl --no-wait init
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-extra="--iova-mode=pa"
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
ovs-vswitchd unix:/var/run/openvswitch/db.sock --pidfile --detach --log-file
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem="1024,0"
ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=${core_mask}
ovs-vsctl add-br br-ext -- set bridge br-ext datapath_type=netdev -- br-set-external-id br-ext bridge-id br-ext -- set bridge br-ext fail-mode=standalone
------------恢复内容结束------------