調試環境
ubuntu 12.04
JDK1.7
apache-maven-3.10
eclipse 4.2 Juno
mysql 5
apache ant
JDK的配置和安裝
安裝可以參考:
http://my.oschina.net/jamesju/blog/94916
我是安裝在~//java/jdk1.7.0_21下,執行java -version可以看到當前的JDK版本。
Maven的配置和安裝
安裝可以參考:
http://blog.csdn.net/sin90lzc/article/details/7429620
Eclipse及插件安裝
到eclipse官網下載4.2或者最新的4.3版本的eclipse.
下載地址:
http://www.eclipse.org/downloads/
安裝PyDev插件,用來查看python角本,因為底層操作是使用python寫的。
安裝地址:
http://pydev.org/updates/
然后安裝eclipse的m2e插件,就是eclipse的maven插件。
安裝地址:
http://download.eclipse.org/technology/m2e/releases
然后在eclipse的
因為源碼是上傳到git上的,所以要安裝Egit插件。
安裝地址:Preferences里邊配置maven的路徑,就是剛安裝的maven的路徑。
http://download.eclipse.org/egit/updates
安裝完成后可以到菜單Help->About Eclipse->Installation Details,點擊
下載源碼
使用File->Import
選擇Next,選擇URI
輸入:
https://git-wip-us.apache.org/repos/asf/cloudstack.git
選擇要調試的版本,這里要調試是4.02版本,比較穩定的一個版本,如下圖:
然后選擇本地路徑,Finish。
接下來就等着下載源碼,這個時間跟網速有關。
然后再選擇File->Import,選擇Existing Maven Projects,選擇剛才保存的git本地路徑,導入剛下載的工程。
編譯和運行jetty
使用maven編譯,點擊Run->Run Configuration
compile -U,-U表示強制更新,如果有未更新完成的包也會重新下載,這個可以根據自己的情況選擇加或不加。
然后點Run,編譯成功后會出現如下結果:
[INFO] Reactor Summary: [INFO] [INFO] Apache CloudStack ................................. SUCCESS [1.038s] [INFO] Apache CloudStack Utils ........................... SUCCESS [1.485s] [INFO] Apache CloudStack API ............................. SUCCESS [0.633s] [INFO] Apache XenSource XAPI ............................. SUCCESS [0.135s] [INFO] Apache CloudStack Core ............................ SUCCESS [0.495s] [INFO] Apache CloudStack Agents .......................... SUCCESS [0.546s] [INFO] Apache CloudStack SystemVM Patches ................ SUCCESS [0.209s] [INFO] Apache CloudStack Console Proxy ................... SUCCESS [0.347s] [INFO] Apache CloudStack Server .......................... SUCCESS [0.470s] [INFO] Apache CloudStack Usage Server .................... SUCCESS [0.214s] [INFO] Apache CloudStack Plugin POM ...................... SUCCESS [0.196s] [INFO] Apache CloudStack Plugin - User Concentrated Pod Deployment Planner SUCCESS [0.165s] [INFO] Apache CloudStack Plugin - User Dispersing Deployment Planner SUCCESS [0.236s] [INFO] Apache CloudStack Plugin - Host Allocator Random .. SUCCESS [0.355s] [INFO] Apache CloudStack Plugin - Hypervisor OracleVM .... SUCCESS [0.477s] [INFO] Apache CloudStack Plugin - Open vSwitch ........... SUCCESS [0.328s] [INFO] Apache CloudStack Plugin - Hypervisor Xen ......... SUCCESS [0.412s] [INFO] Apache CloudStack Plugin - Hypervisor KVM ......... SUCCESS [0.395s] [INFO] Apache CloudStack Plugin - Network Elastic Load Balancer SUCCESS [0.174s] [INFO] Apache CloudStack Plugin - Network Nicira NVP ..... SUCCESS [0.175s] [INFO] Apache CloudStack Plugin - Storage Allocator Random SUCCESS [0.158s] [INFO] Apache CloudStack Plugin - User Authenticator LDAP SUCCESS [0.161s] [INFO] Apache CloudStack Plugin - User Authenticator MD5 . SUCCESS [0.169s] [INFO] Apache CloudStack Plugin - User Authenticator Plain Text SUCCESS [0.166s] [INFO] Apache CloudStack AWS API Bridge .................. SUCCESS [2.046s] [INFO] Apache CloudStack Test ............................ SUCCESS [0.167s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.256s [INFO] Finished at: Fri Aug 02 22:21:41 CST 2013 [INFO] Final Memory: 25M/357M [INFO] ------------------------------------------------------------------------
然后運行jetty,這個默認是在cloud-client-ui這個工程里邊配置的,所以配置如下:
如果中間出現問題,岀到出錯的工程中選擇maven clean然后再maven install一下,然后再執行cloudrun運行jetty,這樣反復幾次,就可以成功運行jetty了。
這時啟動會報錯,因為沒有安裝數據庫。
安裝數據庫:
$ sudo apt-get install mysql-server 在彈出的界面中輸入密碼,如: cloudstack
然后
修改MySQL配置文件參數 $ sudo vim /etc/mysql/my.cnf 在[mysqld]模塊中加入以下參數 1 innodb_rollback_on_timeout=1 2 innodb_lock_wait_timeout=600 3 max_connections=350 4 log-bin=mysql-bin 5 binlog-format = 'ROW' 重啟MySQL $ sudo service mysql restart
在eclipse中找到replace.properties文件,修改replace.properties文件中的key為DBROOTPW的值,這個值是mysql默認的密碼,我們修改成上面的cloudstack
然后安裝ant
sudo apt-get install ant
安裝完成后到源碼安裝目錄或者在eclipse中執行
ant deploydb
這樣數據庫就可以成功部署了。
然后在調試的時候需要選擇Debug->Debug Configuration->Source->Add
將所有源碼工程加上。
然后打上斷點,以Debug模式運行,就可用斷點調試了。
可能遇到的問題
1、工程jar包丟失,編譯不過去
[WARNING] The POM for org.apache.cloudstack:cloud-plugin-user-authenticator-md5:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-user-authenticator-plaintext/4.0.2/cloud-plugin-user-authenticator-plaintext-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-user-authenticator-plaintext:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-network-nvp/4.0.2/cloud-plugin-network-nvp-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-network-nvp:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-network-ovs/4.0.2/cloud-plugin-network-ovs-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-network-ovs:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-network-elb/4.0.2/cloud-plugin-network-elb-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-network-elb:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-hypervisor-xen/4.0.2/cloud-plugin-hypervisor-xen-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-hypervisor-xen:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-hypervisor-ovm/4.0.2/cloud-plugin-hypervisor-ovm-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-hypervisor-ovm:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-hypervisor-kvm/4.0.2/cloud-plugin-hypervisor-kvm-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-hypervisor-kvm:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-storage-allocator-random/4.0.2/cloud-plugin-storage-allocator-random-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-storage-allocator-random:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-planner-user-dispersing/4.0.2/cloud-plugin-planner-user-dispersing-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-planner-user-dispersing:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-planner-user-concentrated-pod/4.0.2/cloud-plugin-planner-user-concentrated-pod-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-planner-user-concentrated-pod:jar:4.0.2 is missing, no dependency information available [INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/cloudstack/cloud-plugin-host-allocator-random/4.0.2/cloud-plugin-host-allocator-random-4.0.2.pom [WARNING] The POM for org.apache.cloudstack:cloud-plugin-host-allocator-random:jar:4.0.2 is missing, no dependency information available
找到對應的工程,然后執行mvn clean install,哪個出問題就在哪個工程上執行就可以了。