欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ONOS,Mininet源码安装

程序员文章站 2022-07-06 20:21:27
...

ONOS

1、虚拟机

ubuntu16.04
内存 2G
硬盘大小 15G

2、源码编译安装

参见 https://wiki.onosproject.org/display/ONOS/Developer+Quick+Start
1)安装java依赖

sudo apt-get install software-properties-common -y && \
sudo add-apt-repository ppa:webupd8team/java -y && \
sudo apt-get update && \
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections && \
sudo apt-get install oracle-java8-installer oracle-java8-set-default -y

2)安装其他
git,zip,curl,python(Version 2.7 is required)

sudo apt-get install git zip curl python -y

3)下载源码并build
1>下载源码

git clone https://gerrit.onosproject.org/onos

2>设置环境变量ONOS_ROOT

cd onos
export ONOS_ROOT=$(pwd)
echo $ONOS_ROOT

直接export环境变量临时,而日后ONOS_ROOT还会用到。可以在文件~/.profile文件最后加一行:

export ONOS_ROOT="/home/host1/onos"

然后:

source ~/.profile

3>Git到想要的版本

git tag
git checkout 1.12.0

4>Build编译整个onos

tools/build/onos-buck build onos --show-output

编译成功,生成onos.tar.gz文件,如下:
ONOS,Mininet源码安装

Mininet

1、安装mininet

参考 http://mininet.org/download/
按照方法“Option 2: Native Installation from Source”即可。

2、验证

sudo mn --test pingall

Mininet+ONOS

1、拓扑

在mininet文件夹的下有custom/topo-2sw-2host.py这样一个拓扑示例文件。可以直接拿来用下。

sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall

2、运行ONOS

1>运行ONOS

tools/build/onos-buck run onos-local -- clean debug  

2>进入ONOS控制台

tools/test/bin/onos localhost

进入控制台后,可以运行各种ONOS CLI和Apache Karaf命令。
例如,要启动OpenFlow和响应转发,可以通过如下命令:

onos> app activate org.onosproject.openflow
onos> app activate org.onosproject.fwd

3、Mininet拓扑连接ONOS控制器

1>Mininet拓扑和ONOS关联(这里ONOS在本地,ip为127.0.0.1)

sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --controller remote,ip=127.0.0.1 --test pingall

2>ONOS GUI查看拓扑
默认浏览器打开ONOS GUI,可以通过如下命令:

tools/test/bin/onos-gui localhost

也可以直接访问网址 http://localhost:8181/onos/ui
注:需要Openflow等才能看到拓扑

坑~

一些坑,不踩不知道的痛。

1、ONOS编译构建时不要用sudo

在构建onos时你不需要成为sudo。 以普通用户运行即可,不然权限问题会导致失败。
参考 https://groups.google.com/a/onosproject.org/forum/#!topic/onos-dev/aAQNioAMXNs
sudo运行大概会导致:

Successfully updated Buck in /home/tera/onos/bin/buck to buck-v2017.08.16.01.zip 
Not using buckd because NO_BUCKD is set. 
/home/tera/onos/buck-out/gen/web/gui/onos-tools-gui-exe: line 10: cd: /tools/gui: No such file or directory 

BUILD FAILED: //web/gui:onos-tools-gui failed with exit code 1: 
genrule 
stderr: /home/tera/onos/buck-out/gen/web/gui/onos-tools-gui-exe: line 10: cd: /tools/gui: No such file or directory 

ONOS,Mininet源码安装

2、虚拟机硬盘容量10G不大够用

否则,装了Mininet再装ONOS会提示设备上没有空间,如下:

/home/ubuntu-1604/onos/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/TeTunnelManager.java:61: 
error: 写入org.onosproject.tetunnel.impl.TeTunnelManager时出错: 设备上没有空间
 public class TeTunnelManager implements TeTunnelService, TeTunnelAdminService, 
         ^ Errors: 1. Warnings: 0. 

用查看硬盘容量,的确。
查看容量:

df -h

查看挂载点:

df -ai

3、虚拟机内存1G不大够用

否则,会提示“无法分配内存”:

|=> //core/store/dist:onos-core-dist...  1.7s (running javac[1.5s])
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000ea4bc000, 207618048, 0) failed; error='无法分配内存' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 207618048 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/host1/onos/hs_err_pid10635.log

遇到这个情况,增大虚拟机内存为2G即可。

4、一些奇特错误

还有一些错误,不是很明确什么原因。
1)我想大概是我编译时时复制过来的onos或者mininet文档,权限和Git获取的有所不同造成的。复制文档对文档权限有什么影响呢?需要去研究下。。。
2)网络网速不好,在build时一些要下载的等待时间太长。也有可能吧。
修改了/etc/hosts有些问题就不在出现了。
这些错误贴一贴,有遇到解决的小伙伴可以指导下。。。
已杀死?!什么鬼
ONOS,Mininet源码安装
这个好像是复制后权限原因?
ONOS,Mininet源码安装
这个在1.13版本中出现过。
ONOS,Mininet源码安装