about 7 years ago
自行編譯的好處是可以自行修改核心,而且可以更了解ODL的專案開發方式,但ODL的開發使用了許多套件,並使用了maven來管理其相依性與編譯程式,對於不熟的人來說是個很大的麻煩。故以下提供一個較完善的流程,讓新手可以快速的編譯,但並沒有多加敘述,各個部分請自行參考來源或自行搜索相關資料。
- ntp setup http://blog.longwin.com.tw/2009/12/ubunut-linux-set-zone-ntp-time-2009/
- install java
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer export JAVA_HOME=/usr/lib/jvm/java-7-oracle/ //you can add it to your bashrc.
- maven 3.1.1 download
-
參考來源
wget http://apache.spinellicreations.com/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz mkdir -p /usr/local/apache-maven sudo cp apache-maven-3.1.1-bin.tar.gz /usr/local/apache-maven/ cd /usr/local/apache-maven/ sudo tar -zxvf apache-maven-3.1.1-bin.tar.gz sudo ln -s /usr/local/apache-maven/apache-maven-3.1.1/bin/mvn /usr/local/bin/mvn
- 安裝成功,輸入"mvn -v"會有像下面一樣的訊息
Apache Maven 3.1.1 (NON-CANONICAL_2013-11-08_14-32_mockbuild; 2013-11-08 09:32:41-0500) Maven home: /usr/share/maven Java version: 1.7.0_55, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.10-200.fc20.x86_64", arch: "amd64", family: "unix"
-
參考來源
- 設定及安裝基本環境
mkdir .m2 cp -n ~/.m2/settings.xml{,.orig} ; \wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml apt-get install git vim curl htop screen install mininet git clone git://github.com/mininet/mininet ./mininet/util/install.sh -a
- 下載並編譯
mkdir opendaylight for PROJECT in controller openflowjava openflowplugin l2switch; \ do git clone ssh://${ODL_USERNAME}@git.opendaylight.org:29418/${PROJECT}.git; \ done //編譯順序 controller > openflowjava > openflowplugin > l2switch export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m" cd ~/opendaylight/controller git checkout -b helium remotes/origin/stable/helium git checkout -b helium-SR3 61e8ebd4fe43fc54b1bf54570e44bc1e20e26378 mvn clean install cd ~/opendaylight/openflowjava git checkout -b helium remotes/origin/stable/helium git checkout -b helium-SR3 2de4abf0a55b509879f9b88213ed61ed9bb0e947 mvn clean install cd ~/opendaylight/openflowplugin git checkout -b helium remotes/origin/stable/helium git checkout -b helium-SR3 c3c4614e0533c08a73a659320927bf8fdea06368 mvn clean install cd ~/opendaylight/l2switch git checkout -b helium remotes/origin/stable/helium git checkout -b helium-SR3 46b2a0167aa3e70d662478e3cb7d5d00b75f5d57 mvn clean install
- 編譯過程中的錯誤解決
- 目前遇到過兩種狀況
- 直接出現某某jar在 nexus.opendaylight.org/content/repositories/public/ 下無法存取
解決方法
請照著網址手動下載那個檔案,並放置.m2/repositoy中,按照網頁中一樣的目錄順序即可存取 - 只有出現錯誤,只有說明要到那個專案裡的 surefire-reports裡面查看 report
然後到錯誤的專案裡,並依提示路徑找到 ~/opendaylight/controller/features/base/target/surefire-reportsTEST-org.opendaylight.yangtools.featuretest.SingleFeatureTest.xml 像這樣的檔案
找到後可以更深入的知道什麼問題,例如我遇到的又是缺少檔案
我缺少的是 apache 和 maven的官網某個東西無法下載,此時就依第一個解決方法一樣放入
- 直接出現某某jar在 nexus.opendaylight.org/content/repositories/public/ 下無法存取
- 如果都不是上兩種情況,請對照一下您 maven的版本,專案的編譯順序,基本上就可以編過
- 執行方式
cd ~/opendaylight/controller/opendaylight/distribution/opendaylight-karaf/target/assembly/bin/ ./karaf (開過一次後在上一層的目錄下會出現 configuration/initial 裡面可以設定cluster)
- Testing
mininet sudo mn --topo linear,3 --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow10 md-sal apis doc http://localhost:8181/apidoc/explorer/index.html md-sal testing get topology curl -u admin:admin http://localhost:8181/restconf/operational/network-topology:network-topology/ ad-sal testing get topology curl -u admin:admin -H 'Accept: application/json' 'http://localhost:8080/controller/nb/v2/topology/default' 執行時需要export export JAVA_OPTS="-Xmx4096m -XX:MaxPermSize=512m"
- Karaf 內部的 feature install
//karaf install featrues 可以開啟網頁 feature:install odl-dlux-all odl-restconf odl-l2switch-switch http://localhost:8181/dlux/index.html //但查詢了http:list | grep dlux 可能不是掛載在dlux -> http://localhost:8181/index.html //helium-SR3 除了controller外另兩個專案rpo的新增 feature:repo-add mvn:org.opendaylight.dlux/features-dlux/0.1.3-Helium-SR3/xml/features feature:repo-add mvn:org.opendaylight.openflowjava/features-openflowjava/0.5.3-Helium-SR3/xml/features feature:repo-add mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.0.6-Helium-SR3/xml/features feature:repo-add mvn:org.opendaylight.l2switch/features-l2switch/0.1.3-Helium-SR3/xml/features feature:repo-add mvn:org.opendaylight.controller/features-adsal-compatibility/1.4.5-Helium-SR3/xml/features //正常運作 需要加入這些feature feature:install odl-base-all odl-aaa-authn odl-restconf odl-adsal-northbound odl-mdsal-apidocs odl-l2switch-switch //AD-SAL + MD-SAL feature:install odl-adsal-all odl-adsal-northbound odl-openflowjava-all odl-openflowplugin-all odl-l2switch-all odl-nsf-all odl-adsal-compatibility-all feature:list -i To list only intalled features //cluster Testing feature:install odl-restconf-all feature:install odl-mdsal-clustering feature:install odl-openflowplugin-flow-services feature:install http bundle:install -s mvn:org.jolokia/jolokia-osgi/1.1.4 //查看運作狀況 GET http://<host>:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-inventory-config,type=DistributedConfigDatastore
- 補充指令
測試資料庫同步
feature:install odl-toaster-rest POST /config { "toaster:toaster": { "toaster:toasterManufacturer" :"andy", "toaster:toasterModelNumber" : "456", "toaster:toasterStatus" : "up" } } GET/config/toaster
- 補充指令
測試資料庫同步
編譯指令
mvn clean install
mvn clean install -DskipTests
mvn -Dmaven.test.failure.ignore=true --fail-at-end clean install