ienki 发表于 2015-4-18 08:45:43

虚拟化平台cloudstack(6)——使用maven:jetty调试

调试环境
  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.iyunv.com/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,编译成功后会出现如下结果:



Reactor Summary:

Apache CloudStack ................................. SUCCESS
Apache CloudStack Utils ........................... SUCCESS
Apache CloudStack API ............................. SUCCESS
Apache XenSource XAPI ............................. SUCCESS
Apache CloudStack Core ............................ SUCCESS
Apache CloudStack Agents .......................... SUCCESS
Apache CloudStack SystemVM Patches ................ SUCCESS
Apache CloudStack Console Proxy ................... SUCCESS
Apache CloudStack Server .......................... SUCCESS
Apache CloudStack Usage Server .................... SUCCESS
Apache CloudStack Plugin POM ...................... SUCCESS
Apache CloudStack Plugin - User Concentrated Pod Deployment PlannerSUCCESS
Apache CloudStack Plugin - User Dispersing Deployment PlannerSUCCESS
Apache CloudStack Plugin - Host Allocator Random .. SUCCESS
Apache CloudStack Plugin - Hypervisor OracleVM .... SUCCESS
Apache CloudStack Plugin - Open vSwitch ........... SUCCESS
Apache CloudStack Plugin - Hypervisor Xen ......... SUCCESS
Apache CloudStack Plugin - Hypervisor KVM ......... SUCCESS
Apache CloudStack Plugin - Network Elastic Load BalancerSUCCESS
Apache CloudStack Plugin - Network Nicira NVP ..... SUCCESS
Apache CloudStack Plugin - Storage Allocator RandomSUCCESS
Apache CloudStack Plugin - User Authenticator LDAPSUCCESS
Apache CloudStack Plugin - User Authenticator MD5 . SUCCESS
Apache CloudStack Plugin - User Authenticator Plain TextSUCCESS
Apache CloudStack AWS API Bridge .................. SUCCESS
Apache CloudStack Test ............................ SUCCESS
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 12.256s
Finished at: Fri Aug 02 22:21:41 CST 2013
Final Memory: 25M/357M
------------------------------------------------------------------------
  然后运行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
在模块中加入以下参数
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包丢失,编译不过去



The POM for org.apache.cloudstack:cloud-plugin-user-authenticator-md5:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-user-authenticator-plaintext:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-network-nvp:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-network-ovs:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-network-elb:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-hypervisor-xen:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-hypervisor-ovm:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-hypervisor-kvm:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-storage-allocator-random:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-planner-user-dispersing:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-planner-user-concentrated-pod:jar:4.0.2 is missing, no dependency information available
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
The POM for org.apache.cloudstack:cloud-plugin-host-allocator-random:jar:4.0.2 is missing, no dependency information available
  找到对应的工程,然后执行mvn clean install,哪个出问题就在哪个工程上执行就可以了。
  
页: [1]
查看完整版本: 虚拟化平台cloudstack(6)——使用maven:jetty调试