当前位置: 首页 > ONOS > 正文

从源码编译安装 ONOS[sdnhub.cn亲测]

build onos from source code

1.准备工作

使用最新版本的Mininet 2.2虚拟机(从Mininet官网下载),这样只需要一个虚拟机就可以做实验了。启动虚拟机,使用mininet/mininet登录虚拟机,设置root用户的密码(我喜欢直接使用root用户,当然,如果你喜欢sudo的话,就直接使用mininet用户吧)。

修改root用户的密码,使用如下命令:

$ sudo sudo passwd root

设置SSH允许root用户登录,这样我就可以直接使用SSH客户端xshell连到虚拟机了。省的在虚拟机和宿主操作系统之间来回切换。编辑sshd的配置文件:

$ vim /etc/ssh/sshd_config

作如下修改:

#PermitRootLogin without-password
PermitRootLogin yes

重启sshd服务:

$ sudo service ssh restart
ssh stop/waiting
ssh start/running, process 1786

查看虚拟机的IP地址,命令如下:

$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0c:29:6f:a1:38  
          inet addr:192.168.80.130  Bcast:192.168.80.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29446 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5357 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:37239244 (37.2 MB)  TX bytes:604986 (604.9 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

接下来使用xshell连接对应的IP地址,使用root用户登录后,更新apt源,安装git-core,命令如下:

root@mininet-vm:~# apt-get update
root@mininet-vm:~# apt-get install git-core

2.下载ONOS的最新源码和必须的软件

在用户主目录下创建两个子目录:~/Downloads和~/Applications。下载Karaf 3.0.2 和 Maven 3.2.2的二进制软件包(tar.gz),放到~/Download目录下,解压缩到~/Application目录。

root@mininet-vm:~# cd; mkdir Downloads Applications
root@mininet-vm:~# cd Downloads
root@mininet-vm:~# wget http://mirrors.hust.edu.cn/apache/karaf/3.0.2/apache-karaf-3.0.2.tar.gz
root@mininet-vm:~# wget http://www.apache.org/dist/maven/binaries/apache-maven-3.2.2-bin.tar.gz
root@mininet-vm:~# tar -zxvf apache-karaf-3.0.2.tar.gz -C ../Applications/
root@mininet-vm:~# tar -zxvf apache-maven-3.2.2-bin.tar.gz -C ../Applications/ 

安装Oracle Java 8:

root@mininet-vm:~# apt-get install software-properties-common -y
root@mininet-vm:~# add-apt-repository ppa:webupd8team/java -y
root@mininet-vm:~# apt-get update
root@mininet-vm:~# apt-get install oracle-java8-installer oracle-java8-set-default -y

下载ONOS最新的源码:

root@mininet-vm:~# cd
root@mininet-vm:~# git clone https://gerrit.onosproject.org/onos -b 1.1.0

3.编译ONOS源码

3.1 编译环境设置,需要编辑~/.profile文件:

首先需要设置编译环境,ONOS源代码中包含了一个bash_profile设置环境变量的范例。这个范例文件可以直接引入到~/.profile文件的最后:

. ~/onos/tools/dev/bash_profile

接着,由于我用的是root用户,所以需要设置环境变量ONOS_USER,否则ONOS默认的用户是sdn,把下面的内容加入到~/.profile文件的最后:

export ONOS_USER=root
export ONOS_GROUP=root

最后还需要把下面的内容加入到~/.profile文件的最后:

PATH=/root/Applications/apache-maven-3.2.2/bin/:/root/Applications/apache-karaf-3.0.2/bin/:$PATH
export PATH

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

保存.profile文件退出后重新登录,或者执行如下命令,使配置生效:

root@mininet-vm:~# . ~/.profile

可以使用env命令查看系统中多了几个环境变量(例如:ONOS_ROOT,OCI,KARAF_ROOT)。

3.2获取ONOS最新源码

使用如下命令下载最新的1.1.0源码:

root@mininet-vm:~# git clone https://gerrit.onosproject.org/onos -b 1.1.0
or
root@mininet-vm:~# git clone https://github.com/opennetworkinglab/onos.git -b 1.1.0

如果速度比较慢,或者出错的话,可以直接从这里下载:https://github.com/opennetworkinglab/onos/releases,然后解压缩到root用户的主目录下。

3.3编译ONOS

开始编译ONOS 1.1.0(因为要到国外站点下载很多东东,这个过程较长,需要耐心等待):

root@mininet-vm:~# cd onos
root@mininet-vm:~/onos# mvn clean install

编译成功后的输出信息如下:

[INFO] 
[INFO] --- maven-bundle-plugin:2.5.3:install (default-install) @ onos-branding ---
[INFO] Installing org/onosproject/onos-branding/1.1.0/onos-branding-1.1.0.jar
[INFO] Writing OBR metadata
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] onos ............................................... SUCCESS [07:23 min]
[INFO] onlab-utils ........................................ SUCCESS [02:51 min]
[INFO] onlab-junit ........................................ SUCCESS [02:39 min]
[INFO] onlab-misc ......................................... SUCCESS [01:57 min]
[INFO] onlab-netty ........................................ SUCCESS [ 31.444 s]
[INFO] onlab-nio .......................................... SUCCESS [  5.569 s]
[INFO] onlab-osgi ......................................... SUCCESS [  4.022 s]
[INFO] onlab-rest ......................................... SUCCESS [01:14 min]
[INFO] onlab-thirdparty ................................... SUCCESS [04:01 min]
[INFO] onos-core .......................................... SUCCESS [ 16.853 s]
[INFO] onos-api ........................................... SUCCESS [01:15 min]
[INFO] onos-core-common ................................... SUCCESS [ 36.538 s]
[INFO] onos-core-store .................................... SUCCESS [  1.167 s]
[INFO] onos-core-trivial .................................. SUCCESS [ 15.061 s]
[INFO] onos-core-serializers .............................. SUCCESS [  9.550 s]
[INFO] onos-core-dist ..................................... SUCCESS [05:53 min]
[INFO] onos-core-net ...................................... SUCCESS [ 57.713 s]
[INFO] onos-web ........................................... SUCCESS [  1.257 s]
[INFO] onos-gui ........................................... SUCCESS [ 23.059 s]
[INFO] onos-rest .......................................... SUCCESS [ 39.768 s]
[INFO] onos-cli ........................................... SUCCESS [01:28 min]
[INFO] onos-of ............................................ SUCCESS [  1.227 s]
[INFO] onos-of-api ........................................ SUCCESS [18:21 min]
[INFO] onos-providers ..................................... SUCCESS [  0.883 s]
[INFO] onos-of-providers .................................. SUCCESS [  1.189 s]
[INFO] onos-of-provider-device ............................ SUCCESS [  6.241 s]
[INFO] onos-of-provider-link .............................. SUCCESS [  5.783 s]
[INFO] onos-of-provider-host .............................. SUCCESS [  4.922 s]
[INFO] onos-of-provider-packet ............................ SUCCESS [  5.667 s]
[INFO] onos-of-provider-flow .............................. SUCCESS [  2.847 s]
[INFO] onos-of-provider-group ............................. SUCCESS [  6.710 s]
[INFO] onos-lldp-provider ................................. SUCCESS [  9.693 s]
[INFO] onos-host-provider ................................. SUCCESS [  5.391 s]
[INFO] onos-null-providers ................................ SUCCESS [  0.614 s]
[INFO] onos-null-provider-device .......................... SUCCESS [  1.456 s]
[INFO] onos-null-provider-link ............................ SUCCESS [  1.973 s]
[INFO] onos-null-provider-host ............................ SUCCESS [  1.304 s]
[INFO] onos-null-provider-packet .......................... SUCCESS [  1.820 s]
[INFO] onos-null-provider-flow ............................ SUCCESS [  1.213 s]
[INFO] onos-of-drivers .................................... SUCCESS [  2.607 s]
[INFO] onos-of-ctl ........................................ SUCCESS [  6.003 s]
[INFO] onos-apps .......................................... SUCCESS [  0.615 s]
[INFO] onos-app-tvue ...................................... SUCCESS [  1.497 s]
[INFO] onos-app-fwd ....................................... SUCCESS [  1.637 s]
[INFO] onos-app-ifwd ...................................... SUCCESS [  1.371 s]
[INFO] onos-app-mobility .................................. SUCCESS [  1.364 s]
[INFO] onos-app-proxyarp .................................. SUCCESS [  1.312 s]
[INFO] onos-app-config .................................... SUCCESS [  1.406 s]
[INFO] onos-app-routing-api ............................... SUCCESS [  4.307 s]
[INFO] onos-app-sdnip ..................................... SUCCESS [  7.284 s]
[INFO] onos-app-calendar .................................. SUCCESS [  1.470 s]
[INFO] onos-app-optical ................................... SUCCESS [ 46.554 s]
[INFO] onos-app-metrics ................................... SUCCESS [  0.776 s]
[INFO] onos-app-metrics-intent ............................ SUCCESS [  1.881 s]
[INFO] onos-app-metrics-topology .......................... SUCCESS [  1.946 s]
[INFO] onos-app-oecfg ..................................... SUCCESS [  2.998 s]
[INFO] onos-app-demo ...................................... SUCCESS [  1.733 s]
[INFO] onos-app-election .................................. SUCCESS [  1.435 s]
[INFO] onos-app-routing ................................... SUCCESS [ 14.086 s]
[INFO] onos-app-bgprouter ................................. SUCCESS [  2.216 s]
[INFO] onos-app-intent-perf ............................... SUCCESS [01:24 min]
[INFO] onos-app-database-perf ............................. SUCCESS [  1.749 s]
[INFO] onos-features ...................................... SUCCESS [02:56 min]
[INFO] onos-branding ...................................... SUCCESS [  1.492 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:01 h
[INFO] Finished at: 2015-03-26T06:54:36-07:00
[INFO] Final Memory: 78M/380M
[INFO] ------------------------------------------------------------------------

4.运行ONOS控制器

4.1在本机运行ONOS

配置Karaf加载ONOS相关的模块。配置文件在:$KARAF_ROOT/etc/org.apache.karaf.features.cfg。编辑此文件,在配置项featuresRepositories后面追加如下的内容:

mvn:org.onosproject/onos-features/1.1.0/xml/features

注意上面的配置中,我使用的ONOS版本是1.1.0,请根据ONOS的版本情况做适当的调整。

featuresBoot选项后面追加如下的内容:

onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd,onos-app-mobility,onos-gui

上面是当ONOS启动时默认加载的features,onos-core-trivial是ONOS的单实例核心。

运行ONOS(此处需要耐心等待一下,启动速度不是太快):

root@mininet-vm:~# karaf clean
        __ __                  ____      
       / //_/____ __________ _/ __/      
      / ,<  / __ `/ ___/ __ `/ /_        
     / /| |/ /_/ / /  / /_/ / __/        
    /_/ |_|\__,_/_/   \__,_/_/         

  Apache Karaf (3.0.2)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

karaf@root()> 

为了在启动时看到ONOS的提示信息,而非默认的Karaf信息,则执行如下的命令:

cp ${ONOS_ROOT}/tools/package/branding/target/onos-branding-1.1.0.jar ${KARAF_ROOT}/lib/

然后重新启动ONOS:

root@mininet-vm:~# karaf clean
Welcome to Open Network Operating System (ONOS)!
     ____  _  ______  ____   
    / __ \/ |/ / __ \/ __/    
   / /_/ /    / /_/ /\ \       
   \____/_/|_/\____/___/      


Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown ONOS.

onos> 

启动minnet:

root@mininet-vm:~/Applications/apache-karaf-3.0.2/etc# mn --controller remote --switch ovsk,protocols=OpenFlow13 --mac --topo tree,3

打开浏览器,地址栏输入http://localhost:8181/onos/ui,可以查看ONOS的Web GUI。

4.2将编译好的ONOS部署的其它机器上

待续。。。。。

本文固定链接: http://sdnhub.cn/index.php/build-onos-from-source-code/ | 软件定义网络SDN

该日志由 sdnhub 于2015年03月26日发表在 ONOS 分类下, 通告目前不可用,你可以至底部留下评论。
原创文章转载请注明: 从源码编译安装 ONOS[sdnhub.cn亲测] | 软件定义网络SDN
关键字: ,

从源码编译安装 ONOS[sdnhub.cn亲测]:等您坐沙发呢!

发表评论

*

快捷键:Ctrl+Enter