OpenvSwitch概念:用作虚拟交换机,传递虚拟机VM之间的流量,以及实现VM和外界网络的通信。
OpenvSwitch数据路径需要桥接支持(CONFIG_BRIDGE)作为内核模块构建。(这在Linux发行版提供的内核中是常见的)桥接模块不能加载或使用。如果桥模块正在运行(使用“lsmod | grep bridge”进行检查),则在启动数据路径之前必须先删除它(“rmmod bridge”)。
安装openvswitch-2.5.0
安装依赖包:
yum -y install make gcc openssl-devel autoconf automake rpm-build redhat-rpm-config
yum -y install python-devel openssl-devel kernel-devel kernel-debug-devel libtool wget
预处理
mkdir -p ~/rpmbuild/SOURCES
wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz
cp openvswitch-2.5.0.tar.gz ~/rpmbuild/SOURCES/
tar xfz openvswitch-2.5.0.tar.gz
sed ‘s/openvswitch-kmod,
//g’ openvswitch-2.5.0/rhel/openvswitch.spec > openvswitch-2.5.0/rhel/openvswitch_no_kmod.spec
构建RPM包
rpmbuild -bb –nocheck~/openvswitch-2.5.0/rhel/openvswitch_no_kmod.spec
安装:
yum localinstall ~/ rpmbuild/RPMS/x86_64/openvswitch-2.5.0-1.x86_64.rpm
5.启动相关服务:
操作前先cd
cd ~
systemctl start openvswitch.service
如果需要使用openvswitch进行网络配置请看以下步骤:
配置openvswitch
注意:在禁用内核的bridge时候,要先禁止防火墙的开机启动。
centos7以后的版本为:
systemctl stop firewalld
systemctl disable firewalld
[root@localhost ~]# lsmod |grep bridge
bridge 119562 1 ebtable_broute
stp 12976 1 bridge
llc 14552 2 stp,bridge
此时可以发现已经有bridge启动了,执行rmmod bridge会报错
rmmod: ERROR: Module bridge is in use by: ebtable_broute
解决方法:
service etbales status
Redirecting to /bin/systemctl status ebtables.service
● ebtables.service - Ethernet Bridge Filtering tables
Loaded: loaded (/usr/lib/systemd/system/ebtables.service; disabled; vendor preset: disabled)
Active: inactive (dead)
发现ebtables.service 的路径
vim /usr/lib/systemd/system/ebtables.service
<