TT Bigdata TT Bigdata
首页
  • 部署专题

    • 常规安装
    • 一键部署
  • 组件安装

    • 常规&高可用
  • 版本专题

    • 更新说明
  • Ambari-Env

    • 环境准备
    • 开始使用
  • 组件编译

    • 专区—Ambari
    • 专区—Bigtop
  • 报错解决

    • 专区—Ambari
    • 专区—Bigtop
  • 其他技巧

    • Maven镜像加速
    • Gradle镜像加速
    • Bower镜像加速
    • 虚拟环境思路
    • R环境安装+一键安装脚本
    • Ivy配置私有镜像仓库
    • Node.js 多版本共存方案
    • Ambari Web本地启动
    • Npm镜像加速
    • PostgreSQL快速安装
    • Temurin JDK 23快速安装
  • 成神之路

    • 专区—Ambari
    • 专区—Bigtop
  • 集成案例

    • Redis集成教学
    • Dolphin集成教学
    • Doris集成教学
    • 持续整理...
  • 模板代码

    • 各类组件
    • 通用模板
  • 国产化&其他系统

    • Centos系列
    • Kylin系列
    • OpenEuler系列
    • Rocky系列
    • Ubuntu系列
  • 生产调优

    • 组件调优指南
    • 1v1指导调优
  • 定制开发

    • 组件版本定制
    • 样式风格定制
  • 蓝图愿景
  • 技术支持
  • 合作共建
GitHub (opens new window)

JaneTTR

数据酿造智慧,每一滴都是沉淀!
首页
  • 部署专题

    • 常规安装
    • 一键部署
  • 组件安装

    • 常规&高可用
  • 版本专题

    • 更新说明
  • Ambari-Env

    • 环境准备
    • 开始使用
  • 组件编译

    • 专区—Ambari
    • 专区—Bigtop
  • 报错解决

    • 专区—Ambari
    • 专区—Bigtop
  • 其他技巧

    • Maven镜像加速
    • Gradle镜像加速
    • Bower镜像加速
    • 虚拟环境思路
    • R环境安装+一键安装脚本
    • Ivy配置私有镜像仓库
    • Node.js 多版本共存方案
    • Ambari Web本地启动
    • Npm镜像加速
    • PostgreSQL快速安装
    • Temurin JDK 23快速安装
  • 成神之路

    • 专区—Ambari
    • 专区—Bigtop
  • 集成案例

    • Redis集成教学
    • Dolphin集成教学
    • Doris集成教学
    • 持续整理...
  • 模板代码

    • 各类组件
    • 通用模板
  • 国产化&其他系统

    • Centos系列
    • Kylin系列
    • OpenEuler系列
    • Rocky系列
    • Ubuntu系列
  • 生产调优

    • 组件调优指南
    • 1v1指导调优
  • 定制开发

    • 组件版本定制
    • 样式风格定制
  • 蓝图愿景
  • 技术支持
  • 合作共建
GitHub (opens new window)
  • Ambari

    • 编译小技巧

    • 使用Ambari-Env编译

    • 适用于Centos7.9

      • Ambari编译——教程大纲
        • 环境准备与依赖梳理
        • 背景说明
        • 1. 常见编译命令
        • 2. 首次编译报错现象
        • 3. 问题定位实操
          • 3.1 打开详细日志(修改 pom.xml)
          • 3.2 只重试失败子模块
          • 3.3 典型 npm 报错全貌与影响
        • 4. 跳过 npm 安装脚本的实践
          • 4.1 忽略生命周期脚本命令
        • 5. 编译结果验证与 rpm 产物
      • Ambari编译——环境准备
      • Ambari编译——教程大纲
      • Ambari编译——环境准备
    • 适用于Rocky8.10

    • 适用于Ubuntu22.04

  • Ambari-Metrics

  • Ambari-Infra

  • 组件编译-Ambari
  • Ambari
  • 适用于Centos7.9
JaneTTR
2025-05-03
目录

Ambari编译——教程大纲2.8.0

# 环境准备与依赖梳理

