3

Ambari 2.7.3源码编译

1、安装JDK

[root@bigdata-test ambari-src]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

2、安装maven

[root@bigdata-test ambari-src]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /opt/soft/maven
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /opt/soft/jdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0.514.26.2.el7.x86_64", arch: "amd64", family: "unix"

3、下载 python2.7 设置工具

wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea --no-check-certificate
运行命令
sh setuptools-0.6c11-py2.7.egg

4、下载node

wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz --no-check-certificate
添加下面两行:
export NODEJS=/***/***/node-v10.16.0-linux-x64 #解压NodeJS的路径
export PATH=:$NODEJS/bin:$PATH
node -v
npm -v

5、使用 npm 安装 Brunch

npm install -g brunch
brunch -v
npm install -g bower

6、修改/etc/profile,设置JVM参数

export _JAVA_OPTIONS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"
cd apache-ambari-2.7.3-src
mvn versions:set -DnewVersion=2.7.3.0.0
pushd ambari-metrics
mvn versions:set -DnewVersion=2.7.3.0.0
popd

编译命令 :

 mvn -B clean install rpm:rpm -DnewVersion=2.7.3.0.0 -DskipTests -Dpython.ver="python >= 2.6" -Drat.skip=true -Dcheckstyle.skip -X

如果要单独编译某一个模块:

mvn -B clean install package rpm:rpm -DnewVersion=2.7.3.0.0 -DskipTests -Dpython.ver="python >= 2.6" -Drat.skip=true -Dcheckstyle.skip --rf :ambari-web

7、编译中遇到的问题

1、问题1

[DEBUG] Toolchains are ignored, 'executable' parameter is set to /root/ambari-src/ambari-2.7.3/ambari-web/node/node
[DEBUG] Executing command line: /root/ambari-src/ambari-2.7.3/ambari-web/node/node node_modules/brunch/bin/brunch build
或者 
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (Bower install) on project ambari-admin: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (Bower install) on project ambari-admin: Command execution failed.

首先解决方式

cd ambari-admin/src/main/resources/ui/admin-web目录下,编辑 .bowerrc ,修改后的内容如下:

{
"directory": "app/bower_components",
"allow_root": true
}

个人将ambari-admin(包括子目录ambari-admin/src/main/resources/ui/admin-web)里面生成的node、node_modules删除,保持干净的源码环境,再单独编译ambari-admin
find ~/.m2/repository/ -name "*.lastUpdated" -exec rm -rf {} \;

 mvn -B clean install rpm:rpm -DnewVersion=2.7.3.0.0 -DskipTests -Dpython.ver="python >= 2.6" -Drat.skip=true -X -rf :ambari-admin

其次解决方式

如果还报错,则在ambari-admin/src/main/resources/ui/admin-web/下执行

npm install -g brunch
bower install --allow-root
npm install

ambari-admin下 vim pom.xml
Before

 <configuration>
      <nodeVersion>v4.5.0</nodeVersion>
      <npmVersion>2.15.0</npmVersion>
      <workingDirectory>src/main/resources/ui/admin-web/</workingDirectory>
      <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
 </configuration>

After 修改为你的node和npm版本,如果不知道,可以根据
node -v
npm -v
进行查看

  <configuration>
          <nodeVersion>v11.10.0</nodeVersion>
          <npmVersion>6.7.0</npmVersion>
          <workingDirectory>src/main/resources/ui/admin-web/</workingDirectory>
          <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
   </configuration>
find ~/.m2/repository/ -name "*.lastUpdated" -exec rm -rf {} \;
mvn -B clean install rpm:rpm -DnewVersion=2.7.3.0.0 -DskipTests -Dpython.ver="python >= 2.6" -Drat.skip=true -X -rf :ambari-admin

2、问题2

Could not resolve dependencies for project org.apache.ambari:ambari-metrics-timelineservice:jar:2.7.3.0.0: Failed to collect dependencies at org.apache.phoenix:phoenix-core:jar:5.0.0.3.0.0.0-1634 -> org.apache.hbase:hbase-annotations:jar:2.0.0.3.0.0.0-1634
find ~/.m2/repository/ -name "*.lastUpdated" -exec rm -rf {} \;
mvn -B install package rpm:rpm -DnewVersion=2.7.3.0.0 -DskipTests -Dpython.ver="python >= 2.6" -Drat.skip=true --rf :ambari-metrics-assembly

3、问题3

Connect to nexus-private.hortonworks.com:80 [nexus-private.hortonworks.com/54.173.242.72] failed: 连接超时 (Connection timed out)
ping nexus-private.hortonworks.com,发现这个私有仓库地址访问不上去。Ambari配置的仓库为nexus-private.hortonworks.com,但该地址无法访问。

解决方案:个人是进入目录ambari-metrics,编辑pom.xml替换如下

<repository>
<id>apache-hadoop</id>
<name>hdp</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>

使用迅雷下载以下包

<hbase.tar>http://dev.hortonworks.com.s3.amazonaws.com/HDP/centos7/3.x/BUILDS/3.0.0.0-1634/tars/hbase/hbase-2.0.0.3.0.0.0-1634-bin.tar.gz</hbase.tar>
<hadoop.tar>http://dev.hortonworks.com.s3.amazonaws.com/HDP/centos7/3.x/BUILDS/3.0.0.0-1634/tars/hadoop/hadoop-3.1.0.3.0.0.0-1634.tar.gz</hadoop.tar>
<grafana.tar>https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0.linux-x64.tar.gz</grafana.tar>
<phoenix.tar>http://dev.hortonworks.com.s3.amazonaws.com/HDP/centos7/3.x/BUILDS/3.0.0.0-1634/tars/phoenix/phoenix-5.0.0.3.0.0.0-1634.tar.gz</phoenix.tar>

换成
包到本地,然后在服务器上安装httpd

centos6
yum install httpd -y
/etc/init.d/httpd start
centos7
yum install httpd -y
systemctl start httpd

将迅雷下载的包,放入到/var/www/html 建立相应的hbase、hadoop、grafana、phoenix相应的目录,将tar.gz包放入进去,如下图所示

<hbase.tar>http://bigdata-test.bcc-szth.baidu.com/hbase/hbase-2.0.0.3.0.0.0-1634-bin.tar.gz</hbase.tar>
<hadoop.tar>http://bigdata-test.bcc-szth.baidu.com/hadoop/hadoop-3.1.0.3.0.0.0-1634.tar.gz</hadoop.tar>
<grafana.tar>http://bigdata-test.bcc-szth.baidu.com/grafana/grafana-2.6.0.linux-x64.tar.gz</grafana.tar>
<phoenix.tar>http://bigdata-test.bcc-szth.baidu.com/phoenix/phoenix-5.0.0.3.0.0.0-1634.tar.gz</phoenix.tar>

4、问题4

Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project ambari-infra-solr-client: An Ant BuildException has occured: The following error occurred while executing this line:
/opt/apache-ambari-2.7.3-src/ambari-infra/ambari-infra-solr-client/build.xml:39: java.net.UnknownHostException: central.maven.org

进入 /root/ambari-src/ambari-2.7.3/ambari-infra/ambari-infra-solr-client/pom.xml
在ambari-infra模块中有些pom.xml写的路径central.maven.org无法访问了,需要更换为https://repo1.maven.org

如感兴趣,点赞加关注,谢谢


journey
32 声望20 粉丝

引用和评论

0 条评论