开发者社区> 问答> 正文

启用simulator报错

《cloudstack开发环境的搭建》 1.1 搭建虚拟机的VNC和桌面环境 1.2 搭建cloudstack开发环境 1.3 下载并编译源码 1.4 设置eclipse的cloudstack开发环境 1.5 Simulator的安装和使用 1.6 启用simulator报错 

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

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

1.安装VNC服务 #yum install -y tigervnc-server #passwd   //设置root用户vnc远程连接的密码 #service vncserver start

2.修改vnc服务桌面配置文件 #vi /root/.vnc/xstartup 注释掉twm &,添加gnome-session & # twm & gnome-session &

3.修改vnc服务配置文件 #vi /etc/sysconfig/vncservers 编辑文本最后两行,先将注释符号去掉,在将内容修改为如下: VNCSERVERS="1:root"  VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -localhost"

4.重启vnc服务 #service vncserver restart

5.安装X window System

#yum groupinstall -y 'X Window System'

6.安装GNOME

#yum groupinstall -y 'Desktop'

7.启动GNOME

#startx

8.设置防火墙

#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远程连接

在连接地址中输入ip:5901,如:10.204.119.131:5901

1.2 搭建cloudstack开发环境

https://cwiki.apache.org/confluence/display/CLOUDSTACK/Setting+up+CloudStack+Development+Environment+on+Linux

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-1.7.0.79.x86_64

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

设置环境变量到配置文件/etc/profile,使得所有用户都可以使用这些配置项

#vi /etc/profile

在文件的最后增加下面的参数

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

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

1.2.4  配置tomcat

目前4.3版本较好地支持tomcat版本6.0.33,所以使用该版本更好

#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

设置环境变量CATALINA_HOME作为tomcat的解压或者安装路径

#vi /etc/profile

文件底部增加

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

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

设置tomcat的用户组和权限

#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

全部按Enter键即可,不需要输入其他信息。

1.2.6 配置MySQL Server

启动 MySQL service:

    $ service mysqld start

设置开机启动

      #chkconfig mysql on

设置mysql的root密码

#mysql_secure_installation

为了使得配置文件起效,可以重启虚拟机,也可以使用命令来使得配置文件起效:

#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

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

1.3.3 依赖和编译的处理

1.3.3.1  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

1.3.3.2 Building CloudStack

进入目录cloudstack 源码目录:

执行:

   1、mvn clean

   2、mvn -P deps  下载依赖

   3、mvn install

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

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

CloudStack管理服务器就在运行状态了,通过http://localhost:8080/client访问初始化页面。初始登录用户:root,密码:password

如果需要在虚拟机外面登陆到上面的界面,需要设置好防火墙

#vi /etc/sysconfig/iptables

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

#/etc/init.d/iptables restart

1.3.3.3 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= dt_socket,address=8787,server=y,suspend=n" 也可以写到配置文件/etc/profile的底部中去。

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

1.3.3.4 常见问题

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

1.4 设置eclipse的cloudstack开发环境

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插件

一共安装三种插件M2E、PyDev、EGit插件。

在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

1.4.5.1 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

1.4.5.2 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

1.4.5.3 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的安装和使用

Simulator可以很好地在cloudstack的开发和测试环境中被开发人员使用,所有使用simulator对cloudstack的开发人员很有作用和意义。

在开始这部分的时候,已经默认上面的的cloudstack的开发环境和编译环境已经全部完成。这时才开展下面的模块。

1.5.1 升级Python2.6到Python2.7

1.5.1.1 安装依赖

#yum groupinstall -y 'development tools'

#yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget 1.5.1.2 源码安装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

#make altinstall

检查 Python 版本:

# python2.7 -V

Python 2.7.8

设置Python的软连接,这样会导致yum的不可用,需要做修改

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

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

# which yum

/usr/bin/yum

修改 yum中的python

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

此时yum修复完毕。

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

进入到cloudstack的源码的根目录之下执行下面的命令:

#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

 

在命令行另外一个窗口打开,再继续下面的操作,上面的Jetty要保持在运行中。

启用基本网络模式的simulator:

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

启用高级网络模式的simulator:

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

展开
收起
kun坤 2020-06-10 10:11:46 1264 0
2 条回答
写回答
取消 提交回答
  • 666666666666666666666

    2020-06-11 15:11:22
    赞同 展开评论 打赏
  • 精于基础,广于工具,熟于业务。

    不错。好用

    2020-06-10 17:08:45
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Architecting a Multi-Tenanted Platform 立即下载
Froma single droplet toafull b 立即下载
Architecting a Multi-Tenanted 立即下载