Ambari2.7.5源码编译安装及遇到的问题解决有这一篇文章就够了

本文详细记录了Ambari 2.7.5源码的编译过程,包括准备工作、源码编译中的各种问题及其解决方案,如依赖包下载、环境配置、编译错误等。遇到的问题涵盖maven版本、rpm、node、python等多个方面,提供了详细的解决步骤和命令示例。
摘要由CSDN通过智能技术生成

本篇博客列举的所有命令行操作及问题大部分是真实遇到的,还有部分没有遇到,其他博主遇到了也总结到这个博客下,在此贴出前几位博主的链接,也都是大神,希望大家多多支持
如操作过程中遇到什么疑问,或文章内容有什么不严谨的地方
请在评论区留言指出,我会第一时间更正

参考链接

https://xuemengran.blog.csdn.net/article/details/108626421

https://www.cnblogs.com/wang--lei/p/8257238.html

https://www.cnblogs.com/barneywill/p/10264135.html

https://blog.csdn.net/whq12789/article/details/104840597/

一. 准备工作

1.1 获取Ambari2.7.5源码

wget http://archive.apache.org/dist/ambari/ambari-2.7.5/apache-ambari-2.7.5-src.tar.gz

# 附1 wget命令安装方法:  yum install wget
# 附2 使用wget命令如遇报错:Unable to locally verify the issuer's authority  需要在wget命令后面加上--no-check-certificate 参数
tar -zxvf apache-ambari-2.7.5-src.tar.gz
  •  

1.2 搭建编译环境

1.2.1 配置java环境

注意Ambari2.7要求的最低版本为JDK8

vi ~/.bashrc
  •  
export JAVA_HOME=/user/local/src/jdk1.8.0_151 #以自己配置为准
export PATH=$JAVA_HOME/bin:$PATH
export _JAVA_OPTIONS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"

source ~/.bashrc

1.2.2 配置maven环境

注意:ambari适配的maven版本最低为3.3.9,个别出现版本兼容问题(具体参看问题3.5)

vi ~/.bashrc
export MAVEN_HOME=/opt/modules/apache-maven-3.5.3 #以自己配置为准
export PATH=$MAVEN_HOME/bin:$PATH

source ~/.bashrc

1.2.3 安装rpm和rpmbuild

yum install rpm
yum install rpm-build  

1.2.4 安装g++

yum install gcc-c++

1.2.5 检查python版本

注意:ambari要求python的版本为2.6+
一般使用系统自带的就OK

# 检查python版本,低于2.6的重新安装
python -V 

1.2.6 初始化python-devel

yum install python-devel

1.2.7 安装bower, gulp


# 附 npm命令安装方式: yum install npm
npm install -g bower
npm install -g gulp

1.2.8 安装git

yum install git

1.2.9 安装python setuptools

wget https://pypi.python.org/packages/45/29/8814bf414e7cd1031e1a3c8a4169218376e284ea2553cc0822a6ea1c2d78/setuptools-36.6.0.zip#md5=74663b15117d9a2cc5295d76011e6fd1

unzip setuptools-36.6.0.zip  # 附 unzip安装命令:yum install -y unzip zip
cd setuptools-36.6.0
python setup.py install

1.2.10 设置最大打开文件数

linux系统默认最大打开文件数为1024
在源码编译过程中最大打开文件数可能超过该限制报错:

too many files are open而导致编译失败,所以需要修改最大打开文件数限制

ulimit -n 10000  

二. 源码编译

2.1 配置阿里云远程仓库

2.1.1为了能够提高编译过程中依赖包下载效率,maven可以配置阿里远程仓库

vi $MAVEN_HOME/conf/settings.xml

<!--在mirrors标签里添加mirror标签,内容如下:-->
    <mirror>
        <id>alimaven</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>

 2.1.2 觉得下载依赖包特别慢的,可以在pom.xml添加阿里云镜像

vi pom.xml

添加相应节点:

<repositories>
    <repository>
        <id>aliyun</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-apache snapshots</id>
        <url>https://maven.aliyun.com/repository/apache-snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-central</id>
        <url>https://maven.aliyun.com/repository/central</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-google</id>
        <url>https://maven.aliyun.com/repository/google</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-gradle-plugin</id>
        <url>https://maven.aliyun.com/repository/gradle-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-jcenter</id>
        <url>https://maven.aliyun.com/repository/jcenter</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-spring</id>
        <url>https://maven.aliyun.com/repository/spring</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-spring-plugin</id>
        <url>https://maven.aliyun.com/repository/spring-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-public</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-releases</id>
        <url>https://maven.aliyun.com/repository/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-snapshots</id>
        <url>https://maven.aliyun.com/repository/snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-grails-core</id>
        <url>https://maven.aliyun.com/repository/grails-core</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-mapr-public</id>
        <url>https://maven.aliyun.com/repository/mapr-public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>aliyun-plugin</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-apache snapshots</id>
        <url>https://maven.aliyun.com/repository/apache-snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-central</id>
        <url>https://maven.aliyun.com/repository/central</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-google</id>
        <url>https://maven.aliyun.com/repository/google</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-gradle-plugin</id>
        <url>https://maven.aliyun.com/repository/gradle-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-jcenter</id>
        <url>https://maven.aliyun.com/repository/jcenter</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-spring</id>
        <url>https://maven.aliyun.com/repository/spring</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-spring-plugin</id>
        <url>https://maven.aliyun.com/repository/spring-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-public</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-releases</id>
        <url>https://maven.aliyun.com/repository/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-snapshots</id>
        <url>https://maven.aliyun.com/repository/snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-grails-core</id>
        <url>https://maven.aliyun.com/repository/grails-core</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-mapr-public</id>
        <url>https://maven.aliyun.com/repository/mapr-public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

2.1.3 大包提前下载 

hadoop等包

下载很慢,可以提前下载

vi ambari-metrics/pom.xml

找到

<hbase.tar>https://s3.amazonaws.com/dev.hortonworks.com/HDP/centos7/3.x/BUILDS/3.1.4.0-315/tars/hbase/hbase-2.0.2.3.1.4.0-315-bin.tar.gz</hbase.tar>

<hbase.folder>hbase-2.0.2.3.1.4.0-315</hbase.folder>

<hadoop.tar>https://s3.amazonaws.com/dev.hortonworks.com/HDP/centos7/3.x/BUILDS/3.1.4.0-315/tars/hadoop/hadoop-3.1.1.3.1.4.0-315.tar.gz</hadoop.tar>