阅读本节前,请确保已经完成环境准备中的依赖安装与环境变量配置。

# 背景说明

在 CentOS 7.9 下编译 Ambari 2.8.0 源码时,除了常规的 JDK、Maven 环境准备外,ambari-admin 模块由于集成了前端构建(npm install)步骤,经常在实际打包过程中出现 node/npm 相关报错。尤其在低版本 Node.js 环境或内网断网环境,容易被困在 phantomjs-prebuilt、karma-phantomjs-launcher 等历史依赖的生命周期脚本上。 很多编译者在此被阻断,难以产出完整的 rpm 包痛点。本节将结合实际日志和全流程截图,详细还原排查过程与常用解决手段。

# 1. 常见编译命令

正常情况下可直接运行如下 Maven 命令进行全量编译:

mvn -T 2C -B install package rpm:rpm \
  -Drat.skip=true \
  -Dcheckstyle.skip=true \
  -DskipTests \
  -Dpython.ver="python >= 2.6" \
  -Preplaceurl
1
2
3
4
5
6

推荐根据CPU核心数调整 -T 2C多线程加速,提升编译效率。

编译命令执行截图

# 2. 首次编译报错现象

源码拉取完成后,编译执行往往直接报错:

报错了

# 3. 问题定位实操

# 3.1 打开详细日志(修改 pom.xml)

为便于分析 npm 报错具体在哪一步,可以在 ambari-admin/pom.xml 文件里,把 npm install --unsafe-perm 增加 --verbose 参数。 这样每一步安装过程和失败点都能输出详细日志:


<arguments>install --unsafe-perm --verbose</arguments>
1
2

配置位置如下图:

pom.xml加verbose


# 3.2 只重试失败子模块

编译失败后,无需全量 clean,建议直接针对有问题的模块定点重编。比如只重试 ambari-admin:

mvn -T 2C -B install package rpm:rpm \
  -Drat.skip=true \
  -Dcheckstyle.skip=true \
  -Dmaven.test.skip=true \
  -DskipTests \
  -Dpython.ver="python >= 2.6" \
  -Preplaceurl -rf :ambari-admin -X
1
2
3
4
5
6
7

这样可加快排查节奏高效定位,专注攻克关键点。

# 3.3 典型 npm 报错全貌与影响

编译过程中如果控制台输出如下内容,请务必关注(堆栈较长,仅截取代表性部分):

报错解读

  • 该错误多见于 Node 低版本或网络不可达环境;
  • 只影响 ambari-admin 前端资源构建,不影响 rpm 主产物;
  • 若只关心 rpm 包产出(不需本地开发 UI),可以选择跳过相关错误。
