第一次写长文,快写完了,没保存草稿,2个小时的心血没了。。就不废话了,直接写重点
首先,下载cloudstack4.3源代码,并解压
$wget http://mirror.esocc.com/apache/cloudstack/releases/4.3.0/apache-cloudstack-4.3.0-src.tar.bz2 $tar -zxvf apache-cloudstack-4.3.0-src.tar.bz2
1.安装所需软件
# yum groupinstall "Development Tools" # yum install java-1.6.0-openjdk-devel.x86_64 genisoimage mysql mysql-server ws-commons-util MySQL-python tomcat6 createrepo
maven需要手动下载并安装,不同版本的Cloudstack可能需要不同版本的maven,到maven官网上下载即可,我用的是apache-maven-3.2.1,将其解压到想要安装的目录,我的是/usr/local
$ mv apache-maven-3.0.4-bin.tar.gz /usr/local $ cd /usr/local $ tar -zxvf apache-maven-3.2.1-bin.tar.gz
为java、maven配置环境变量
$ vim /etc/profile
将下列三行添加到profile文件的末尾
export M2_HOME=/usr/local/apache-maven-3.2.1
export PATH=$PATH:$M2_HOME/bin
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/
然后使配置立即生效
$source /etc/profile
检查java与maven的环境变量是否配置成功
[root@localhost Downloads]# mvn --version Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T01:37:52+08:00) Maven home: /home/kin/software/apache-maven-3.2.1 Java version: 1.6.0_30, vendor: Sun Microsystems Inc. Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-431.11.2.el6.x86_64", arch: "amd64", family: "unix" [root@localhost Downloads]# [root@localhost Downloads]# [root@localhost Downloads]# java -version java version "1.6.0_30" OpenJDK Runtime Environment (IcedTea6 1.13.3) (rhel-5.1.13.3.el6_5-x86_64) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
2.非开源软件依赖
如果你需要支持VMware、NetApp、F5、NetScaler、SRX等非开源软件,由于它们可能使用了非开源或者与Cloudstack协议不兼容的依赖,你需要手动下载这些jar包或文件到Cloudstack 源代码根目录的deps文件夹
$ cd deps $ 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
这里要注意,对于CS4.3来说,netscaler的jar包(另外的)已经不必再手动下载,但是在后面执行install-non-oss.sh脚本以及编译的时候还是会检查这个jar包,这会导致报错,此为BUG,直接无视即可
另外,对于Xenserver来说,还需要一个名为vhd-util的文件,下载到cloudstack源代码的
/vm/hypervisor/xenserver/目录即可
再回到deps文件夹,为刚才下载的jar包改名,并执行install-non-oss.sh脚本
$ 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
3.编译
切换到cloudstack源代码根目录,使用maven编译
$ mvn clean $ mvn install -Dnoredist
等待编译结束,如果提示success,则编译成功,否则,参看本文最后一部分,尝试解决
编译成功后,在dist/rpmbuild/RPMS/x86_64/可以看到如下7个rpm文件:
[root@localhost apache-cloudstack-4.3.0-src]# cd ./dist/rpmbuild/RPMS/x86_64/ [root@localhost x86_64]# ls cloudstack-agent-4.3.0-1.el6.x86_64.rpm cloudstack-awsapi-4.3.0-1.el6.x86_64.rpm cloudstack-baremetal-agent-4.3.0-1.el6.x86_64.rpm cloudstack-cli-4.3.0-1.el6.x86_64.rpm cloudstack-common-4.3.0-1.el6.x86_64.rpm cloudstack-management-4.3.0-1.el6.x86_64.rpm cloudstack-usage-4.3.0-1.el6.x86_64.rpm
4.创建本地yum源
4.1搭建http服务器
安装httpd
# yum install httpd
配置httpd
$ vim /etc/httpd/conf/httpd.conf
找到“UserDir disable”,在其前面加上“#”注释掉
去掉“UserDir public_html” 前的注释,并将其中的“public_html”改为/var/www/users/
添加<Directory/var/www/users/*>,如下:
# # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # <Directory /var/www/users/*> AllowOverride FileInfo AuthConfig Limit Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory> #<Directory /home/*/public_html>
在/var/www下建立好users目录及用户目录kin(系统必须确实存在kin这个用户),并在kin目录下创建repo文件夹:
# mkdir -p /var/www/users/kin/repo
重启http服务,在浏览器地址栏输入:本机IP/~kin/,回车即可看到创建的repo目录
4.2创建yum repo
将编译的rpm包制作成repo
$ cp dist/rpmbuild/RPMS/x86_64/*rpm /var/www/users/kin/repo $ createrepo ~/tmp/repo
然后,配置repo文件
# vim /etc/yum.repos.d/cloudstack.repo
写入
[apache-cloudstack] name=Apache CloudStack baseurl=http://localhost/~kin/repo //这里跟据http服务器的配置写 enabled=1 gpgcheck=0
5.安装cloudstack-management
# yum clean all # yum install cloudstack-management -y
6.错误处理
使用maven编译时很可能出错,比如
[INFO] Apache CloudStack AWS API Bridge .................. FAILURE [1.488s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6:19.165s [INFO] Finished at: Fri Sep 13 06:31:34 JST 2013 [INFO] Final Memory: 53M/416M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project cloud-awsapi: Compilation failure: Compilation failure: [ERROR] error: error reading /root/.m2/repository/org/apache/axis2/mex/1.5.4/mex-1.5.4-impl.jar; error in opening zip file [ERROR] error: error reading /root/.m2/repository/org/apache/axis2/axis2-mtompolicy/1.5.4/axis2-mtompolicy-1.5.4.jar; error in opening zip file [ERROR] error: error reading /root/.m2/repository/org/apache/ws/commons/axiom/axiom-dom/1.2.10/axiom-dom-1.2.10.jar; error in opening zip file [ERROR] error: error reading /root/.m2/repository/org/opensaml/opensaml1/1.1/opensaml1-1.1.jar; error in opening zip file [ERROR] error: error reading /root/.m2/repository/commons-lang/commons-lang/2.3/commons-lang-2.3.jar; error in opening zip file [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :cloud-awsapi error: Bad exit status from /var/tmp/rpm-tmp.uKNLdw (%build)
我在网上找到了解决方法,这是因为下载的这些jar包有问题,删除掉,自己手动下载即可
# cd /root/.m2/repository/org/apache/axis2/mex/1.5.4/ # mv mex-1.5.4-impl.jar mex-1.5.4-impl.jar.html # wget http://mirrors.ibiblio.org/maven2/org/apache/axis2/mex/1.5.4/mex-1.5.4-impl.jar # file mex-1.5.4-impl.jar mex-1.5.4-impl.jar: Zip archive data, at least v1.0 to extract # cd /root/.m2/repository/org/apache/axis2/axis2-mtompolicy/1.5.4/ # mv axis2-mtompolicy-1.5.4.jar axis2-mtompolicy-1.5.4.jar.html # wget http://mirrors.ibiblio.org/maven2/org/apache/axis2/axis2-mtompolicy/1.5.4/axis2-mtompolicy-1.5.4.jar # file axis2-mtompolicy-1.5.4.jar axis2-mtompolicy-1.5.4.jar: Zip archive data, at least v1.0 to extract # cd /root/.m2/repository/org/apache/ws/commons/axiom/axiom-dom/1.2.10/ # mv axiom-dom-1.2.10.jar axiom-dom-1.2.10.jar.html # wget http://mirrors.ibiblio.org/maven2/org/apache/ws/commons/axiom/axiom-dom/1.2.10/axiom-dom-1.2.10.jar # cd /root/.m2/repository/org/opensaml/opensaml1/1.1/ # mv opensaml1-1.1.jar opensaml1-1.1.jar.html # wget http://mirrors.ibiblio.org/maven2/org/opensaml/opensaml1/1.1/opensaml1-1.1.jar # cd /root/.m2/repository/commons-lang/commons-lang/2.3/ # mv commons-lang-2.3.jar commons-lang-2.3.jar.html # wget http://mirrors.ibiblio.org/maven2/commons-lang/commons-lang/2.3/commons-lang-2.3.jar # cd /root/.m2/repository/bouncycastle/bcprov-jdk14/140/ # mv 140/bcprov-jdk14-140.jar bcprov-jdk14-140.jar.html # wget http://repo1.maven.org/maven2/bouncycastle/bcprov-jdk14/140/bcprov-jdk14-140.jar
本文仅介绍了Cloudstack的编译,以及management的安装,具体配置以及agent相关的东西下次会进行讲解。再往后的东西可能会跟暗黑魔君大大的博文有重叠,但是正如我的第一篇博客提到的,我的博文是为跟我一样的菜鸟服务的,一些地方会进行详细的说明,这些都是让我纠结了很久的。另外要谢谢吴先生对我的指导