<hadoop.folder>hadoop-3.1.1.3.1.4.0-315</hadoop.folder>

<grafana.folder>grafana-6.4.2</grafana.folder>

<grafana.tar>https://dl.grafana.com/oss/release/grafana-6.4.2.linux-amd64.tar.gz</grafana.tar>

<phoenix.tar>https://s3.amazonaws.com/dev.hortonworks.com/HDP/centos7/3.x/BUILDS/3.1.4.0-315/tars/phoenix/phoenix-5.0.0.3.1.4.0-315.tar.gz</phoenix.tar>

<phoenix.folder>phoenix-5.0.0.3.1.4.0-315</phoenix.folder>

现在这些已无法从源下载,大家可以花点积分在CSDN上下载。而我就投机了下,下载了原生包,然后解压改变包的版本号,然后再部署到自己本地的web服务器上,再修改这个pom.xml中的url地址,下载使用更快捷

yum install httpd -y

然后在/var/wwww/html 目录下创建bigdata,将包上传到此目录
(附:service  {start|stop|restart|status|configtest|reload}  httpd)
启动 httpd   
service start httpd
链接改为 http://{你的host}/bigdata/....

2.2 源码编译安装(以下命令需要在ambari源码包的根目录下执行)

# 设置ambari版本
mvn versions:set-property -Dproperty=revision -DnewVersion=2.7.5.0.0 
pushd ambari-metrics
mvn versions:set -DnewVersion=2.7.5.0.0
popd

执行源码编译命令前,请先阅读第三部分,遇到的问题及解决方案,以免踩坑

# -DskipTests参数是为了跳过单元测试,提高编译效率
# -Drat.skip参数是为了跳过licensing 检查,防止报错Too many files with unapproved license
mvn -B clean install package rpm:rpm -DnewVersion=2.7.5.0.0 -DbuildNumber=5895e4ed6b30a2da8a90fee2403b6cab91d19972 -DskipTests -Drat.skip -Dpython.ver="python >= 2.6" -Preplaceurl 

出现如下界面,证明源码编译成功!

在这里插入图片描述

三. 遇到的问题及解决方案

3.1 Ambari Main编译报错: RPM build execution returned: ‘127’ executing

报错详情:

[INFO] Ambari Main ....................................... FAILURE [58:16.141s]

