ambari-2.6.2源码编译

ambari-2.6.2本地编译

环境搭建

安装jdk

(ambari 2.7以上必须使用jdk1.8编译,其余的必须使用jdk1.7编译)

tar -zxvf jdk1.7.0_60.tgz
ln -s jdk1.7.0_60 java 

安装maven

Download maven(ambari要求maven版本3.3.9以上)本次使用的是3.5.4

tar -zxvf apache-maven-3.5.4-bin.tar.gz
ln -s apache-maven-3.5.4 maven

安装nodejs

tar -xvf node-v8.11.4-linux-x64.tar.xz
ln -s node-v8.11.4-linux-x64 node

安装ant

# https://ant.apache.org/bindownload.cgi
# 1.10.x 必须要jdk1.8版本,所以使用1.9.x
tar -zxvf apache-ant-1.9.13-bin.tar.gz
ln -s apache-ant-1.9.13 ant

设置jdk和maven的环境变量

export userEnvi=/home/compile/software
export JAVA_HOME=$userEnvi/java
export MAVEN_HOME=$userEnvi/maven
export NODE_HOME=$userEnvi/node
export ANT_HOME=$userEnvi/ant
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$NODE_HOME/bin:$ANT_HOME/bin:$PATH

安装python

Centos7自带python2.7.5(ambari2.7以上需要python2.7以上环境,其余最低需要python2.6)

安装git

yum install git

安装setuptools

  • python2.6 Download setuptools and run
sh setuptools-0.6c11-py2.6.egg
  • python2.7 Download setuptools and run
sh setuptools-0.6c11-py2.7.egg

根据主机安装的python版本进行选择

安装rpmbuild

rpm -qa | grep rpm-build #检测是否已安装rpmbuild
yum install rpm-build    #如果没安装则手动安装

安装g++

rpm -qa | grep gcc-c++ #检测是否已安装g++
yum install gcc-c++    #如果没安装则手动安装

源码编译

下载&编译

从github上下载ambari本次编译选用ambari2.6.2进行编译

tar -zxvf apache-ambari-2.6.2-src.tar.gz
cd apache-ambari-2.6.2-src
# 版本号必须要5位数字,因为metric模块下有版本正则表达式检测
mvn versions:set -DnewVersion=2.6.2.0.0

#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=2.6.2.0.0
popd

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

# -rf : xxx 每次问题解决后,执行下面命令可以继续编译
mvn -B install package rpm:rpm -DnewVersion=2.6.2.0.0 -DskipTests -Dpython.ver="python >= 2.6" -rf :ambari-server

问题总结

  1. 在ambari-meteics设置版本时 mvn versions:set -DnewVersion=2.6.2.1 错误: Error resolving version for plugin 'org.apache.rat:apache-rat-plugin' from the repositories [local(/home/compile/.m2/repository),central(https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
# /home/compile/ambari/ambari-release-2.6.2/ambari-metrics/pom.xml 添加版本号 0.11
org.apache.rat
        apache-rat-plugin
        0.11
  1. 在ambari-meteics设置版本时 mvn versions:set -DnewVersion=2.6.2.1 错误Error resolving version for plugin 'org.codehaus.mojo:versions-maven-plugin' from the repositories [local (/home/compile/.m2/repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]

  
    nexus-aliyun  
    central    
    Nexus aliyun  
    http://maven.aliyun.com/nexus/content/groups/public  
  
  1. 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 /home/compile/ambari/ambari-release-2.6.2/target/rpm/ambari/SPECS && rpmbuild -bb --buildroot /home/compile/ambari/ambari-release-2.6.2/target/rpm/ambari/buildroot --define '_topdir /home/compile/ambari/ambari-release-2.6.2/target/rpm/ambari' --target noarch-redhat-linux ambari.spec' -> [Help 1]
#rpm 或者 rpm-build不存在需要手动安装
yum install rpm
yum install -y rpm-build.x86_64
  1. 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 download Yarn: Could not download https://github.com/yarnpkg/yarn/releases/download/v0.23.2/yarn-v0.23.2.tar.gz: Received fatal alert: protocol_version -> [Help 1]
#在浏览器中下载https://github.com/yarnpkg/yarn/releases/download/v0.23.2/yarn-v0.23.2.tar.gz

mkdir -p /home/compile/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./

cp yarn-v0.23.2.tar.gz /home/compile/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./
  1. Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (Bower install) on project ambari-admin: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
# 安装git即可解决
  1. around Ant part ...... @ 4:299 in /home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml
# 安装ant即可解决
  1. around Ant part ...... @ 5:270 in /home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-timelineservice/target/antrun/build-Download HBase.xml
# https://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.6.4.0/tars/hbase/hbase-1.1.2.2.6.4.0-91.tar.gz
# https://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.6.4.0/tars/phoenix/phoenix-4.7.0.2.6.4.0-91.tar.gz
# https://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.6.4.0/tars/hadoop/hadoop-2.7.3.2.6.4.0-91.tar.gz
# https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0.linux-x64.tar.gz

# 手动下载以上tar.gz放入相应位置,修改ambari-metric->pom.xml使用本地文件模式
 file:///home/compile/bak/hbase-1.1.2.2.6.4.0-91.tar.gz
 file:///home/compile/bak/hadoop-2.7.3.2.6.4.0-91.tar.gz
 file:///home/compile/bak/phoenix-4.7.0.2.6.4.0-91.tar.gz
 file:///home/compile/bak/grafana-2.6.0.linux-x64.tar.gz
  1. around Ant part ...... @ 4:299 in /home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml
# 缺少python  psutils模块
wget https://pypi.python.org/packages/source/p/psutil/psutil-2.0.0.tar.gz
tar -xzvf psutil-2.0.0.tar.gz
cd psutil-2.0.0
python setup.py install
# 安装python setup.py install时出现如下错误 psutil/_psutil_linux.c:12:20: error: Python.h: No such file or directory
yum -y install python-devel
  1. 编译时出现maven-antrun-plugin Error excute ant tasks PermGen space
# 进入maven安装目录 bin/mvn
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"

相关博客参考

ambari2.5.0源码编译
基于ubuntu的源码编译和安装
ambari官方编译环境

你可能感兴趣的:(ambari-2.6.2源码编译)