目录
1.相关连接
2.编译
2.1.编译环境安装
2.2.下载源码
2.3.镜像加速
2.4.大包提前下载
2.5.各种错误处理
2.6.编译成功
1.相关连接
编译官方说明
Ambari Development - Apache Ambari - Apache Software Foundation
部署官方说明
Installation Guide for Ambari 2.7.5 - Apache Ambari - Apache Software Foundation
git地址:https://github.com/apache/ambari
2.编译
2.1.编译环境安装
yum install -y java-1.8.0-openjdk-develyum install -y gcc-c++ rpm-build git
下载maven新版3.6.3(笔者实验时yum直接安装的maven是3.0.x,会提示需要3.1.0以上)
http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
curl http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o apache-maven-3.6.3-bin.tar.gztar xzvf apache-maven-3.6.3-bin.tar.gz
#pip安装(官方中说安装setuptools即可,pip比较好装,包含了setuptools)
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pypython get-pip.py
nodejs环境安装
yum install epel-releaseyum install nodejs -y
升级nodejs
sudo npm install n -gsudo n stable
vi ~/.bash_profile
添加
export PATH=/usr/local/bin/:$PATH:/root/apache-maven-3.6.3/binexport JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH
再执行
source ~/.bash_profile
安装yarn等
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.reposudo yum install yarnnpm install -g bowernpm install -g gulp
2.2.下载源码
到github下载
https://github.com/apache/ambari/archive/release-2.7.4.tar.gz
下载后解压
tar xfvz apache-ambari-2.7.4-src.tar.gz cd apache-ambari-2.7.4-srcmvn versions:set -DnewVersion=2.7.4.0.0pushd ambari-metricsmvn versions:set -DnewVersion=2.7.4.0.0popdmvn -B clean install rpm:rpm -DnewVersion=2.7.4.0.0 -DbuildNumber=5895e4ed6b30a2da8a90fee2403b6cab91d19972 -DskipTests -Dpython.ver="python >= 2.6" apache-rat:check -Drat.numUnapprovedLicenses=600
注
编译过程中失败,继续从该项目编译即可(mvn命令后添加参数如下,后面的ambari-metrics-host-monitoring就是提示的项目名)
mvn …… -rf :ambari-metrics-host-monitoring
2.3.镜像加速
觉得下载依赖包特别慢的,可以添加阿里云镜像
注意:后面下载storm源的时候会报找不到,此时把public的
<mirrorOf>*</mirrorOf>
改成
<mirrorOf>public</mirrorOf>
vi ${maven安装目录}/conf/settings.xml
<mirrors><mirror><id>ali apache snapshots</id><url>https://maven.aliyun.com/repository/apache-snapshots</url><mirrorOf>apache snapshots</mirrorOf> </mirror><mirror><id>ali central</id><url>https://maven.aliyun.com/repository/central</url><mirrorOf>central</mirrorOf> </mirror><mirror><id>ali google</id><url>https://maven.aliyun.com/repository/google</url><mirrorOf>google</mirrorOf> </mirror><mirror><id>ali gradle-plugin</id><url>https://maven.aliyun.com/repository/gradle-plugin</url><mirrorOf>gradle-plugin</mirrorOf> </mirror><mirror><id>ali jcenter</id><url>https://maven.aliyun.com/repository/jcenter</url><mirrorOf>jcenter</mirrorOf> </mirror><mirror><id>ali spring</id><url>https://maven.aliyun.com/repository/spring</url><mirrorOf>spring</mirrorOf> </mirror><mirror><id>ali spring-plugin</id><url>https://maven.aliyun.com/repository/spring-plugin</url><mirrorOf>spring-plugin</mirrorOf> </mirror><mirror><id>ali public</id><url>https://maven.aliyun.com/repository/public</url><mirrorOf>*</mirrorOf> </mirror><mirror><id>ali releases</id><url>https://maven.aliyun.com/repository/releases</url><mirrorOf>releases</mirrorOf> </mirror><mirror><id>ali snapshots</id><url>https://maven.aliyun.com/repository/snapshots</url><mirrorOf>snapshots</mirrorOf> </mirror><mirror><id>ali grails-core</id><url>https://maven.aliyun.com/repository/grails-core</url><mirrorOf>grails-core</mirrorOf> </mirror><mirror><id>ali mapr-public</id><url>https://maven.aliyun.com/repository/mapr-public</url><mirrorOf>mapr-public</mirrorOf> </mirror></mirrors>
2.4.大包提前下载
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-2.6.0</grafana.folder>
<grafana.tar>https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0.linux-x64.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>
这一段,用下载工具下载下来(PS:迅雷可以直接镜像加速),在部署到自己本地的web服务器上,再修改这个pom.xml中的url地址,下载使用更快捷
2.5.各种错误处理
报错
[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
报错
[ERROR] warning fsevents@0.3.8: The platform "linux" is incompatible with this module.
解决
npm install pm2@latest -gpm2 install pm2-slack
(执行后上面的错误也还存在,但是可以往下走,这里发现了需要安装bower,安装这个即可)
安装bower的依赖包(个人在ambari-admin/src/main/resources/ui/admin-web/下执行)
bower install --allow-root
报错
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是一个大于报错信息中的数量。
报错
PhantomJS not found on PATH
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
[ERROR] Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
[ERROR] Saving to /tmp/phantomjs/phantomjs-1.9.7-linux-x86_64.tar.bz2
[ERROR] Receiving...
[ERROR]
[ERROR] Error making request.
[ERROR] Error: read ECONNRESET
[ERROR] at exports._errnoException (util.js:907:11)
[ERROR] at TLSWrap.onread (net.js:557:26)
应该是下载超时了,网上说用cnpm,这个需要改编译过程,不合适
####不需要执行 npm install -g cnpm --registry=https://registry.npm.taobao.org
下载这个确实太久了,咱手动从淘宝镜像上下载
wget https://npm.taobao.org/mirrors/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
cp phantomjs-2.1.1-linux-x86_64.tar.bz2 /tmp/phantomjs/
下载完2.1.1又会提示需要1.9.7
wget https://npm.taobao.org/mirrors/phantomjs/phantomjs-1.9.7-linux-x86_64.tar.bz2
cp phantomjs-1.9.7-linux-x86_64.tar.bz2 /tmp/phantomjs/
接下来又报错/tmp/npm_config_tmp/phantomjs/这个目录下也要下载phantomjs,一样的版本,都拷贝过去……
cp phantomjs-* /tmp/npm_config_tmp/phantomjs/
wget https://npm.taobao.org/mirrors/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2 -O /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
后面还有……
wget https://npm.taobao.org/mirrors/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O /tmp/logsearch_npm_config_tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
报错
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
解决
yum install -y java-1.8.0-openjdk-devel
这个是安装jdk,yum install -y java-1.8.0-openjdk这个是安装jre,详见
yum search openjdk
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8
报错
[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]
往上找,发现
[INFO] Running 'npm install --unsafe-perm' in /root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web
……
[INFO] --- exec-maven-plugin:1.2.1:exec (Bower install) @ ambari-admin ---
bower 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> (/root/apache-ambari-2.7.4-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 (/root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/lib/renderers/StandardRenderer.js:72:17)
at Logger.<anonymous> (/root/apache-ambari-2.7.4-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 (/root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
at /root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/lib/commands/index.js:40:20
at _rejected (/root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:797:24)
at /root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:823:30
at Promise.when (/root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/root/apache-ambari-2.7.4-src/ambari-admin/src/main/resources/ui/admin-web/node_modules/bower/node_modules/q/q.js:741:41)
处理
vi ambari-admin/pom.xml
<argument>${basedir}/src/main/resources/ui/admin-web/node_modules/bower/bin/bower</argument>
改为
<argument>bower</argument>
报错
[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
报错
各种下载超时
[INFO] Downloading https://github.com/yarnpkg/yarn/releases/download/v1.1.0/yarn-v1.1.0.tar.gz to /root/.m2/repository/com/github/eirslett/yarn/1.1.0/yarn-1.1.0.tar.gz
解决
手动下载
mkdir -p /root/.m2/repository/com/github/eirslett/yarn/1.1.0/wget https://github.com/yarnpkg/yarn/releases/download/v1.1.0/yarn-v1.1.0.tar.gz -O /root/.m2/repository/com/github/eirslett/yarn/1.1.0/yarn-1.1.0.tar.gz
2.6.编译成功
……[INFO] Ambari Server ...................................... SUCCESS [04:18 min]
[INFO] Ambari Functional Tests ............................ SUCCESS [ 3.061 s]
[INFO] Ambari Agent ....................................... SUCCESS [01:05 min]
[INFO] ambari-logsearch ................................... SUCCESS [ 1.431 s]
[INFO] Ambari Logsearch Appender .......................... SUCCESS [ 0.595 s]
[INFO] Ambari Logsearch Config Api ........................ SUCCESS [ 2.027 s]
[INFO] Ambari Logsearch Config JSON ....................... SUCCESS [ 0.253 s]
[INFO] Ambari Logsearch Config Solr ....................... SUCCESS [ 0.449 s]
[INFO] Ambari Logsearch Config Zookeeper .................. SUCCESS [ 0.512 s]
[INFO] Ambari Logsearch Config Local ...................... SUCCESS [ 0.181 s]
[INFO] Ambari Logsearch Log Feeder Plugin Api ............. SUCCESS [ 0.298 s]
[INFO] Ambari Logsearch Log Feeder Container Registry ..... SUCCESS [ 0.462 s]
[INFO] Ambari Logsearch Log Feeder ........................ SUCCESS [ 7.216 s]
[INFO] Ambari Logsearch Web ............................... SUCCESS [02:56 min]
[INFO] Ambari Logsearch Server ............................ SUCCESS [ 10.176 s]
[INFO] Ambari Logsearch Assembly .......................... SUCCESS [ 0.185 s]
[INFO] Ambari Logsearch Integration Test .................. SUCCESS [ 2.482 s]
[INFO] ambari-infra ....................................... SUCCESS [ 0.221 s]
[INFO] Ambari Infra Solr Client ........................... SUCCESS [ 22.077 s]
[INFO] Ambari Infra Solr Plugin ........................... SUCCESS [ 2.573 s]
[INFO] Ambari Infra Manager ............................... SUCCESS [ 7.893 s]
[INFO] Ambari Infra Assembly .............................. SUCCESS [ 0.267 s]
[INFO] Ambari Infra Manager Integration Tests ............. SUCCESS [ 1.871 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:25 min
[INFO] Finished at: 2020-04-10T11:42:14+08:00
[INFO] ------------------------------------------------------------------------
成功
编译好后的rpm包在
cd ambari-server/target/rpm/ambari-server/RPMS/x86_64/
ambari-server-2.7.4.0-0.x86_64.rpm
一系列漫长的折磨,断断续续两三天,终于成功了!
总结教训:
1.用阿里云镜像,能加速很多
2.了解几个常用的编译工具,问题出现在这些点上的时候要想到是不是他没安装的问题。