[ERROR] /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karma-phantomjs-launcher/node_modules/phantomjs-prebuilt
/node_modules/request/node_modules/tough-cookie/node_modules/psl/dist/psl.cjs:1
[ERROR] (function (exports, require, module, __filename, __dirname) { "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Sym
bol.toStringTag]:{value:"Module"}});function K(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O,
F;function Q(){if(F)return O;F=1;const e=2147483647,s=36,c=1,o=26,t=38,d=700,z=72,y=128,g="-",P=/^xn--/,V=/[^\0-\x7F]/,G=/[\x2E\u3002\uFF0E\uF
F61]/g,W={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-inp
ut":"Invalid input"},C=s-c,h=Math.floor,I=String.fromCharCode;function v(a){throw new RangeError(W[a])}function U(a,i){const m=[];let n=a.leng
th;for(;n--;)m[n]=i(a[n]);return m}function S(a,i){const m=a.split("@");let n="";m.length>1&&(n=m[0]+"@",a
[ERROR]
[ERROR] SyntaxError: Unexpected token ...
[ERROR]     at exports.runInThisContext (vm.js:53:16)
[ERROR]     at Module._compile (module.js:373:25)
[ERROR]     at Object.Module._extensions..js (module.js:416:10)
[ERROR]     at Module.load (module.js:343:32)
[ERROR]     at Function.Module._load (module.js:300:12)
[ERROR]     at Module.require (module.js:353:17)
[ERROR]     at require (internal/module.js:12:17)
[ERROR]     at Object.<anonymous> (/opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karma-phantomjs-launcher/node
_modules/phantomjs-prebuilt/node_modules/request/node_modules/tough-cookie/lib/pubsuffix-psl.js:32:11)
[ERROR]     at Module._compile (module.js:409:26)
[ERROR]     at Object.Module._extensions..js (module.js:416:10)
[ERROR] npm verb unsafe-perm in lifecycle true
[ERROR] npm info phantomjs-prebuilt@2.1.16 Failed to exec install script
[ERROR] npm verb unlock done using /root/.npm/_locks/phantomjs-prebuilt-0a52d8c736c59c45.lock for /opt/modules/ambari/ambari-admin/src/main/re
sources/ui/admin-web/node_modules/karma-phantomjs-launcher/node_modules/phantomjs-prebuilt
[ERROR] npm verb about to build /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karma-phantomjs-launcher
[ERROR] npm verb unlock done using /root/.npm/_locks/karma-phantomjs-launcher-22c5ff3bd8632bf5.lock for /opt/modules/ambari/ambari-admin/src/m
ain/resources/ui/admin-web/node_modules/karma-phantomjs-launcher
[ERROR] npm verb stack Error: phantomjs-prebuilt@2.1.16 install: `node install.js`
[ERROR] npm verb stack Exit status 1
[ERROR] npm verb stack     at EventEmitter.<anonymous> (/opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node/node_modules/npm
/lib/utils/lifecycle.js:217:16)
[ERROR] npm verb stack     at emitTwo (events.js:87:13)
[ERROR] npm verb stack     at EventEmitter.emit (events.js:172:7)
[ERROR] npm verb stack     at ChildProcess.<anonymous> (/opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node/node_modules/npm
/lib/utils/spawn.js:24:14)
[ERROR] npm verb stack     at emitTwo (events.js:87:13)
[ERROR] npm verb stack     at ChildProcess.emit (events.js:172:7)
[ERROR] npm verb stack     at maybeClose (internal/child_process.js:829:16)
[ERROR] npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
[ERROR] npm verb pkgid phantomjs-prebuilt@2.1.16
[ERROR] npm verb cwd /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web
[ERROR] npm ERR! Linux 5.15.167.4-microsoft-standard-WSL2
[ERROR] npm ERR! argv "/opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node/node" "/opt/modules/ambari/ambari-admin/src/main/
resources/ui/admin-web/node/node_modules/npm/bin/npm-cli.js" "install" "--unsafe-perm" "--verbose"
[ERROR] npm ERR! node v4.5.0
[ERROR] npm ERR! npm  v2.15.0
[ERROR] npm ERR! code ELIFECYCLE
[ERROR]
[ERROR] npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script 'node install.js'.
[ERROR] npm ERR! This is most likely a problem with the phantomjs-prebuilt package,
[ERROR] npm ERR! not with npm itself.
[ERROR] npm ERR! Tell the author that this fails on your system:
[ERROR] npm ERR!     node install.js
[ERROR] npm ERR! You can get information on how to open an issue for this project with:
[ERROR] npm ERR!     npm bugs phantomjs-prebuilt
[ERROR] npm ERR! Or if that isn't available, you can get their info via:
[ERROR] npm ERR!
[ERROR] npm ERR!     npm owner ls phantomjs-prebuilt
[ERROR] npm ERR! There is likely additional logging output above.
[ERROR] npm verb exit [ 1, true ]
[ERROR] npm verb unbuild node_modules/karma-phantomjs-launcher/node_modules/phantomjs-prebuilt
[ERROR] npm info preuninstall phantomjs-prebuilt@2.1.16
[ERROR] npm info uninstall phantomjs-prebuilt@2.1.16
[ERROR] npm verb unbuild rmStuff phantomjs-prebuilt@2.1.16 from /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules
[ERROR] npm verb unbuild rmStuff in /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karma-phantomjs-launcher/nod
e_modules
[ERROR] npm verb gentlyRm vacuuming from /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karma-phantomjs-launche
r/node_modules/.bin/phantomjs up to /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web
[ERROR] npm info postuninstall phantomjs-prebuilt@2.1.16
[ERROR] npm verb gentlyRm don't care about contents; nuking /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karm
a-phantomjs-launcher/node_modules/phantomjs-prebuilt
[ERROR] npm verb unbuild node_modules/karma-phantomjs-launcher
[ERROR] npm info preuninstall karma-phantomjs-launcher@1.0.4
[ERROR] npm info uninstall karma-phantomjs-launcher@1.0.4
[ERROR] npm verb unbuild rmStuff karma-phantomjs-launcher@1.0.4 from /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_mod
ules
[ERROR] npm info postuninstall karma-phantomjs-launcher@1.0.4
[ERROR] npm verb gentlyRm don't care about contents; nuking /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node_modules/karm
a-phantomjs-launcher
[ERROR]
[ERROR] npm ERR! Please include the following file with any support request:
[ERROR] npm ERR!     /opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/npm-debug.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

# 4. 跳过 npm 安装脚本的实践

# 4.1 忽略生命周期脚本命令

实操建议在 ambari-admin 前端目录下执行以下命令,直接跳过生命周期脚本校验:

/opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node/node \
/opt/modules/ambari/ambari-admin/src/main/resources/ui/admin-web/node/node_modules/npm/bin/npm-cli.js \
install --unsafe-perm --verbose --registry=https://registry.npmmirror.com --ignore-scripts
1
2
3

命令执行完成后,如下图所示(依赖被正确解压,生命周期脚本被跳过,无红字): ignore-scripts执行后终端截图1

源代码使用下方内容后

ignore-scripts执行后终端截图2

继续执行 mvn 编译,最后可以正常通过并产出完整 rpm 包,产物目录如下图:

编译通过后的产物截图


# 5. 编译结果验证与 rpm 产物

编译结束后可通过如下命令校验 rpm 包:

find . -iname *.rpm
1

实际 find 命令终端效果如下图(建议新手直接对比目录结构和产物名称):

编译后产物

路径 说明
./ambari-server-spi/target/rpm/ambari-server-spi/RPMS/noarch/ambari-server-spi-2.8.0.0-0.noarch.rpm server接口
./ambari-admin/target/rpm/ambari-admin/RPMS/noarch/ambari-admin-2.8.0.0-0.noarch.rpm admin模块
./ambari-funtest/target/rpm/ambari-funtest/RPMS/noarch/ambari-funtest-2.8.0.0-0.noarch.rpm 测试用例
./ambari-agent/target/rpm/ambari-agent/RPMS/x86_64/ambari-agent-2.8.0.0-0.x86_64.rpm agent服务
./ambari-web/target/rpm/ambari-web/RPMS/noarch/ambari-web-2.8.0.0-0.noarch.rpm 前端资源
./ambari-project/target/rpm/ambari-project/RPMS/noarch/ambari-project-2.8.0.0-0.noarch.rpm 通用项目
./target/rpm/ambari/RPMS/noarch/ambari-2.8.0.0-0.noarch.rpm 集成主包
./ambari-server/target/rpm/ambari-server/RPMS/x86_64/ambari-server-2.8.0.0-0.x86_64.rpm server服务
./ambari-views/target/rpm/ambari-views/RPMS/noarch/ambari-views-2.8.0.0-0.noarch.rpm 视图库
#Ambari#源码编译#构建排错#Node.js#前端依赖
Ambari 源码编译指南-懒人篇
Ambari编译——环境准备

← Ambari 源码编译指南-懒人篇 Ambari编译——环境准备→

最近更新
01
Pandoc 缺失导致 SparkR 构建失败
06-08
02
Cyrus SASL/GSASL 缺失解决
06-07
03
Hadoop_3.3.4 编译实战 1.0.0+
06-06
更多文章>
Theme by Vdoing | Copyright © 2017-2025 JaneTTR | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式