“OpenvSwitch安装与操作(本地版)”的版本间的差异
(→下载源码包,并创建rpm包) |
(→挂载CentOS-7-x86_64-DVD-1511.iso) |
||
(未显示5个用户的12个中间版本) | |||
第1行: | 第1行: | ||
==系统环境== | ==系统环境== | ||
Centos 7.2,双网卡(NAT,仅主机) | Centos 7.2,双网卡(NAT,仅主机) | ||
+ | 虚拟化设置打开 | ||
+ | |||
+ | ==所需软件== | ||
+ | openvswitch-2.3.2.tar.gz | ||
+ | |||
+ | 或 wget http://openvswitch.org/releases/openvswitch-2.3.2.tar.gz | ||
− | |||
==OpenvSwitch安装== | ==OpenvSwitch安装== | ||
+ | |||
+ | ==挂载CentOS-7-x86_64-DVD-1511.iso== | ||
+ | |||
+ | [root@localhost ~]# mkdir /mnt/centos | ||
+ | |||
+ | [root@localhost ~]# mount -o loop /dev/sr0 /mnt/centos(此命令没有任何输出,如果有输出就说明发生了错误) | ||
+ | |||
+ | [root@localhost ~]# ls /mnt/centos | ||
+ | |||
+ | <nowiki>CentOS_BuildTag EULA images repodata RPM-GPG-KEY-CentOS-Testing-6 | ||
+ | |||
+ | EFI GPL isolinux Packages RPM-GPG-KEY-Centos-Debug-6 RPM-GPG-KEY-CentOS-6 TRANS.TBL</nowiki> | ||
+ | |||
+ | ==配置yum== | ||
+ | |||
+ | cd /etc/yum.repos.d | ||
+ | |||
+ | [root@localhost yum.repos.d]# vi local.repo | ||
+ | |||
+ | [centos] | ||
+ | |||
+ | name=centos | ||
+ | |||
+ | baseurl=file:///mnt/centos | ||
+ | |||
+ | gpgcheck=0 | ||
+ | |||
+ | enabled=1 | ||
+ | |||
+ | [root@localhost yum.repos.d]# yum repolist | ||
+ | |||
+ | <nowiki>Loaded plugins: fastestmirror, langpacks | ||
+ | Loading mirror speeds from cached hostfile | ||
+ | centos/primary_db | 2.8 MB 00:03 | ||
+ | repo id repo name status | ||
+ | centos centos 3,723 | ||
+ | repolist: 3,723</nowiki> | ||
===安装依赖软件包=== | ===安装依赖软件包=== | ||
第39行: | 第81行: | ||
[root@localhost ~]# getenforce | [root@localhost ~]# getenforce | ||
Permissive | Permissive | ||
− | |||
===启动服务,并查看ovs版本信息=== | ===启动服务,并查看ovs版本信息=== |
2019年5月30日 (四) 08:11的最新版本
系统环境
Centos 7.2,双网卡(NAT,仅主机) 虚拟化设置打开
所需软件
openvswitch-2.3.2.tar.gz
或 wget http://openvswitch.org/releases/openvswitch-2.3.2.tar.gz
OpenvSwitch安装
挂载CentOS-7-x86_64-DVD-1511.iso
[root@localhost ~]# mkdir /mnt/centos
[root@localhost ~]# mount -o loop /dev/sr0 /mnt/centos(此命令没有任何输出,如果有输出就说明发生了错误)
[root@localhost ~]# ls /mnt/centos
CentOS_BuildTag EULA images repodata RPM-GPG-KEY-CentOS-Testing-6 EFI GPL isolinux Packages RPM-GPG-KEY-Centos-Debug-6 RPM-GPG-KEY-CentOS-6 TRANS.TBL
配置yum
cd /etc/yum.repos.d
[root@localhost yum.repos.d]# vi local.repo
[centos]
name=centos
baseurl=file:///mnt/centos
gpgcheck=0
enabled=1
[root@localhost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile centos/primary_db | 2.8 MB 00:03 repo id repo name status centos centos 3,723 repolist: 3,723
安装依赖软件包
yum -y install wget gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool
创建普通用户ovs
adduser ovs
su - ovs
下载源码包,并创建rpm包
mkdir -p ~/rpmbuild/SOURCES
从本地上传openvswitch-2.3.2.tar.gz到Linux
cp openvswitch-2.3.2.tar.gz ~/rpmbuild/SOURCES/
tar xfz openvswitch-2.3.2.tar.gz
sed 's/openvswitch-kmod, //g' openvswitch-2.3.2/rhel/openvswitch.spec > openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec
rpmbuild -bb --nocheck openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec
exit
创建ovs配置目录,并安装制作好的rpm包
mkdir /etc/openvswitch
yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.3.2-1.x86_64.rpm
如果selinux开启,请执行如下操作,如未开启,请略过此步骤
[root@localhost ~]# sed -i 's/SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce Permissive
启动服务,并查看ovs版本信息
chkconfig openvswitch on
systemctl restart openvswitch.service
ovs-vsctl -V
ovs-vsctl (Open vSwitch) 2.3.2 Compiled Mar 23 2019 07:02:28 DB Schema 7.6.2
OpenvSwitch常用操作
添加网桥
添加一个网桥br0
ovs-vsctl add-br br0
列出网桥
列出OpenvSwitch中的所有网桥
ovs-vsctl list-br
br-ex br-int br0
添加端口(物理网卡)
将物理网卡 eno33554960(即段口)添加到网桥br0上
ovs-vsctl add-port br0 eno33554960
列出所有端口
列出br0网桥中的所有端口
ovs-vsctl list-ports br0
eno33554960
列出网桥列表
列出网卡eno33554960挂接到的网桥列表
ovs-vsctl port-to-br eno33554960
br0
查看Open vSwitch状态
查看Open vSwitch的网络状态
ovs-vsctl show
[root@localhost ~]# ovs-vsctl show 27727e54-922e-4735-93f4-0e59fef5d5fa Bridge "br0" Port "br0" Interface "br0" type: internal Port "eth1" Interface "eth1" Port "eno33554960" Interface "eno33554960" ovs_version: "2.3.2"
删除端口(物理网卡)
删除网桥br0上挂接的网卡eno33554960
ovs-vsctl del-port br0 eno33554960
ovs-vsctl list-ports br0
删除网桥
删除网桥br0
ovs-vsctl del-br br0
ovs-vsctl list-br
参考文档: