分类: 云计算
2015-04-03 08:51:49
原文链接:http://feder.blog.51cto.com/8889763/1408117#559183-tsina-1-71903-ed0973a0c870156ed15f06a6573c8bf0
第一次写长文,快写完了,没保存草稿,2个小时的心血没了。。就不废话了,直接写重点
首先,下载cloudstack4.3源代码,并解压
1
2
|
$wget
$tar -zxvf apache-cloudstack-4.3.0-src.tar.bz2
|
1.安装所需软件
1
2
|
# 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
1
2
3
|
$ 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配置环境变量
1
|
$ 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/
然后使配置立即生效
1
|
$source /etc/profile
|
检查java与maven的环境变量是否配置成功
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[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文件夹
1
2
3
4
5
6
|
$ cd deps
$ wget
$ wget
$ wget
$ wget
$ wget
|
这里要注意,对于CS4.3来说,netscaler的jar包(另外的)已经不必再手动下载,但是在后面执行install-non-oss.sh脚本以及编译的时候还是会检查这个jar包,这会导致报错,此为BUG,直接无视即可
另外,对于Xenserver来说,还需要一个名为的文件,下载到cloudstack源代码的
/vm/hypervisor/xenserver/目录即可
再回到deps文件夹,为刚才下载的jar包改名,并执行install-non-oss.sh脚本
1
2
3
4
5
6
7
|
$ 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编译
1
2
|
$ mvn clean
$ mvn install -Dnoredist
|
等待编译结束,如果提示success,则编译成功,否则,参看本文最后一部分,尝试解决
编译成功后,在dist/rpmbuild/RPMS/x86_64/可以看到如下7个rpm文件:
1
2
3
4
5
6
7
8
9
|
[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
1
|
# yum install httpd
|
配置httpd
1
|
$ vim /etc/httpd/conf/httpd.conf
|
找到“UserDir disable”,在其前面加上“#”注释掉
去掉“UserDir public_html” 前的注释,并将其中的“public_html”改为/var/www/users/
添加
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
Order deny,allow
Deny from all
#
|
在/var/www下建立好users目录及用户目录kin(系统必须确实存在kin这个用户),并在kin目录下创建repo文件夹:
1
|
# mkdir -p /var/www/users/kin/repo
|
重启http服务,在浏览器地址栏输入:本机IP/~kin/,回车即可看到创建的repo目录
4.2创建yum repo
将编译的rpm包制作成repo
1
2
|
$ cp dist/rpmbuild/RPMS/x86_64/*rpm /var/www/users/kin/repo
$ createrepo ~/tmp/repo
|
然后,配置repo文件
1
|
# vim /etc/yum.repos.d/cloudstack.repo
|
写入
1
2
3
4
5
|
[apache-cloudstack]
name=Apache CloudStack
baseurl=~kin/repo //这里跟据http服务器的配置写
enabled=1
gpgcheck=0
|
5.安装cloudstack-management
1
2
|
# yum clean all
# yum install cloudstack-management -y
|
6.错误处理
使用maven编译时很可能出错,比如
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
[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]
[ERROR]
[ERROR] After correcting the problems, you can resume the build withthe command
[ERROR] mvn
error: Bad exit status from /var/tmp/rpm-tmp.uKNLdw (%build)
|
我在网上找到了解决方法,这是因为下载的这些jar包有问题,删除掉,自己手动下载即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# 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
# 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
# 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
# cd /root/.m2/repository/org/opensaml/opensaml1/1.1/
# mv opensaml1-1.1.jar opensaml1-1.1.jar.html
# wget
# cd /root/.m2/repository/commons-lang/commons-lang/2.3/
# mv commons-lang-2.3.jar commons-lang-2.3.jar.html
# wget
# cd /root/.m2/repository/bouncycastle/bcprov-jdk14/140/
# mv 140/bcprov-jdk14-140.jar bcprov-jdk14-140.jar.html
# wget
|
本文仅介绍了Cloudstack的编译,以及management的安装,具体配置以及agent相关的东西下次会进行讲解。再往后的东西可能会跟暗 黑魔君大大的博文有重叠,但是正如我的第一篇博客提到的,我的博文是为跟我一样的菜鸟服务的,一些地方会进行详细的说明,这些都是让我纠结了很久的。另外 要谢谢吴先生对我的指导