天天看點

《Cisco VPP SFC》4、ODL SFC 安裝SFC部署

原文位址:https://blog.csdn.net/u010827484/article/details/81222622

1、部署基礎環境

1.1 安裝 git

sudo apt-get install git
           

1.2 安裝 Maven

sudo apt-get install maven

安裝完成後:
 added,  removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
root@ubuntu:/home/odl#

測試java環境:
root@ubuntu:/home/odl# java -version
           

2、建立sfc-oxygen目錄并下載下傳ODL代碼到sfc-oxygen目錄,然後切換到oxygen的穩定分支:

git clone https://git.opendaylight.org/gerrit/p/sfc.git  --branch stable/oxygen --single-branch sfc-oxygen

下載下傳完成後:
root@ubuntu:/home/odl# git clone https://git.opendaylight.org/gerrit/p/sfc.git  --branch stable/oxygen --single-branch sfc-oxygen
Cloning into 'sfc-oxygen'...
remote: Finding sources: % (/)
remote: Total  (delta ), reused  (delta )
Receiving objects: % (/),  MiB |  KiB/s, done.
Resolving deltas: % (/), done.
Checking connectivity... done.
root@ubuntu:/home/odl# cd sfc-oxygen/
root@ubuntu:/home/odl/sfc-oxygen# git branch
* stable/oxygen
root@ubuntu:/home/odl/sfc-oxygen#
           

3、編譯 opendaylight 過程中可能會因為網絡的原因下載下傳失敗,隻需要重新編譯就行

設定maven堆空間,有助于編譯過程,節約編譯時間:

export MAVEN_OPTS=’-Xmx1048m -XX:MaxPermSize=512m’

you can increase the heap space, the -Xmx setting, to greater than 1G if memory is available. When building in maven, the max memory reached will be displayed at the end of the build. You can use this as a guide to determine if more memory would help decrease build times. Approx 1.5G of RAM is needed by the JVM to run the Helium Controller repeatedly and avoid OOM errors.
開始編譯:–DskipTests:跳過測試過程,可以節約很多時間
mvn clean install -DskipTests

提示如下錯誤:
root@ubuntu:/home/odl/sfc-oxygen# mvn clean install -DskipTests
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.opendaylight.sfc:sfc-parent:.-SNAPSHOT: Could not find artifact org.opendaylight.mdsal:binding-parent:pom:.-SNAPSHOT and 'parent.relativePath' points at no local POM @ line , column 
 @ 
[ERROR] The build could not read  project -> [Help ]
[ERROR]   
[ERROR]   The project org.opendaylight.sfc:sfc-parent:.-SNAPSHOT (/home/odl/sfc-oxygen/pom.xml) has  error
[ERROR]     Non-resolvable parent POM for org.opendaylight.sfc:sfc-parent:.-SNAPSHOT: Could not find artifact org.opendaylight.mdsal:binding-parent:pom:.-SNAPSHOT and 'parent.relativePath' points at no local POM @ line , column  -> [Help ]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help ] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help ] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
root@ubuntu:/home/odl/sfc-oxygen# 
           

以上錯誤原因是ODL編譯過程中Maven會下載下傳很多包,但是找不到下載下傳的源需要在目前使用者目錄加上settings.xml

下載下傳Opendaylight官網提供的settings.xml并儲存在目前使用者目錄:

root@ubuntu:/home/odl/sfc-oxygen# wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
           

重新編譯 ODL:

root@ubuntu:/home/odl/sfc-oxygen# mvn clean install –DskipTestsWarning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
Downloading: https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/mdsal/binding-parent/.-SNAPSHOT/maven-metadata.xml
Downloaded: https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/mdsal/binding-parent/.-SNAPSHOT/maven-metadata.xml ( B at . KB/sec)
Downloading: https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/mdsal/binding-parent/.-SNAPSHOT/binding-parent-.--.pom
           

出錯了…分析錯誤原因是因為在java環境中沒有tools.jar包,檢視java安裝目錄找不到這個包,還是重新裝java:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: : min
[INFO] Finished at: --T04::-:
[INFO] Final Memory: M/M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin::check (check-license) on project sfc-parent: Execution check-license of goal org.apache.maven.plugins:maven-checkstyle-plugin::check failed: Plugin org.apache.maven.plugins:maven-checkstyle-plugin: or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:. at specified path /usr/lib/jvm/java--openjdk-amd64/jre/../lib/tools.jar -> [Help ]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help ] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
root@ubuntu:/home/odl/sfc-oxygen#
           

安裝java:

、解除安裝現有java
apt-get --purge remove java-common

、安裝java

添加ppa
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

安裝oracle-java-installer
sudo apt-get install oracle-java8-installer

設定系統預設jdk
sudo update-java-alternatives -s java--oracle

java安裝測試
java -version
javac -version

導出JAVA安裝目錄到環境變量:
export JAVA_HOME=/usr/lib/jvm/java--oracle/

、重新安裝Maven,解除安裝java-common時會解除安裝掉mvn指令,重新安裝就可以了
sudo apt-get install maven
           

又出錯了…

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: : min
[INFO] Finished at: --T05::-:
[INFO] Final Memory: M/M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:..:bower (bower) on project sfc-ui-module: Failed to run task: 'bower install' failed. (error code 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help ] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :sfc-ui-module
root@ubuntu:/home/odl/sfc-oxygen# 
           

