虛擬化平臺cloudstack(7)——新版本的調試

調試環境

ubuntu 12.04

JDK1.7

apache-maven-3.10

eclipse 4.2 Juno

mysql 5

源碼下載及調試

上面的幾個軟件在上一篇中已經介紹了。

在新的版本中,整個的編譯和調試過程都是基於maven的,而且整個工程的結構也有所變化。

更新git:

sudo apt-get install git-core

安裝maven,確認安裝的是maven 3

sudo apt-get install maven
複製代碼
[email protected]virtual-machine:~$ mvn -version
Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-28 10:15:32+0800)
Maven home: /home/skyme/java/apache-maven-3.1.0
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /home/skyme/java/jdk1.7.0_21/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-37-generic", arch: "amd64", family: "unix"
複製代碼

安裝配置java

安裝mysql並且創建用戶,用戶名cloud,密碼cloud

sudo apt-get install mysql-server-5.5
mysql -u root -p 
輸入密碼
insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_sub
ject) values("localhost","cloud",password("cloud"),'','',''); 
grant all privileges on phplampDB.* to [email protected] identified by 'cloud'; 
flush privileges; 

安裝tomcat6

sudo apt-get install tomcat6

構建步驟

下載源碼:

git clone https://git-wip-us.apache.org/repos/asf/cloudstack.git

下載完成後,執行:

mvn clean install

構建完成後,進行測試:

mvn -P developer -pl developer -Ddeploydb

在這裏面構建數據庫的過程也改成了mvn的方式。

在執行測試的時候:

export MAVEN_OPTS="-XX:MaxPermSize=512M -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

MaxPermSize的值在這裏面設置爲512M,因爲有可能啓動jetty的時候會報錯

Exception in thread "main" java.lang.OutOfMemoryError: PermGen space。

然後啓動jetty。

mvn -pl :cloud-client-ui jetty:run
複製代碼
d788942
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.guru.OvsGuestNetworkGuru_EnhancerByCloudStack_2230f61b
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.template.HypervisorTemplateAdapter_EnhancerByCloudStack_ab1a790f
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.guru.StorageNetworkGuru_EnhancerByCloudStack_8d4afb32
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.element.MidoNetElement_EnhancerByCloudStack_bbaedad
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator_EnhancerByCloudStack_a26e7930
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting org.apache.cloudstack.storage.allocator.GarbageCollectingStoragePoolAllocator_EnhancerByCloudStack_3ecf09b5
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker_EnhancerByCloudStack_16619324
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.ha.KVMFencer_EnhancerByCloudStack_fa0503f3
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.element.VirtualRouterElement_EnhancerByCloudStack_9d6525ff
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.ha.XenServerFencer_EnhancerByCloudStack_bfe5e165
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator_EnhancerByCloudStack_feb121d2
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.server.auth.MD5UserAuthenticator_EnhancerByCloudStack_1500f4a2
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.element.NiciraNvpElement_EnhancerByCloudStack_48e0bcdb
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.hypervisor.XenServerGuru_EnhancerByCloudStack_41a08dc3
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.ha.XenServerInvestigator_EnhancerByCloudStack_f77a7c2d
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.element.ElasticLoadBalancerElement_EnhancerByCloudStack_510d11fa
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.network.guru.NiciraNvpGuestNetworkGuru_EnhancerByCloudStack_9f279c07
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.baremetal.networkservice.BaremetalPxeElement_EnhancerByCloudStack_ec99bfab
INFO  [c.c.u.c.ComponentContext] (Timer-3:null) Starting com.cloud.server.ManagementServerImpl_EnhancerByCloudStack_550a6c02
INFO  [c.c.s.ManagementServerImpl] (Timer-3:null) Startup CloudStack management server...
INFO  [c.c.c.ClusterServiceServletContainer] (Thread-18:null) Cluster service servlet container listening on port 9090
INFO  [c.c.u.d.Merovingian2] (Timer-3:null) Cleaning up locks for 52238372990
INFO  [c.c.u.d.Merovingian2] (Timer-3:null) Released 0 locks for 52238372990
INFO  [c.c.c.ClusterManagerImpl] (Timer-3:null) register cluster listener class com.cloud.server.LockMasterListener
INFO  [c.c.c.ClusterManagerImpl] (Cluster-Heartbeat-1:null) We are good, no orphan management server msid in host table is found
INFO  [c.c.c.ClusterManagerImpl] (Cluster-Heartbeat-1:null) No inactive management server node found
WARN  [o.a.c.alerts] (Cluster-Notification-1:null)  alertType:: 14 // dataCenterId:: 0 // podId:: 0 // clusterId:: null // message:: Management server node 127.0.0.1 is up
WARN  [c.c.c.ClusterManagerImpl] (Cluster-Notification-1:null) Notifying management server join event took 76 ms
複製代碼

啓動成功。

打開瀏覽器,訪問URL:http://localhost:8080/client

輸入

用戶名:admin

密碼:password

可登錄。

打開eclipse,我們以遠程可調試方式啓動cloudstack,回到Eclipse工具中,點菜單「Run」,選擇Debug Configurations

在出現的調試配置對話框中,我們點 New 創建一個新的Remote Java Application 配置。

設置eclipse 遠程調試run,我們在Connect Tab頁中,設置如下

選擇遠程調試使用的源代碼,在Source Tab頁中,點Add 按鈕,從Java Project中增加源代碼

出現的工程中,我們全部選擇上。

點Debug.

打上斷點,然後運行,就可以進行調試了。