lihai1107 发布于 2016/03/02 12:33
阅读 1K+
收藏 0

1.1 搭建虚拟机的VNC和桌面环境

1.1.1 CentOS 6.4安装图形界面并用VNC远程连接

#yum install -y tigervnc-server
#passwd   //设置root用户vnc远程连接的密码
#service vncserver start

#vi /root/.vnc/xstartup
注释掉twm &,添加gnome-session &
# twm &
gnome-session &

#vi /etc/sysconfig/vncservers
VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -localhost"

#service vncserver restart

5.安装X window System

#yum groupinstall -y 'X Window System'


#yum groupinstall -y 'Desktop'




#vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT

#/etc/init.d/iptables restart

9.使用VNC Client远程连接


1.2 搭建cloudstack开发环境


1.2.1  安装工具软件和依赖软件

#yum update

#yum upgrade

$yum install git ant ant-devel java-1.7.0-openjdk java-1.7.0-openjdk-devel mysql mysql-server tomcat6 mkisofs gcc python MySQL-python openssh-clients wget

1.2.2 设置Java环境变量

#vi /etc/profile


export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

export classpath=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

1.2.3  Set up Maven

$ wget http://www.us.apache.org/dist/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz

$ cd /usr/local/ # or any path

$ tar -zxvf apache-maven-3.0.5-bin.tar.gz


#vi /etc/profile


export M2_HOME=/usr/local/apache-maven-3.0.5

export PATH=${M2_HOME}/bin:${PATH}

1.2.4  配置tomcat


#wget https://archive.apache.org/dist/tomcat/tomcat-6/v6.0.33/bin/apache-tomcat-6.0.33.tar.gz

#tar xzvf apache-tomcat-6.0.33.tar.gz -C /usr/local


#vi /etc/profile


export CATALINA_BASE=/usr/local/apache-tomcat-6.0.33

export CATALINA_HOME=/usr/local/apache-tomcat-6.0.33


#chown -R <you>:<your-group> $CATALINA_HOME

1.2.5  Generate you ssh keys, useful for ssh-ing to your hosts and vm etc.:

    $ ssh-keygen -t rsa –q


1.2.6 配置MySQL Server

启动 MySQL service:

    $ service mysqld start


      #chkconfig mysql on




#source /etc/profile      或者      #./etc/profile,本人建议重启较好。

1.3 下载并编译源码

1.3.1 下载源码

使用git 下载cloudstack 4.3源码:#git clone -b 4.3 –recursive https://github.com/apache/cloudstack.git

1.3.2 数据库配置文件

进入cloudstack 源码目录,修改数据库配置 build/replace.properties

If you have a root password, copy db.properties to db.properties.override and put your password there. To customize hosts, password etc. just copy utils/conf/db.properties to utils/conf/db.properties.override (this is git ignored by default) and edit the properties as needed they will override the defaults in utils/conf/db.properties.

#cp utils/conf/db.properties utils/conf/db.properties.override

#vi utils/conf/db.properties.override

在文件中增加上刚刚上面设定的mysqlroot 账号和密码。

1.3.3 依赖和编译的处理  Cloudstack的依赖包下载和处理

#wget http://zooi.widodh.nl/cloudstack/build-dep/cloud-iControl.jar

#wget http://zooi.widodh.nl/cloudstack/build-dep/cloud-manageontap.jar

#wget http://zooi.widodh.nl/cloudstack/build-dep/vmware-vim.jar

#wget http://zooi.widodh.nl/cloudstack/build-dep/vmware-vim25.jar

#wget http://zooi.widodh.nl/cloudstack/build-dep/vmware-apputils.jar

#wget  http://zooi.widodh.nl/cloudstack/build-dep/cloud-netscaler-jars.zip

$ cd deps

$ mv cloud-manageontap.jar manageontap.jar

$ mv vmware-apputils.jar apputils.jar

$ mv vmware-vim.jar vim.jar

$ mv vmware-vim25.jar vim25_51.jar

$ unzip cloud-netscaler-jars.zip

$ ./install-non-oss.sh Building CloudStack

进入目录cloudstack 源码目录:


   1mvn clean

   2mvn -P deps  下载依赖

   3mvn install

   4mvn -P developer -Ddeploydb -pl developer  初始化数据库

   5、运行:mvn -pl client jetty:run



#vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT

#/etc/init.d/iptables restart Running a server for test/debug purposes.

One can use maven to deploy and debug the management server. First export the MAVEN_OPTS variable to open a transport socket on port 8787 (same as before).

$ export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=500m -Xdebug -Xrunjdwp:transport=



If you don't export using above configuration, the management server will run with no debugger attached. 常见问题

1、 如果出现内存不足的情况,可以设置 tomcat的jvm内存: export MAVEN_OPTS="-Xmx1024m -Xms256m -XX:PermSize=256m"

1.4 设置eclipsecloudstack开发环境

1.4.1 下载eclipse

These steps have been tested with Eclipse Indigo and Eclipse Juno- it's suggested you use that or a newer build.

1.4.2 Start with a clean workspace

To minimize confusion, start with a clean workspace with no other projects.

1.4.3 安装eclipse插件


eclipse的主界面中,Help—Install new Software

M2E  http://m2eclipse.sonatype.org/sites/m2e

PyDev  http://pydev.org/updates

EGit    http://download.eclipse.org/egit/updates

1.4.4 Import CloudStack

Now you can import CloudStack using the M2E plugin:

·         Go to File->Import...

·         Under Maven select "Existing Maven Projects" and click Next

·         Browse to and select the root directory of the CloudStack source tree. Once selected, Eclipse will scan the source for pom.xml files. Make sure all are selected, then click the Finish button.

Eclipse will import the projects and build the code. At this point you should be able to develop and debug code as usual within Eclipse.

