1、环境搭建
基于centos 6.9 python2.6.6
1.1、安装jdk
将下载好的jdk-8u151-linux-x64.tar.gz上传到/usr/java下,然后解压
export JAVA_HOME=/usr/java/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
1.2安装maven
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum install -y maven
1.3安装ant
yum install -y ant
1.4安装node
将下载好的node-v4.5.0-linux-x64.tar.gz上传到/usr/node下,然后解压
配置环境变量
#set for nodejs
export NODE_HOME=/usr/node/node-v4.5.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH
1.5安装git
yum install -y git
1.6安装rpmbuild
rpm -qa | grep rpm-build #检测是否已安装rpmbuild
yum install rpm-build #如果没安装则手动安装
1.7安装gcc
rpm -qa | grep gcc-c++ #检测是否已安装gcc
yum install gcc-c++ #如果没安装则手动安装
2、源码编译
下载&编译
从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" -Drat.skip=true -Preplaceurl
#-rf : xxx 每次问题解决后,重新执行编译命令进行编译
mvn -B clean install package rpm:rpm -DnewVersion=2.6.2.0.0 -DskipTests -Dpython.ver="python >= 2.6"
编译需要一些时间 编译成功后显示如下:
3、编译中可能遇到的问题
3.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
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<version>0.11</version>
3.2 错误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]
遇到以上错误时,可以修改maven的镜像,设置为阿里镜像,建议直接修改镜像为阿里云镜像
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
3.3 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
3.4 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]
#在以下地址下载tar包
https://github.com/yarnpkg/yarn/releases/download/v0.23.2/yarn-v0.23.2.tar.gz
mkdir -p /root/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./
cp yarn-v0.23.2.tar.gz /root/.m2/repository/com/github/eirslett/yarn/0.23.2/yarn-0.23.2./
3.5 around Ant part …< exec dir="/home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/…/…/ambari-common/src/main/unix/ambari-python-wrap" fail“true”>… @ 4:299 in /home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml
yum install -y ant
3.6 around Ant part …< get dest="/home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-timelineservice/target/embedded/hbase.tar.gz" src=“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” usetimestamp=“true”/>… @ 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使用本地文件模式
<hbase.tar>file:///home/compile/bak/hbase-1.1.2.2.6.4.0-91.tar.gz</hbase.tar>
<hadoop.tar>file:///home/compile/bak/hadoop-2.7.3.2.6.4.0-91.tar.gz</hadoop.tar>
<phoenix.tar>file:///home/compile/bak/phoenix-4.7.0.2.6.4.0-91.tar.gz</phoenix.tar>
<grafana.tar>file:///home/compile/bak/grafana-2.6.0.linux-x64.tar.gz</grafana.tar>
3.7 around Ant part …< exec dir="/home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/home/compile/ambari/ambari-release-2.6.2/ambari-metrics/ambari-metrics-host-monitoring/…/…/ambari-common/src/main/unix/ambari-python-wrap" fail“true”>… @ 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
3.8 源码编译报错:Too many files with unapproved license
(加上-Drat.skip=true进行编译即可)