CentOS 6 中安装Mininet + openswitch

Mininet 源代码包中的 install.sh脚本不支持 RHEL/CentOS,要手动解决一些列的琐碎问题,很麻烦。下面的方法用用于在 CentOS 6 中快速安装 Mininet 和 openvswitch 搭建SDN测试环境。

CentOS 版本为 6.3 64bit

1. 安装 Mininet

创建软件仓库配置文件: /etc/yum.repos.d/naulinux-extras.repo :

[naulinux-extras]
name=NauLinux Extras
baseurl=http://downloads.naulinux.ru/pub/NauLinux/6.2/$basearch/Extras/RPMS/
enabled=0
gpgcheck=1
gpgkey=http://downloads.naulinux.ru/pub/NauLinux/RPM-GPG-KEY-linux-ink

使用如下的命令安装 mininet :

# yum --enablerepo=naulinux-extras install mininet

提示找不到软件包,于是乎到 http://downloads.naulinux.ru/pub/NauLinux/6.2/SRPMS/NauLinux/ 看了一下,mininet软件包确实不在了。

于是参考 https://github.com/mininet/mininet/wiki/Mininet-Community-Extensions-and-Packages 发现 Mininet 的 RPM 包在 6.3 中按照项目名称进行了归类:

http://downloads.naulinux.ru/pub/NauLinux/6.3/x86_64/Extras/RPMS/Projects/OpenFlow/

OK,那就修改 repository 配置文件吧。

[naulinux-extras]
name=NauLinux Extras
baseurl=http://downloads.naulinux.ru/pub/NauLinux/6.3/$basearch/Extras/RPMS/
enabled=0
gpgcheck=1
gpgkey=http://downloads.naulinux.ru/pub/NauLinux/RPM-GPG-KEY-linux-ink

再次运行命令安装 mininet :

# yum --enablerepo=naulinux-extras install mininet

问题又来了,提示:

Package mininet-2.1.0-3.el6.x86_64.rpm is not signed

提示:没签名。那就不验证签名吧,使用如下命令安装:

yum --enablerepo=naulinux-extras --nogpgcheck install mininet

It’s OK! Yeah! :)

2.安装 openvswitch

细心的你应该会发现,http://downloads.naulinux.ru/pub/NauLinux/6.3/x86_64/Extras/RPMS/Projects/OpenFlow/ 下面也有 openvswitch 1.4.3 ,版本虽然有点老,it’s OK!

再次运行命令安装 mininet :

# yum --enablerepo=naulinux-extras install openvswitch
install openvswitch
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openvswitch.x86_64 0:1.4.3-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================
 Package                        Arch                      Version                         Repository                          Size
===================================================================================================================================
Installing:
 openvswitch                    x86_64                    1.4.3-2.el6                     naulinux-extras                    1.6 M

Transaction Summary
===================================================================================================================================
Install       1 Package(s)

Total download size: 1.6 M
Installed size: 5.1 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 1.6 M
openvswitch-1.4.3-2.el6.x86_64.rpm                                                                          | 1.6 MB     00:04     
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID fac8d3c0: NOKEY
Retrieving key from http://downloads.naulinux.ru/pub/NauLinux/RPM-GPG-KEY-linux-ink
Importing GPG key 0xFAC8D3C0:
 Userid: "Developer (Linux Ink. developers team) <devel@linux-ink.ru>"
 From  : http://downloads.naulinux.ru/pub/NauLinux/RPM-GPG-KEY-linux-ink
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : openvswitch-1.4.3-2.el6.x86_64                                                                                  1/1 
  Verifying  : openvswitch-1.4.3-2.el6.x86_64                                                                                  1/1 

Installed:
  openvswitch.x86_64 0:1.4.3-2.el6                                                                                                 

Complete!

3. 测试 Mininet + openvswitch 工作是否正常

用最简单的方法,在命令行直接运行 mn 命令,提示出错:

[root@localhost ~]# mn
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
May 18 10:05:20|00001|stream_unix|ERR|/tmp/stream-unix.26105.0: connection to /var/run/openvswitch/db.sock failed: No such file or directory
May 18 10:05:20|00002|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
May 18 10:05:21|00003|stream_unix|ERR|/tmp/stream-unix.26105.1: connection to /var/run/openvswitch/db.sock failed: No such file or directory
May 18 10:05:21|00004|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
ovs-vsctl exited with code -14
*** Error connecting to ovs-db with ovs-vsctl
Make sure that Open vSwitch is installed, that ovsdb-server is running, and that
"ovs-vsctl show" works correctly.
You may wish to try "service openvswitch-switch start".

要启动 openvswitch 服务:

# service openvswitch start

启动出错。

于是乎,卸载这个版本的 openvswitch

# rpm -e openswitch

4. 安装openvswitch最新版2.3.1

http://www.openswitch.org 下载最新的tar包,按照https://github.com/openvswitch/ovs/blob/master/INSTALL.RHEL.md 从源码编译 RPM 包。过程如下:

# cd
# yum install gcc make python-devel openssl-devel kernel-devel graphviz \
kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool
# wget http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz
# mkdir $HOME/rpmbuild/SOURCES
# cp openvswitch-2.3.1.tar.gz $HOME/rpmbuild/SOURCES
# cd
# tar zxvf openvswitch-2.3.1.tar.gz
# cd openvswitch-x.y.z
# rpmbuild -bb rhel/openvswitch.spec
# cp openvswitch-2.3.1/rhel/openvswitch-kmod.files $/HOME/rpmbuild/SOURCES
# rpmbuild -bb rhel/openvswitch-kmod-rhel6.spec

进入生成 RPM 的目录,yum localinstall * :

# pwd
/root/rpmbuild/RPMS/x86_64
# ls
kmod-openvswitch-2.3.1-1.el6.x86_64.rpm  openvswitch-2.3.1-1.x86_64.rpm  openvswitch-debuginfo-2.3.1-1.x86_64.rpm
# yum localinstall *

启动 openvswitch 服务,提示:

Inserting openvswitch module FATAL: Module openvswitch not found.

重启系统,openvswitch 已经设置为自动启动了,All OK! Yeah!

# service openvswitch status
ovsdb-server is running with pid 2740
ovs-vswitchd is running with pid 2751
# ovs-vsctl show
bfc56466-07ff-454a-9a31-7e293edd2369
ovs_version: "2.3.1"

5. 再次测试

首先启动 POX 控制器:

# ./pox.py log.level --DEBUG forwarding.l2_learning

启动 Mininet :

# mn --controller remote
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s1 
*** Adding links:
(h1, s1) (h2, s1) 
*** Configuring hosts
h1 h2 
*** Starting controller
*** Starting 1 switches
s1 
*** Starting CLI:
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=49.4 ms
^C
--- 10.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 861ms
rtt min/avg/max/mdev = 49.400/49.400/49.400/0.000 ms
mininet> 

总算是大功告成了,使用其它的控制器应该都没什么问题!

关于 pkgs.org

pkgs.org – Linux Packages Search
The pkgs.org is created to provide you with the simplest method of searching and downloading
the newest versions of the Linux packages without the usual excessive popups or spyware.

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值