1.4.5 Making Eclipse Work Better with CloudStack Give Eclipse More Memory

CloudStack is a big project and it requires more memory for Eclipse.  Here's how to give it more memory.

·         cd [eclipse home]

·         vi eclipse.ini

·         Change or add the following properties

·         -Xms1024m

·         -Xmx2048m

·         -XX:PermSize=512m

·         -XX:MaxPermSize=1024M Eliminate duplicate resources

CloudStack has a lot of projects that are really just for grouping the different type of projects.  The problem is in Eclipse, the files that belong in sub-projects also show up in the projects.  This causes a lot of problems with the Open Resource dialogue, which is often used to quickly get to a file if you know the filename already.  These problems include the multiple copies of the same .class files showing up and multiple copies of the same .java file showing up.  If you select the wrong .java file, then a lot of the references doesn't work.  Upon further inspection, the reason is because the same .java and .class file is included by both the project and the parent project.  To get rid of this problem, do the following.  Unfortunately, you have to do this for every parent project.

·         Right click on the project and select Properties.

·         Go to Resource->Resource Filters.

·         Click on Add...

·         Select Exclude all

·         Select Folders

·         Click Regular Expression

·         In the entry box, type [a-zA-Z0-9].*

·         Click OK

·         Click OK

What this does is to tell Eclipse that the sub-directories under parent projects should not be included in the resource list, thus avoiding the the duplicate resources in the Open Resource dialogue box.  If the parent project does have a directory that you want, then you can add that to a include filter.  Note that you can not use * as the folders because that would exclude the .settings folder which eclipse uses to keep its metadata and will cause the m2e plugin to have problems.

Here's a list of parent projects you should do this with:

·         cloudstack

·         cloudstack-framework

·         cloudstack-plugins

·         cloudstack-services

·         cloud-engine Avoiding conflicts between builds outside of Eclipse and Eclipse's auto-building

Eclipse by default uses the the Maven pom.xml to tell it where to put its generated files.  Unfortunately, that has one big disadvantage.  Everytime a "mvn clean" is done outside of Eclipse, Eclipse will start rebuilding.  To avoid this, CloudStack has an Eclipse profile that puts all of the Eclipse generated files in a directory called target-eclipse.  In order to activate this, you must do the following to every project.  There is a shortcut for the existing projects so please read the shortcut first before deciding to do the following.  You still need to perform these steps manually if a new project is added after you ran the shortcut.

·         Right click on the project and select Properties

·         Select Maven

·         In the entry box under "Active Maven Profile", type in eclipse

·         Click OK

CloudStack has a lot of projects so doing the above by hand for every project takes time so here's a shortcut provided for existing projects.

·         Exit Eclipse (assuming you've already installed the m2e plugin)

·         cd [cloudstack home]

·         bash -x tools/eclipse/set-eclipse-profile.sh

·         Restart Eclipse

1.4.6 Remote Debugging

You can use Eclipse to attach to the Management Server and debug CloudStack. You setup a Remote Debug Session (Run > Debug Configuration), connect to Port 8787. Typically you would use the project you want to debug as the target and include other projects that you need to debug, e.g. cloud-agent, cloud-api, cloud-core and cloud-server.

1.4.7 Eclipse 调试

Eclipse 导入源码,后执行mvn clean,如下图所示:

执行 mvn -P deps 如下图所示:









1.5 Simulator的安装和使用



1.5.1 升级Python2.6Python2.7 安装依赖

#yum groupinstall -y 'development tools'

#yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget 源码安装Python 2.7.x

#wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz

#xz -d Python-2.7.8.tar.xz

#tar -xvf Python-2.7.8.tar


#cd Python-2.7.8

运行配置 configure:

#./configure --prefix=/usr/local



#make altinstall

检查 Python 版本:

# python2.7 -V

Python 2.7.8


#mv /usr/bin/python  /usr/bin/python2.6

#ln -s /usr/local/bin/python2.7  /usr/bin/python

# which yum


修改 yum中的python

将第一行  #!/usr/bin/python  改为 #!/usr/bin/python2.6


1.5.2 安装 setuptools

#wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz

  #tar -zxvf setuptools-1.4.2.tar.gz

  #cd setuptools-1.4.2

#python setup.py install

1.5.3 安装PIP

#wget https://bootstrap.pypa.io/get-pip.py

#python  get-pip.py

或者:#easy_install pip

1.5.4 安装mysql-connector-python

# wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.11.zip 

# unzip mysql-connector-python-1.0.11.zip 

# cd mysql-connector-python-1.0.11  

# python setup.py install 

1.5.5 安装和配置Marvin

#cd  cloudstack/tools/marvin

#python  setup.py install

1.6 启用simulator


#mvn -Pdeveloper -Dsimulator -DskipTests clean install

mvn -Pdeveloper -Dsimulator  -Dmaven.test.skip=true

mvn clean install -Dmaven.test.skip=true

#mvn -Pdeveloper -pl developer -Ddeploydb  (重新初始化数据库)

#mvn -Pdeveloper -pl developer -Ddeploydb-simulator

# mvn install -Dnoredist  (init)

mvn -Pdeveloper,marvin.sync -Dendpoint=localhost -pl :cloud-marvin(同步)

#pip install tools/marvin/dist/Marvin-0.1.0.tar.gz

# mvn -Dsimulator -pl client jetty:run

mvn -Dsimulator -Dnoredist -pl client jetty:run




#mvn -Pdeveloper,marvin.setup -Dmarvin.config=setup/dev/basic.cfg -pl :cloud-marvin integration-test


#mvn -Pdeveloper,marvin.setup -Dmarvin.config=setup/dev/advanced.cfg -pl :cloud-marvin integration-tes