[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.0.1:rpm (default-cli) on project ambari: RPM build execution returned: '127' executing '/bin/sh -c cd /opt/ambari/apache-ambari-2.7.5-src/target/rpm/ambari/SPECS && rpmbuild -bb --buildroot /opt/ambari/apache-ambari-2.7.5-src/target/rpm/ambari/buildroot --define '_topdir /opt/ambari/apache-ambari-2.7.5-src/target/rpm/ambari' --target noarch-redhat-linux ambari.spec' -> [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/MojoExecutionException

报错原因:: rpm,或者rpm-build没有安装

解决方案:

# 安装rpm,rpm-build
yum install rpm
yum install rpm-build  

之后使用2.2的编译命令重新编译安装即可

解决结果:

# Ambari Main编译成功
[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  0.824 s]

3.2 Ambari Web编译报错: requires Maven version 3.1.0

报错详情:

[INFO] Reactor Summary:
[INFO] 
[INFO] Ambari Main ....................................... SUCCESS [0.873s]
[INFO] Apache Ambari Project POM ......................... SUCCESS [0.121s]
[INFO] Ambari Web ........................................ FAILURE [37.713s]

[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]
[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/PluginIncompatibleException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ambari-web

报错原因: maven版本的问题, ambari要求, maven版本最低为3.3.9

我这里报该错误的原因是配置了高版本的maven环境,但是没有使用source ~/.bashrc命令使改动生效

mvn -version
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_262, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.21.1.el7.x86_64", arch: "amd64", family: "unix"

解决方案

配置高版本maven,并使用source ~/.bashrc命令使改动生效

解决结果:

#Ambari Web编译成功
[INFO] Ambari Web ......................................... SUCCESS [ 55.379 s]

3.3 Ambari Admin View编译失败: Command execution failed. Process exited with an error: 1

问题详情:


Ambari2.7.5源码编译安装及遇到的问题解决有这一篇文章就够了
34/100
mcj1314bb


<没有设置>
error Unexpected token {

Stack trace:
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/bower-registry-client/node_modules/request/lib/cookies.js:3:13)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Console trace:
Trace
    at StandardRenderer.error (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/lib/renderers/StandardRenderer.js:72:17)
    at Logger.<anonymous> (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/bin/bower:111:22)
    at emitOne (events.js:77:13)
    at Logger.emit (events.js:169:7)
    at Logger.emit (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
    at /opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/lib/commands/index.js:40:20
    at _rejected (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:797:24)
    at /opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:823:30
    at Promise.when (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:1035:31)
    at Promise.promise.promiseDispatch (/opt/ambari/apache-ambari-2.7.5-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:741:41)

System info:
Bower version: 1.3.8
Node version: 4.5.0
OS: Linux 3.10.0-693.21.1.el7.x86_64 x64
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  0.814 s]
[INFO] Apache Ambari Project POM 2.7.5.0.0 ................ SUCCESS [  0.131 s]
[INFO] Ambari Web 2.7.5.0.0 ............................... SUCCESS [03:07 min]
[INFO] Ambari Views 2.7.5.0.0 ............................. SUCCESS [08:32 min]
[INFO] Ambari Admin View 2.7.5.0.0 ........................ FAILURE [02:46 min]

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (Bower install) on project ambari-admin: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [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/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :ambari-admin
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (Bower install) on project ambari-admin: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [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/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :ambari-admin


 

问题原因:

ambari-admin/pom.xml里默认的配置存在一些问题
nodeVersion,npmVersion配置项与实际不符

默认配置如下图:
在这里插入图片描述

使用如下命令查看npm和node的版本

npm -v  # 我的版本为3.10.10
node -v # 我的版本为v6.17.1

解决办法:

<!--修改ambari-admin模块下的pom.xml文件 -->
<nodeVersion>3.10.10</nodeVersion>
<npmVersion>v6.17.1</npmVersion>

解决结果:

# Ambari Admin View编译成功 
[INFO] Ambari Admin View .................................. SUCCESS [ 15.976 s]

3.4 Ambari Metrics Storm Sink编译失败: Could not resolve dependencies for project

报错详情:

[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  0.816 s]
[INFO] Apache Ambari Project POM 2.7.5.0.0 ................ SUCCESS [  0.131 s]
[INFO] Ambari Web 2.7.5.0.0 ............................... SUCCESS [ 55.226 s]
[INFO] Ambari Views 2.7.5.0.0 ............................. SUCCESS [  0.957 s]
[INFO] Ambari Admin View 2.7.5.0.0 ........................ SUCCESS [01:18 min]
[INFO] utility 1.0.0.0-SNAPSHOT ........................... SUCCESS [02:47 min]
[INFO] ambari-metrics 2.7.5.0.0 ........................... SUCCESS [ 10.792 s]
[INFO] Ambari Metrics Common 2.7.5.0.0 .................... SUCCESS [02:56 min]
[INFO] Ambari Metrics Hadoop Sink 2.7.5.0.0 ............... SUCCESS [03:15 min]
[INFO] Ambari Metrics Flume Sink 2.7.5.0.0 ................ SUCCESS [01:38 min]
[INFO] Ambari Metrics Kafka Sink 2.7.5.0.0 ................ SUCCESS [05:19 min]
[INFO] Ambari Metrics Storm Sink 2.7.5.0.0 ................ FAILURE [ 22.982 s]
.......................................................................................................................
[ERROR] Failed to execute goal on project ambari-metrics-storm-sink: Could not resolve dependencies for project org.apache.ambari:ambari-metrics-storm-sink:jar:2.7.5.0.0: Could not find artifact org.apache.storm:storm-core:jar:1.1.0-SNAPSHOT in apache-hadoop (http://repo.hortonworks.com/content/groups/public/) -> [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 <args> -rf :ambari-metrics-storm-sink


报错原因:

ambari-metrics模块下,ambari-metrics-storm-sink部分的pom.xml文件里
storm的版本号配置有误,按照配置的版本号无法在仓库找到对应jar包

下图为其默认配置:

在这里插入图片描述

解决方案:

修改ambari-metrics模块下,ambari-metrics-storm-sink部分的pom.xml文件,修改如下:

 <properties>
    <storm.version>1.1.0</storm.version>
  </properties>

解决结果:

# Ambari Metrics Storm Sink编译成功
[INFO] Ambari Metrics Storm Sink .......................... SUCCESS [  2.970 s]
[INFO] Ambari Metrics Storm Sink (Legacy) ................. SUCCESS [  2.400 s]

3.5 Ambari Server编译失败: Unable to parse configuration of mojo

详细报错:

[INFO] Downloaded from alimaven: http://maven.aliyun.com/nexus/content/repositories/central/org/codehaus/groovy/groovy-all/2.4.3/groovy-all-2.4.3.jar (7.0 MB at 2.9 MB/s)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  0.828 s]
[INFO] Apache Ambari Project POM 2.7.5.0.0 ................ SUCCESS [  0.126 s]
[INFO] Ambari Web 2.7.5.0.0 ............................... SUCCESS [ 55.103 s]
[INFO] Ambari Views 2.7.5.0.0 ............................. SUCCESS [  0.458 s]
[INFO] Ambari Admin View 2.7.5.0.0 ........................ SUCCESS [ 16.401 s]
[INFO] utility 1.0.0.0-SNAPSHOT ........................... SUCCESS [  0.079 s]
[INFO] ambari-metrics 2.7.5.0.0 ........................... SUCCESS [  0.319 s]
[INFO] Ambari Metrics Common 2.7.5.0.0 .................... SUCCESS [  5.443 s]
[INFO] Ambari Metrics Hadoop Sink 2.7.5.0.0 ............... SUCCESS [  2.458 s]
[INFO] Ambari Metrics Flume Sink 2.7.5.0.0 ................ SUCCESS [  2.046 s]
[INFO] Ambari Metrics Kafka Sink 2.7.5.0.0 ................ SUCCESS [  1.832 s]
[INFO] Ambari Metrics Storm Sink 2.7.5.0.0 ................ SUCCESS [  3.541 s]
[INFO] Ambari Metrics Storm Sink (Legacy) 2.7.5.0.0 ....... SUCCESS [  2.670 s]
[INFO] Ambari Metrics Collector 2.7.5.0.0 ................. SUCCESS [01:40 min]
[INFO] Ambari Metrics Monitor 2.7.5.0.0 ................... SUCCESS [  1.243 s]
[INFO] Ambari Metrics Grafana 2.1.0.0.0 ................... SUCCESS [  8.008 s]
[INFO] Ambari Metrics Assembly 2.7.5.0.0 .................. SUCCESS [01:01 min]
[INFO] Ambari Server 2.7.5.0.0 ............................ FAILURE [53:05 min]
[INFO] Ambari Functional Tests 2.7.5.0.0 .................. SKIPPED
[INFO] Ambari Agent 2.7.5.0.0 ............................. SKIPPED
[INFO] Ambari Client 2.7.5.0.0 ............................ SKIPPED
[INFO] Ambari Python Client 2.7.5.0.0 ..................... SKIPPED
[INFO] Ambari Groovy Client 2.7.5.0.0 ..................... SKIPPED
[INFO] Ambari Shell 2.7.5.0.0 ............................. SKIPPED
[INFO] Ambari Python Shell 2.7.5.0.0 ...................... SKIPPED
[INFO] Ambari Groovy Shell 2.7.5.0.0 ...................... SKIPPED
[INFO] ambari-logsearch 2.7.5.0.0 ......................... SKIPPED
[INFO] Ambari Logsearch Appender 2.7.5.0.0 ................ SKIPPED
[INFO] Ambari Logsearch Portal 2.7.5.0.0 .................. SKIPPED
[INFO] Ambari Logsearch Log Feeder 2.7.5.0.0 .............. SKIPPED
[INFO] Ambari Logsearch Solr Client 2.7.5.0.0 ............. SKIPPED
[INFO] Ambari Infra Solr Plugin 2.7.5.0.0 ................. SKIPPED
[INFO] Ambari Logsearch Assembly 2.7.5.0.0 ................ SKIPPED
[INFO] Ambari Logsearch Integration Test 2.7.5.0.0 ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  57:28 min
[INFO] Finished at: 2020-09-16T21:18:21+08:00
[INFO] ------------------------------------------------------------------------
[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 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 -> [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/PluginConfigurationException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :ambari-server

问题原因:

这个是maven导致的错误,可能的原因有两个:

  1. 如果maven版本是3.5.4以上,应该是版本过高导致的
  2. 还有一种可能就是Maven下载成功之后,修改了镜像或者是配置文件,有些jar包下载不下来导致的

解决方案: 降低maven版本(我最初配置的是3.6.3版本), 在3.3.9到3.5.4版本之间选择一个

配置之后的maven版本:
在这里插入图片描述

解决结果:

# 不再报该错误,报错The entity name must immediately follow the '&' in the entity reference
# 该错误请参考3.6

3.6  问题

[INFO] Downloading https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-x64.tar.gz to /root/.m2/repository/com/github/eirslett/node/4.5.0/node-4.5.0-linux-x64.tar.gz

[INFO] No proxies configured

[INFO] No proxy was configured, downloading directly

[INFO] Unpacking /root/.m2/repository/com/github/eirslett/node/4.5.0/node-4.5.0-linux-x64.tar.gz into /root/apache-ambari-2.7.5-src/ambari-web/node/tmp

……

[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: Could not extract the Node archive: Could not extract archive: '/root/.m2/repository/com/github/eirslett/node/4.5.0/node-4.5.0-linux-x64.tar.gz': EOFException -> [Help 1]

解决:

手动下载

curl -o /root/.m2/repository/com/github/eirslett/node/4.5.0/node-4.5.0-linux-x64.tar.gz https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-x64.tar.gz

3.7 报错

[ERROR] warning fsevents@0.3.8: The platform "linux" is incompatible with this module.

解决

npm install pm2@latest -g

pm2 install pm2-slack

(执行后上面的错误也还存在,但是可以往下走,这里发现了需要安装bower,安装这个即可)

安装bower的依赖包(个人在ambari-admin/src/main/resources/ui/admin-web/下执行)

bower install --allow-root 

3.8 报错

Failed to execute goal org.apache.rat:apache-rat-plugin:0.12:check (default) on project ambari: Too many files with unapproved license: 1 See RAT report in: /root/apache-ambari-2.7.5-src/target/rat.txt -> [Help 1]

 

解决(采用方案二)

一种方案是在新建的每一个类的第一行添加

 

/**

* Licensed to the Apache Software Foundation (ASF) under one

* or more contributor license agreements. See the NOTICE file

* distributed with this work for additional information

* regarding copyright ownership. The ASF licenses this file

* to you under the Apache License, Version 2.0 (the

* "License"); you may not use this file except in compliance

* with the License. You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

第二种解决方案:

在mvn命令中添加参数

apache-rat:check -Drat.numUnapprovedLicenses=600

数字600是一个大于报错信息中的数量。

 

 

3.9.报错

ClassNotFoundException : Com.Sun.Jersey.Spi.Container.Servlet.ServletContainer

解决

vi ambari-metrics/ambari-metrics-timelineservice/pom.xml

添加依赖(注意version与其他一致即可)

<dependency>

<groupId>com.sun.jersey</groupId>

<artifactId>jersey-bundle</artifactId>

<version>1.11</version>

</dependency>

 

4.0.报错

[exec] psutil/_psutil_linux.c:12:20: 致命错误:Python.h:没有那个文件或目录

[exec] #include <Python.h>

[exec] ^

[exec] 编译中断。

[exec] error: command 'gcc' failed with exit status 1

 

解决

yum install -y python-devel

 

4.1.报错

/root/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-aggregator/src/test/java/org/apache/hadoop/metrics2/host/aggregator/AggregatorWebServiceTest.java:[22,33] 程序包com.sun.jersey.api.client不存在

 

解决

vi ambari-metrics/ambari-metrics-host-aggregator/pom.xml

添加依赖

<dependency>

<groupId>com.sun.jersey</groupId>

<artifactId>jersey-client</artifactId>

<version>1.11</version>

</dependency>

4.2.报错

[ERROR] /root/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-aggregator/src/test/java/org/apache/hadoop/metrics2/host/aggregator/AggregatorWebServiceTest.java:[31,34] 程序包org.codehaus.jackson.jaxrs不存在

[ERROR] /root/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-aggregator/src/test/java/org/apache/hadoop/metrics2/host/aggregator/AggregatorWebServiceTest.java:[49,55] 找不到符号

符号: 类 JacksonJaxbJsonProvider

位置: 类 org.apache.hadoop.metrics2.host.aggregator.AggregatorWebServiceTest

解决

vi ambari-metrics/ambari-metrics-host-aggregator/pom.xml

添加依赖

<dependency>

<groupId>org.codehaus.jackson</groupId>

<artifactId>jackson-jaxrs</artifactId>

<version>1.9.13</version>

</dependency>

注意要看清是codehaus的,不是fasterxml的,别添加错了

4.3 Ambari Server编译失败: The entity name must immediately follow the ‘&’ in the entity reference

详细报错:

[INFO] Reactor Summary:
[INFO] 
[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  1.405 s]
[INFO] Apache Ambari Project POM .......................... SUCCESS [  0.131 s]
[INFO] Ambari Web ......................................... SUCCESS [ 55.516 s]
[INFO] Ambari Views ....................................... SUCCESS [  0.691 s]
[INFO] Ambari Admin View .................................. SUCCESS [ 17.159 s]
[INFO] utility 1.0.0.0-SNAPSHOT ........................... SUCCESS [  0.160 s]
[INFO] ambari-metrics ..................................... SUCCESS [  0.493 s]
[INFO] Ambari Metrics Common .............................. SUCCESS [  5.426 s]
[INFO] Ambari Metrics Hadoop Sink ......................... SUCCESS [  2.823 s]
[INFO] Ambari Metrics Flume Sink .......................... SUCCESS [  2.278 s]
[INFO] Ambari Metrics Kafka Sink .......................... SUCCESS [  1.986 s]
[INFO] Ambari Metrics Storm Sink .......................... SUCCESS [  2.937 s]
[INFO] Ambari Metrics Storm Sink (Legacy) ................. SUCCESS [  2.428 s]
[INFO] Ambari Metrics Collector ........................... SUCCESS [01:33 min]
[INFO] Ambari Metrics Monitor ............................. SUCCESS [  1.271 s]
[INFO] Ambari Metrics Grafana 2.1.0.0.0 ................... SUCCESS [  2.801 s]
[INFO] Ambari Metrics Assembly ............................ SUCCESS [01:14 min]
[INFO] Ambari Server ...................................... FAILURE [02:34 min]
[INFO] Ambari Functional Tests ............................ SKIPPED
[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] ambari-logsearch ................................... SKIPPED
[INFO] Ambari Logsearch Appender .......................... SKIPPED
[INFO] Ambari Logsearch Portal ............................ SKIPPED
[INFO] Ambari Logsearch Log Feeder ........................ SKIPPED
[INFO] Ambari Logsearch Solr Client ....................... SKIPPED
[INFO] Ambari Infra Solr Plugin ........................... SKIPPED
[INFO] Ambari Logsearch Assembly .......................... SKIPPED
[INFO] Ambari Logsearch Integration Test 2.7.5.0.0 ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 07:00 min
[INFO] Finished at: 2020-09-17T09:57:12+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:xml-maven-plugin:1.0:transform (default) on project ambari-server: Failed to transform input file /opt/ambari/apache-ambari-2.7.5-src/ambari-server/target/findbugs/findbugsXml.html: The entity name must immediately follow the '&' in the entity reference. -> [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/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ambari-server

问题原因:

从报错来看是&这个符号使用的问题,导致文件编译出现问题

具体的原因可参考stackoverflow的这篇问答:

The entity name must immediately follow the ‘&’ in the entity reference

解决方案:
因为报错的findbugsXml.html文件内容过多,找出文件问题并改正成本太高,所以选择了修改ambari-server的pom.xml文件,将findbugs部分内容注释掉:

需要注释部分的原文:
在这里插入图片描述

修改之后:

      <executions>
          <!-- <execution>
            <phase>verify</phase>
            <goals> 
              <goal>check</goal>
            </goals>
          </execution> -->
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
          <!--    
           <execution>
            <phase>verify</phase>
            <goals> 
              <goal>transform</goal>
            </goals>
          </execution>
          -->     
        </executions>

解决结果

# 该问题得到解决,编译时抛出了新的错误:
Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.4:rpm (default-cli) on project ambari-server

# 该问题的处理方法请参照3.7

4.4.报错:

[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: Could not extract the Yarn archive: Could not extract archive: '/root/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./yarn-v0.23.2.tar.gz': EOFException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:install-node-and-yarn (install node and yarn) on project ambari-web: Could not extract the Yarn archive: Could not extract archive: '/root/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./yarn-v0.23.2.tar.gz'
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

解决:

下载不完全,无法解压,手动下载https://github.com/yarnpkg/yarn/releases/download/v0.23.2/yarn-v0.23.2.tar.gz

替换/root/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./yarn-v0.23.2.tar.gz

# find ~/.m2/repository/ -name "*.lastUpdated" -exec rm -rf {} \;

重新从ambari-web开始编译

4.5.报错:

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:yarn (yarn install) on project ambari-web: Failed to run task: 'yarn install --ignore-engines --pure-lockfile' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:yarn (yarn install) on project ambari-web: Failed to run task
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

解决:

删除编译报错目录下的*.lock文件(个人将target目录一起删除),重新编译

4.6.报错

[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 BuildException has occured: exec returned: 1

[ERROR] around Ant part ...<exec failonerror="true" dir="/data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap">... @ 4:275 in /data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml

[ERROR] -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (psutils-compile) on project ambari-metrics-host-monitoring: An Ant BuildException has occured: exec returned: 1

around Ant part ...<exec failonerror="true" dir="/data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap">... @ 4:275 in /data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:498)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: exec returned: 1

around Ant part ...<exec failonerror="true" dir="/data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap">... @ 4:275 in /data/apache-ambari-2.7.3-src/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml

    at org.apache.maven.plugin.antrun.AntRunMojo.execute (AntRunMojo.java:355)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:498)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

Caused by: org.apache.tools.ant.BuildException: exec returned: 1

    at org.apache.tools.ant.taskdefs.ExecTask.runExecute (ExecTask.java:646)

    at org.apache.tools.ant.taskdefs.ExecTask.runExec (ExecTask.java:672)

    at org.apache.tools.ant.taskdefs.ExecTask.execute (ExecTask.java:498)

    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:291)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:498)

    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:106)

    at org.apache.tools.ant.Task.perform (Task.java:348)

    at org.apache.tools.ant.Target.execute (Target.java:390)

    at org.apache.tools.ant.Target.performTasks (Target.java:411)

    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1399)

    at org.apache.tools.ant.Project.executeTarget (Project.java:1368)

    at org.apache.maven.plugin.antrun.AntRunMojo.execute (AntRunMojo.java:327)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:498)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

解决:

这个看不出直接原因,错误是因为执行python返回1,具体的错误没报出来,只能手工重现问题;

首先看报错的脚本:

# cat /data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml

<?xml version="1.0" encoding="UTF-8" ?>

<project name="maven-antrun-" default="psutils-compile"  >

<target name="psutils-compile">

  <exec failonerror="true" dir="/data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap">

    <arg value="setup.py"/>

    <arg value="build"/>

    <arg value="--build-platlib"/>

    <arg value="/data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/target/psutil_build"/>

  </exec>

</target>

</project>

然后手工重现

# cd /data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil

# /data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap setup.py build --build-platlib /data/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-monitoring/target/psutil_build
running build
running build_py
running build_ext
building '_psutil_linux' extension
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 1

终于看到直接原因了,缺少gcc(你的原因可能不同,手工执行可以看到)

yum install gcc 

注意:这种情况也可能是下面两个导致

1、缺少cmake 和ant

     安装下 cmake和ant

2、yum install python-devel.x86_64

4.7 Ambari Server编译失败: Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.4:rpm (default-cli) on project ambari-server

[INFO] Bytecompiling .py files below /opt/ambari/apache-ambari-2.7.5-src/ambari-server/target/rpm/ambari-server/buildroot/usr/lib/python2.6 using /usr/bin/python2.6
[INFO] /usr/lib/rpm/brp-python-bytecompile: line 38: /usr/bin/python2.6: No such file or directory
[INFO] error: Bad exit status from /var/tmp/rpm-tmp.c817Ww (%install)
[INFO] 
[INFO] 
[INFO] RPM build errors:
[INFO]     Bad exit status from /var/tmp/rpm-tmp.c817Ww (%install)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  0.780 s]
[INFO] Apache Ambari Project POM .......................... SUCCESS [  0.132 s]
[INFO] Ambari Web ......................................... SUCCESS [ 55.137 s]
[INFO] Ambari Views ....................................... SUCCESS [  0.432 s]
[INFO] Ambari Admin View .................................. SUCCESS [ 16.003 s]
[INFO] utility 1.0.0.0-SNAPSHOT ........................... SUCCESS [  0.076 s]
[INFO] ambari-metrics ..................................... SUCCESS [  0.287 s]
[INFO] Ambari Metrics Common .............................. SUCCESS [  4.914 s]
[INFO] Ambari Metrics Hadoop Sink ......................... SUCCESS [  2.738 s]
[INFO] Ambari Metrics Flume Sink .......................... SUCCESS [  2.263 s]
[INFO] Ambari Metrics Kafka Sink .......................... SUCCESS [  1.938 s]
[INFO] Ambari Metrics Storm Sink .......................... SUCCESS [  2.701 s]
[INFO] Ambari Metrics Storm Sink (Legacy) ................. SUCCESS [  2.364 s]
[INFO] Ambari Metrics Collector ........................... SUCCESS [01:35 min]
[INFO] Ambari Metrics Monitor ............................. SUCCESS [  1.146 s]
[INFO] Ambari Metrics Grafana 2.1.0.0.0 ................... SUCCESS [  8.122 s]
[INFO] Ambari Metrics Assembly ............................ SUCCESS [01:24 min]
[INFO] Ambari Server ...................................... FAILURE [01:15 min]
[INFO] Ambari Functional Tests ............................ SKIPPED
[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] ambari-logsearch ................................... SKIPPED
[INFO] Ambari Logsearch Appender .......................... SKIPPED
[INFO] Ambari Logsearch Portal ............................ SKIPPED
[INFO] Ambari Logsearch Log Feeder ........................ SKIPPED
[INFO] Ambari Logsearch Solr Client ....................... SKIPPED
[INFO] Ambari Infra Solr Plugin ........................... SKIPPED
[INFO] Ambari Logsearch Assembly .......................... SKIPPED
[INFO] Ambari Logsearch Integration Test 2.7.5.0.0 ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:55 min
[INFO] Finished at: 2020-09-17T10:53:16+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.4:rpm (default-cli) on project ambari-server: RPM build execution returned: '1' executing '/bin/sh -c cd '/opt/ambari/apache-ambari-2.7.5-src/ambari-server/target/rpm/ambari-server/SPECS' && 'rpmbuild' '-bb' '--target' 'x86_64-redhat-linux' '--buildroot' '/opt/ambari/apache-ambari-2.7.5-src/ambari-server/target/rpm/ambari-server/buildroot' '--define' '_topdir /opt/ambari/apache-ambari-2.7.5-src/ambari-server/target/rpm/ambari-server' '--define' '_build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' '--define' '_builddir %{_topdir}/BUILD' '--define' '_rpmdir %{_topdir}/RPMS' '--define' '_sourcedir %{_topdir}/SOURCES' '--define' '_specdir %{_topdir}/SPECS' '--define' '_srcrpmdir %{_topdir}/SRPMS' 'ambari-server.spec'' -> [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/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :ambari-server

问题原因:

开始看到报错信息有rpm,认为是rpm,或者rpm-build没有安装导致的,使用命令行查看rpm,rpm-build都是正常的

后面在报错信息上面的INFO日志中看到如下信息:
/usr/lib/rpm/brp-python-bytecompile: line 38: /usr/bin/python2.7: No such file or directory

推测是该问题导致的编译失败

解决方案

因为装的是python2.7,有个python2.7的文件,所以建立软连接指向该文件

# 建立软连接指向/usr/bin/python2.7
ln -s /usr/bin/python2.7.5 /usr/bin/python2.7

之后重新编译

解决结果:

# Ambari Server终于编译成功!
[INFO] Ambari Server ...................................... SUCCESS [02:30 min]

4.8 Ambari Groovy Shell编译失败: Could not resolve dependencies for project org.apache.ambari:ambari-groovy-shell:jar:2.7.5.0.0

[INFO] Reactor Summary:
[INFO] 
[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  0.810 s]
[INFO] Apache Ambari Project POM .......................... SUCCESS [  0.134 s]
[INFO] Ambari Web ......................................... SUCCESS [ 55.390 s]
[INFO] Ambari Views ....................................... SUCCESS [  0.421 s]
[INFO] Ambari Admin View .................................. SUCCESS [ 16.168 s]
[INFO] utility 1.0.0.0-SNAPSHOT ........................... SUCCESS [  0.094 s]
[INFO] ambari-metrics ..................................... SUCCESS [  0.287 s]
[INFO] Ambari Metrics Common .............................. SUCCESS [  5.606 s]
[INFO] Ambari Metrics Hadoop Sink ......................... SUCCESS [  2.669 s]
[INFO] Ambari Metrics Flume Sink .......................... SUCCESS [  2.226 s]
[INFO] Ambari Metrics Kafka Sink .......................... SUCCESS [  1.962 s]
[INFO] Ambari Metrics Storm Sink .......................... SUCCESS [  2.767 s]
[INFO] Ambari Metrics Storm Sink (Legacy) ................. SUCCESS [  2.400 s]
[INFO] Ambari Metrics Collector ........................... SUCCESS [01:31 min]
[INFO] Ambari Metrics Monitor ............................. SUCCESS [  1.156 s]
[INFO] Ambari Metrics Grafana 2.1.0.0.0 ................... SUCCESS [  7.677 s]
[INFO] Ambari Metrics Assembly ............................ SUCCESS [01:13 min]
[INFO] Ambari Server ...................................... SUCCESS [02:30 min]
[INFO] Ambari Functional Tests ............................ SUCCESS [  1.422 s]
[INFO] Ambari Agent ....................................... SUCCESS [02:05 min]
[INFO] Ambari Client ...................................... SUCCESS [  0.136 s]
[INFO] Ambari Python Client ............................... SUCCESS [  1.058 s]
[INFO] Ambari Groovy Client ............................... SUCCESS [ 13.309 s]
[INFO] Ambari Shell ....................................... SUCCESS [  0.133 s]
[INFO] Ambari Python Shell ................................ SUCCESS [  0.672 s]
[INFO] Ambari Groovy Shell ................................ FAILURE [04:39 min]
[INFO] ambari-logsearch ................................... SKIPPED
[INFO] Ambari Logsearch Appender .......................... SKIPPED
[INFO] Ambari Logsearch Portal ............................ SKIPPED
[INFO] Ambari Logsearch Log Feeder ........................ SKIPPED
[INFO] Ambari Logsearch Solr Client ....................... SKIPPED
[INFO] Ambari Infra Solr Plugin ........................... SKIPPED
[INFO] Ambari Logsearch Assembly .......................... SKIPPED
[INFO] Ambari Logsearch Integration Test 2.7.5.0.0 ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:58 min
[INFO] Finished at: 2020-09-17T11:52:52+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ambari-groovy-shell: Could not resolve dependencies for project org.apache.ambari:ambari-groovy-shell:jar:2.7.5.0.0: Failed to collect dependencies at org.springframework.shell:spring-shell:jar:1.1.0.RC3: Failed to read artifact descriptor for org.springframework.shell:spring-shell:jar:1.1.0.RC3: Could not transfer artifact org.springframework.shell:spring-shell:pom:1.1.0.RC3 from/to spring-milestones (http://repo.spring.io/milestone): Access denied to: http://repo.spring.io/milestone/org/springframework/shell/spring-shell/1.1.0.RC3/spring-shell-1.1.0.RC3.pom , ReasonPhrase:Forbidden. -> [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-groovy-shell

报错原因:

这种报错是在jar包下载过程中出现的问题

类似的报错,主要有以下几种可能性
可以参照报错提示给出的链接:
DependencyResolutionException

首先根据报错提示访问了Access denied to: 指向的链接

界面显示如下:

在这里插入图片描述

去maven本地仓库查看该jar包,果然有问题:

在这里插入图片描述

到这里,开始怀疑是 ambari-shell/ambari-groovy-shell模块的pom.xml文件文件有问题
发现该配置文件下和报错有关的配置如下:

 <dependency>
      <groupId>org.springframework.shell</groupId>
      <artifactId>spring-shell</artifactId>
    </dependency>

根据关键字spring-shell去maven资料库查询,maven资料库链接如下:

maven资料库查询链接

发现spring-shell没有对应于上述pom.xml文件的配置

在这里插入图片描述

解决方案:

 vi ambari-shell/ambari-groovy-shell/pom.xml

修改spring-shell部分配置为如下:

 <dependency>
      <groupId>org.springframework.shell</groupId>
      <artifactId>spring-shell</artifactId>
      <version>1.1.0.RELEASE</version>
    </dependency>

修改之后重新编译

解决结果:

#  Ambari Groovy Shell编译成功
[INFO] Ambari Groovy Shell ................................ SUCCESS [07:49 min]

4.9 Failed to execute goal com.github.eirslett:frontend-maven-plugin

报错详情:

Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:yarn (yarn install) on project ambari-web:
 Failed to run task: 'yarn install --ignore-engines --pure-lockfile' failed.

报错原因:
nodejs会通过 yarn去加载依赖包,网络不稳定的时候会出现该问题,比较常见

解决方案:
保证网络环境稳定

四. 安装配置Ambari

4.1 安装配置Ambari Server

执行安装命令前,首先修改ambari-server文件

vi /usr/sbin/ambari-server

将文件标红部分,如下图:
在这里插入图片描述
修改为:

HASH="${VERSION}"

这是为了防止执行ambari-server setup出现问题:
/usr/sbin/ambari-server: line 34: buildNumber: unbound variable

安装ambari-server


yum install ambari-server/target/rpm/ambari-server/RPMS/x86_64/ambari-server*.rpm
ambari-server setup

注意:设置jdk时,应该选择3,然后输入1.2.1过程中设置的JAVA_HOME路径

执行情况如下:

Using python  /usr/bin/python
Setup ambari-server
Checking SELinux...
SELinux status is 'disabled'
Customize user account for ambari-server daemon [y/n] (n)? n
Adjusting ambari-server permissions and ownership...
Checking firewall status...
Checking JDK...
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
[3] Custom JDK
==============================================================================
Enter choice (1): 3
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.
Path to JAVA_HOME: /opt/modules/jdk1.8.0_151
Validating JDK on Ambari Server...done.
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? n
Configuring database...
Default properties detected. Using built-in database.
Configuring ambari database...
Checking PostgreSQL...
Running initdb: This may take up to a minute.
Initializing database ... OK


About to start PostgreSQL
Configuring local database...
Configuring PostgreSQL...
Restarting PostgreSQL
Creating schema and user...
done.
Creating tables...
done.
Extracting system views...
ambari-admin-2.7.5.0.0.jar

Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

启动ambari server

ambari-server start

在这里插入图片描述

成功启动后在浏览器输入Ambari地址:
http://ip:<port_number>

注意: port_number默认8080,我这里设置的8083,页面访问的账户名和密码都是admin

在这里插入图片描述

4.2 安装配置Ambari Agent

安装ambari-agent

yum install ambari-agent/target/rpm/ambari-agent/RPMS/x86_64/ambari-agent-*.rpm

启动ambari-agent之前,首先修改该文件,
防止出现类似4.1中类似ambari-server出现的错误

vi /var/lib/ambari-agent/bin/ambari-agent
# 将HASH="${buildNumber}"修改为:  HASH="${VERSION}"

编辑ambari server的位置

vi /etc/ambari-agent/conf/ambari-agent.ini
# 修改hostname一行为ambari-server对应的主机名

# 在security下面添加如下行:force_https_protocol=PROTOCOL_TLSv1_2,确保有下图所示的两个配置

在这里插入图片描述

启动ambari-agent

ambari-agent start

在这里插入图片描述

如果有异常请查看日志:/var/log/ambari-agent/ambari-agent.log

4.3 修改yum源,离线安装HDP及HDP-UTILS

安装httpd服务(主服务器)

yum -y install httpd
service httpd restart
chkconfig httpd on

将HDP,HDP-UTILS安装包放到/var/www/html目录下

HDP-2.7.5.0版本下载链接

HDP-UTILS-1.1.0.21版本下载链接

# 将从上述下载链接下载的文件拷贝到该目录下
mkdir -p /var/www/html/ambari
cd /var/www/html/ambari
tar -zxvf HDP-2.6.3.0-centos7-rpm.tar.gz 
mkdir HDP-UTILS
tar -zxvf HDP-UTILS-1.1.0.21-centos7.tar.gz -C HDP-UTILS
rm -rf  HDP-2.6.3.0-centos7-rpm.tar.gz HDP-UTILS-1.1.0.21-centos7.tar.gz

现在可以通过http://ip/ambari/查看能否成功访问

在这里插入图片描述

制作本地源

  1. 安装本地源制作相关工具
yum install yum-utils createrepo yum-plugin-priorities -y
createrepo  ./
  1. 修改文件里面的源地址
vi HDP/centos7/2.7.5.0-315/hdp.repo

修改如下:

#VERSION_NUMBER=2.7.5.0-315
[HDP-2.7.5.0]
name=HDP Version - HDP-2.7.5.0
baseurl=http://ip/ambari/HDP/centos7/2.7.5.0-315
gpgcheck=1
gpgkey=http://ip/ambari/HDP/centos7/2.7.5.0-315/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1


[HDP-UTILS-1.1.0.21]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.21
baseurl=http://ip/ambari/HDP-UTILS
gpgcheck=1
gpgkey=http://ip/ambari/HDP-UTILS/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

注意: 修改时需要将我这里的ip换为自己实际ip地址

  1. yum缓存
yum clean all
yum makecache
yum repolist

4.4 安装部署hdp

  1. 登录
    默认管理员登录,账户密码均为admin
  2. 安装
    在这里插入图片描述

Get Started配置集群名字

选择版本并修改为本地源地址

在这里插入图片描述

Install Options配置主机名和ssh秘钥文件id_rsa

注意:秘钥文件在~/.ssh目录下

后续部分按照页面提示一一配置即可~
具体细节可以参照博客:

Ambari2.6.0安装HDP2.6.3链接

遇到问题可参考我的博客:

Ambari踩过的坑及解决方案

五. ambari2.7.5安装配置遇到的问题及解决方案

5.1 ambari server启动报错: java.net.BindException: Address already in use

详细报错:

# 查看server日志
cat /var/log/ambari-server/ambari-server.log
17 Sep 2020 17:44:38,714 ERROR [main] AmbariServer:1073 - Failed to run the Ambari Server
java.net.BindException: Address already in use
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
	at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
	at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.server.Server.doStart(Server.java:293)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.apache.ambari.server.controller.AmbariServer.run(AmbariServer.java:558)
	at org.apache.ambari.server.controller.AmbariServer.main(AmbariServer.java:1067)

报错原因:

8080端口号被占用

如图,端口号被k8s应用占用

在这里插入图片描述

解决办法:

  1. 杀掉占用8080端口号的进程
  2. 更换ambari-server端口号,我这里选用的是第二种
# 修改ambari配置文件
vi /etc/ambari-server/conf/ambari.properties
# 增加这一行
client.api.port=<port_number>

执行结束之后,重启ambari-server

ambari-server start

解决结果:

如图,界面可以访问!

在这里插入图片描述

5.2 ambari agent启动报错: SSLError: Failed to connect. Please check openssl library versions

报错详情:agent启动后无法注册成为ambari节点,界面显示Fail

日志如下:

cat /var/log/ambari-agent/ambari-agent.log 
WARNING 2020-09-18 14:46:52,865 NetUtil.py:124 - Server at https://hdpamb154:8440 is not reachable, sleeping for 10 seconds...
INFO 2020-09-18 14:47:02,865 NetUtil.py:70 - Connecting to https://hdpamb154:8440/ca
ERROR 2020-09-18 14:47:02,867 NetUtil.py:96 - EOF occurred in violation of protocol (_ssl.c:618)
ERROR 2020-09-18 14:47:02,867 NetUtil.py:97 - SSLError: Failed to connect. Please check openssl library versions. 
Refer to: https://bugzilla.redhat.com/show_bug.cgi?id=1022468 for more details.

报错原因:
https连接失败

解决方案:

  1. 首先按照提示检查openssl版本
openssl version # 如果低于 openssl-1.0.1e-16.el6.x86_64 版本,则需要更新到 openssl-1.0.1e-16.el6.x86_64 及以上版本

2.将 [https] 节的 verify 项设为禁用

vi /etc/python/cert-verification.cfg

# 在配置中更改下列参数
[https]
verify=disable
  1. 编辑 /etc/ambari-agent/conf/ambari-agent.ini 配置文件,在 [security] 节部分,确保设置如下两个值,其它值保持不变:
vi /etc/ambari-agent/conf/ambari-agent.ini


[security]
ssl_verify_cert=0
force_https_protocol=PROTOCOL_TLSv1_2

之后重启ambari-agent

ambari-agent restart

解决详情:

节点注册成功
在这里插入图片描述

QQ:502044959,有问题请加我!注明昵称

Ambari是一个开源的集群管理工具,它可以用于管理Hadoop和Hadoop生态系统中的其他组件。下面是关于如何在Linux系统上从源码编译安装Ambari的步骤: 1. 安装编译工具和依赖项 首先需要安装一些编译工具和依赖项,以便编译Ambari。使用以下命令安装这些工具和依赖项: ``` sudo apt-get install git maven rpm createrepo ``` 2. 下载Ambari源代码 使用以下命令从Github上下载Ambari源代码: ``` git clone https://github.com/apache/ambari.git ``` 3. 切换到特定的版本 如果您想要安装特定版本的Ambari,可以切换到该版本的分支。使用以下命令切换到Ambari 2.7.5分支: ``` cd ambari git checkout branch-2.7.5 ``` 4. 编译Ambari 进入ambari-server目录,使用以下命令编译Ambari: ``` cd ambari-server mvn versions:set -DnewVersion=2.7.5.0.0 mvn clean install -PskipTests ``` 该操作将会花费几分钟的时间来编译和构建Ambari。 5. 安装Ambari 编译完成后,进入ambari-server/target目录。在这个目录中你将会看到一个名为ambari-server-2.7.5.0.0.tar.gz的文件。解压缩该文件并安装Ambari: ``` tar -xvf ambari-server-2.7.5.0.0.tar.gz cd ambari-server-2.7.5.0.0 sudo ./setup.sh ``` 该操作将会安装Ambari并启动Ambari Server。 6. 访问Ambari Web控制台 安装完成后,您可以通过在Web浏览器中输入Ambari Server的IP地址和端口来访问Ambari Web控制台。 ``` http://your_server_ip:8080 ``` 现在您可以使用Ambari管理Hadoop和其他Hadoop生态系统组件了。
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mcj1314bb

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值