分析出錯原因,是因為系統沒有bower,安裝bower後重新編譯ODL

root@ubuntu:/home/odl/sfc-oxygen# apt-get install npm
root@ubuntu:/home/odl/sfc-oxygen# npm install bower -g 
npm WARN deprecated bower@1.: We don't recommend using Bower for new projects. Please consider Yarn and Webpack or Parcel. You can read how to migrate legacy project here: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
/usr/local/lib
└── [email protected]
           

繼續出錯……

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: : min
[INFO] Finished at: --T05::-:
[INFO] Final Memory: M/M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:.:bower (bower) on project sfc-ui-module: Failed to run task: 'bower install' failed. (error code ) -> [Help ]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help ] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :sfc-ui-module
           

google後知道mvn使用root編譯需要加上如下參數,繼續編譯

echo '{ "allow_root": true }' > /root/.bowerrc
           

大概需要2個小時,編譯完成

SFC部署

1、進入karaf目錄:

2、删除karaf曆史資料:

3、啟動odl

[email protected]:/home/odl/sfc-oxygen/karaf/target/assembly# ./bin/karaf clean
Apache Karaf starting up. Press Enter to open the shell now...
100% [========================================================================]

Karaf started in 1s. Bundle stats: 13 active, 13 total

    ________                       ________                .__  .__       .__     __       
    \_____  \ ______   ____   ____ \______ \ _____  ___.__.|  | |__| ____ |  |___/  |_     
     /   |   \\____ \_/ __ \ /    \ |    |  \\__  \<   |  ||  | |  |/ ___\|  |  \   __\    
    /    |    \  |_> >  ___/|   |  \|    `   \/ __ \\___  ||  |_|  / /_/  >   Y  \  |      
    \_______  /   __/ \___  >___|  /_______  (____  / ____||____/__\___  /|___|  /__|      
            \/|__|        \/     \/        \/     \/\/            /_____/      \/          


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 OpenDaylight.

[email protected]>
           

目前ODL隻有基礎元件,需要安裝SFC環境需要的元件

opendaylight-user@root>feature:list -i
Name                                 │ Version │ Required │ State   │ Repository                           │ Description
─────────────────────────────────────┼─────────┼──────────┼─────────┼──────────────────────────────────────┼──────────────────────────────────────────────────
c3ba29-dc2-fff-a491-a8393c9ab46 │    │ x        │ Started │ a6a1663-dfe-efd-ae1-b07 │
aries-proxy                          │    │          │ Started │ standard-                       │ Aries Proxy
aries-blueprint                      │    │          │ Started │ standard-                       │ Aries Blueprint
feature                              │    │          │ Started │ standard-                       │ Features Support
shell                                │    │          │ Started │ standard-                       │ Karaf Shell
shell-compat                         │    │          │ Started │ standard-                       │ Karaf Shell Compatibility
deployer                             │    │          │ Started │ standard-                       │ Karaf Deployer
bundle                               │    │          │ Started │ standard-                       │ Provide Bundle support
config                               │    │          │ Started │ standard-                       │ Provide OSGi ConfigAdmin support
diagnostic                           │    │          │ Started │ standard-                       │ Provide Diagnostic support
instance                             │    │          │ Started │ standard-                       │ Provide Instance support
jaas                                 │    │          │ Started │ standard-                       │ Provide JAAS support
log                                  │    │          │ Started │ standard-                       │ Provide Log support
package                              │    │          │ Started │ standard-                       │ Package commands and mbeans
service                              │    │          │ Started │ standard-                       │ Provide Service support
system                               │    │          │ Started │ standard-                       │ Provide System support
kar                                  │    │          │ Started │ standard-                       │ Provide KAR (KARaf archive) support
ssh                                  │    │          │ Started │ standard-                       │ Provide a SSHd server on Karaf
management                           │    │          │ Started │ standard-                       │ Provide a JMX MBeanServer and a set of MBeans in
wrap                                 │    │          │ Started │ standard-                       │ Wrap URL handler
standard                             │    │          │ Started │ standard-                       │ Wrap feature describing all features part of a st
opendaylight-user@root> 
           

根據SFC架構,北向接口需要安裝restconf相關元件,南向接口需要安裝netconf相關元件以及南北向抽象層mdsal的相關元件和提供SFC功能的核心元件:

opendaylight-user@root>feature:install odl-netconf-api odl-netconf-mapping-api odl-netconf-util odl-netconf-netty-util odl-netconf-client odl-sfc-netconf odl-netconf-connector-all odl-netconf-notifications-api odl-mdsal-apidocs odl-mdsal-models odl-mdsal-binding odl-mdsal-binding-runtime odl-mdsal-common odl-mdsal-broker odl-mdsal-clustering-commons odl-mdsal-distributed-datastore odl-mdsal-remoterpc-connector odl-mdsal-broker-local odl-restconf odl-restconf-noauth odl-sfc-model odl-sfc-provider odl-sfc-provider-rest  odl-sfc-ovs odl-sfc-ui odl-sfc-sb-rest odl-sfc-openflow-renderer
opendaylight-user@root>