Ambari Server编译报错

版本号不一致导致的Ambari Server编译报错

Ambari Server的ambari-metrics-common依赖

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Ambari Main ....................................... SUCCESS [19.820s]
[INFO] Apache Ambari Project POM ......................... SUCCESS [0.835s]
[INFO] Ambari Web ........................................ SUCCESS [37.145s]
[INFO] Ambari Views ...................................... SUCCESS [7.536s]
[INFO] Ambari Admin View ................................. SUCCESS [5:02.761s]
[INFO] ambari-metrics .................................... SUCCESS [3.859s]
[INFO] Ambari Metrics Common ............................. SUCCESS [5.188s]
[INFO] Ambari Metrics Hadoop Sink ........................ SUCCESS [10.753s]
[INFO] Ambari Metrics Flume Sink ......................... SUCCESS [5.335s]
[INFO] Ambari Metrics Kafka Sink ......................... SUCCESS [5.929s]
[INFO] Ambari Metrics Storm Sink ......................... SUCCESS [17.246s]
[INFO] Ambari Metrics Collector .......................... SUCCESS [5:49.381s]
[INFO] Ambari Metrics Monitor ............................ SUCCESS [9.156s]
[INFO] Ambari Metrics Assembly ........................... SUCCESS [5:10.913s]
[INFO] Ambari Server ..................................... FAILURE [29.396s]
[INFO] Ambari Agent ...................................... SKIPPED
[INFO] Ambari Client ..................................... SKIPPED
[INFO] Ambari Python Client .............................. SKIPPED
[INFO] Ambari Groovy Client .............................. SKIPPED
[INFO] Ambari Shell ...................................... SKIPPED
[INFO] Ambari Python Shell ............................... SKIPPED
[INFO] Ambari Groovy Shell ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18:39.688s
[INFO] Finished at: Wed Jun 22 09:57:27 CST 2016
[INFO] Final Memory: 153M/366M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ambari-server: Could not resolve dependencies for project org.apache.ambari:ambari-server:jar:2.2.1.1: Could not find artifact org.apache.ambari:ambari-metrics-common:jar:2.2.1.1 in oss.sonatype.org (https://oss.sonatype.org/content/groups/staging) -> [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/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ambari-server

这次实验试图把Ambari编译到2.2.1.1版本,然而编译到Ambari Server的时候失败了,报错信息中提示Ambari Server依赖的ambari-metrics-common:jar:2.2.1.1无法找到。我们进入以下目录查看发现Ambari Metrics Common模块生成的jar包是2.2.1.0.0版本的,而Ambari Server依赖需要的是2.2.1.1版本的:

/ambari-branch-2.2.1/ambari-metrics/ambari-metrics-common/target/ambari-metrics-common-2.2.1.0.0.jar

导致该问题出现的原因,就是上面提到的Ambari Metrics模块未继承Ambari Main的版本号,导致 Ambari Metrics模块版本号与其他模块不一致。

参照官方对该版本不一致问题的解释:
https://cwiki.apache.org/confluence/display/AMBARI/Ambari+Development

RHEL/CentOS 6:
mvn versions:set -DnewVersion=${AMBARI_VERSION}

#Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM.
#Hence you also need to set ambari-metrics project version as well.
pushd ambari-metrics
mvn versions:set -DnewVersion=${AMBARI_VERSION}
popd

mvn -B clean install package rpm:rpm -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl

解决方案

上面官方的解释中也提到了解决方案,就是在编译前对Ambari Metrics模块再单独进行一次版本更改,使Ambari Metrics模块与Ambari其他模块的版本号保持一致。
然而个人以为官方文档中对版本号的解释有问题:

Note: Replace ${AMBARI_VERSION} with a 4-digit version you want the artifacts to be (e.g., -DnewVersion=1.6.1.1)

官方说明的版本号格式为4个数字,如1.6.1.1格式。这个格式对Ambari Main系的模块来说是没问题的,但是对Ambari Metrics系的模块来讲就是无效的格式,参考前面“版本号格式导致的ambari-metrics编译报错”。

稳妥的解决方案就是把Ambari Main系和Ambari Metrics系的版本号统一设置为5个数字格式,如2.2.1.1.0。

以我的项目为例:

# cd /ambari/ambari-branch-2.2.1
# mvn clean
修改Ambari主项目版本号:
# mvn versions:set -DnewVersion=2.2.1.1.0
修改Ambari Metrics版本号:
# pushd ambari-metrics
# mvn versions:set -DnewVersion=2.2.1.1.0
# popd
编译项目:
# cd /ambari/ambari-branch-2.2.1
# mvn -B install package rpm:rpm -DnewVersion=2.2.1.1.0 -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl

更多关于Ambari版本号的问题,可以参考我的另外一篇文章:http://blog.csdn.net/royma_1990/article/details/51749981#t18

阅读更多
换一批

没有更多推荐了,返回首页