一、onos安裝
下載OXP源碼 並切換到最新版本
$ git clone https://github.com/paradisecr/ONOS-ICOA.git $ mv ONOS-ICOA onos $ git checkout v2
安裝onos依賴。
方法一:使用onos自帶腳本安裝,比較便利
$ cd onos $ ./tools/dev/bin/onos-setup-ubuntu-devenv
方法二:手動安裝,比較麻煩,需要一步步執行命令
$ mkdir Downloads Applications $ cd Downloads $ wget http://archive.apache.org/dist/karaf/3.0.5/apache-karaf-3.0.5.tar.gz $ wget http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz $ tar -zxf apache-karaf-3.0.5.tar.gz -C ../Applications/ $ tar -zxf apache-maven-3.3.9-bin.tar.gz -C ../Applications/ 如圖所示
添加onos環境變量。
打開配置文件 $ vim ~/.profile 在末尾追加這句命令 $ source ~/onos/tools/dev/bash_profile 退出,在shell下執行source命令使其生效 $ source ~/.profile
如圖所示
二、編譯ONOS
爲了使編譯順利,推薦使用國內Maven的鏡像。
$ cd ~/Applications/apache-maven-3.3.9/conf $ vim setting.xml
在文件裏配置mirrors的子節點,添加如下mirror,覆蓋之前的mirror:
<mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
如果編譯依賴下載依然出錯,可以採取添加profiles的子節點的方式,不覆蓋之前的mirror的基礎上添加其他的mirror
<profile> <id>dev</id> <repositories> <repository> <id>nexus</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>
防止Java與Maven不一致的情況,執行以下命令:
打開配置文件 $ vim /etc/profile 在末尾添加 export JAVA_HOME=/usr/lib/jvm/java-8-oracle 退出文件,然後執行 $ source /etc/profile
編譯
$ cd ~/onos $ mvn clean install -DskipTests
如果由於某種原因編譯出現問題,可以將編譯成功的虛擬機上的maven庫打包到這個虛擬機上
$ tar -zcvf maven.tar.gz ./.m2 然後發送到目標主機 $ scp maven.tar.gz [email protected]:~/
在目標主機解壓
$ tar -zxvf maven.tar.gz
然後重新編譯
5. 啓動控制器
$ ok clean