在VPS上申请一个虚拟机,几点建议:
用yum在系统中安装maven环境
yum install -y maven
Notice: 要用mvn --version检查maven的版本。 如果不满足要求需要自己下载安装包。
mvn --version
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_191, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.14.4.el7.x86_64", arch: "amd64", family: "unix"
通过mvn --version可以找到mvn的位置,到mvn根目录下的conf中找到setting.xml,对maven本地库的位置进行设置,需要增加的内容如下。
/home/.m2/repo
完成setting配置之后,返回到home目录下建立对应的 /home/.m2/repo 目录
yum install -y git
yum install -y rpm-build
yum install -y ant
yum install -y gcc
直接在/home目录下创建git目录作为挂载点。
[root@vultr ~] cd /home
[root@vultr home] mkdir git
[root@vultr git] git clone https://github.com/apache/ambari.git
使用 git branch -a查看远程分支
[root@vultr ambari]# git branch -a
* (detached from origin/release-2.7)
trunk
remotes/origin/1.x-branch
remotes/origin/2.6.2-maint
remotes/origin/HEAD -> origin/trunk
remotes/origin/ambari-rest-api-explorer
remotes/origin/branch-0.9
remotes/origin/branch-1.2
remotes/origin/branch-1.2.3
.......省略
我们需要checkout一个 2.7 release分支
git checkout remotes/origin/release-2.7
参考文献:
https://cwiki.apache.org/confluence/display/AMBARI/Installation+Guide+for+Ambari+2.7.0
mvn versions:set -DnewVersion=2.7.1.0.0
pushd ambari-metrics
mvn versions:set -DnewVersion=2.7.1.0.0
popd
mvn clean install rpm:rpm -DskipTests -Drat.skip=true
项目编译时可以选择的一些开关
如果担心编译时间过长,终端会退出,可以采用后台编译方式
nohup mvn clean install rpm:rpm -DskipTests -Drat.skip=true > /home/mvn.log 2>&1 &
采用下面命令监控编译过程
tail -f /home/mvn.log
编译好的rmp包位于“/ambari/ambari-server/target/rpm/ambari-server/RPMS/x86_64”(最后这个目录根据每个系统不一样)
yum install ambari-server*.rpm #This should also pull in postgres packages as well.
ambari-server setup
一路默认即可。
ambari-server start
问题:在ambari-metrics模块中,有几个大的tar包需要下载,会非常浪费时间和带宽
解决方案:本地安装个nginx,将这几个包用wget之后,放到nginx的html目录下。然后修改metrics中的Pom.xml文件中相应tar包的链接地址
systemctl start nginx
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:install-node-and-yarn (install node and yarn) on project ambari-web: The plugin
com.github.eirslett:frontend-maven-plugin:1.4 requires Maven version 3.1.0 -> [Help 1]
解决方法:到maven官网下载高版本的maven版本
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (psutils-compile) on project ambari-metrics-host-monitoring: An Ant Build
Exception has occured: exec returned: 1
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status
psutil/_psutil_linux.c:12:20: fatal error: Python.h: No such file or directory
#include ^ compilation terminated. error: command 'gcc' failed with exit status 1
解决方法
yum -y install python-devel.x86_64
检查一下是不是因为环境的内存不够。
[ERROR] Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.3:findbugs (findbugs) on project ambari-server: Unable to parse configuration of m
ojo org.codehaus.mojo:findbugs-maven-plugin:3.0.3:findbugs for parameter pluginArtifacts: Cannot assign configuration entry 'pluginArtifacts' with value '${plugin.artifacts}' of type java.util.Collections.UnmodifiableRandomAccessList to property of type java.util.ArrayList -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.3:findbugs (findbugs) on project a
mbari-server: Unable to parse configuration of mojo org.codehaus.mojo:findbugs-maven-plugin:3.0.3:findbugs for parameter pluginArtifacts: Cannot assign configuration entry 'pluginArtifacts' with value '${plugin.artifacts}' of type java.util.Collections.UnmodifiableRandomAccessList to property of type java.util.ArrayList
参考(https://stackoverflow.com/questions/18011494/failed-to-execute-goal-org-codehaus-mojoexec-maven-plugin1-2java-default-cli/33732632),提到可能java sdk 的兼容问题,将findbugs-maven-plugin版本升级到3.0.5,解决该问题。