1.需要安装的工具
1.1 安装JDK 推荐1.8
1.2 安装Apache Maven 3.3.9
设置环境变量
# vi /etc/profile
export MAVEN_HOME="/opt/maven"
export path=$path: $MAVEN_HOME/bin
1.3 安装rpmbuild
1)检测rpm-build是否已经安装
[root@bigData-02 ~]# rpm -qa | grep rpm-build
2)安装
[root@bigData-02 ~]# yum install rpm-build
1.4 安装g++
- 检测
[root@bigData-02 ~]# rpm -qa | grep gcc-c++
- 安装
[root@bigData-02 ~]# yum install gcc-c++
1.5 安装NodeJS
- 下载
[root@bigData-02 ~]# wget http://nodejs.org/dist/v6.10.3/node-v6.10.3-linux-x64.tar.gz
- 解压
[root@bigData-02 ~]# tar –zxvf node-v6.10.3-linux-x64.tar.gz
- 设置环境变量
[root@bigData-02 ~]# vi /etc/profile
export NODE_HOME="/opt/node"
export path=$path: $NODE_HOME/bin
[root@bigData-02 ~]#source /etc/profile
- 检测是否正确安装
[root@bigData-02 ~]# node -v
v0.10.33
[root@bigData-02 ~]# npm -v
1.4.28
1.6 安装Brunch
1)安装
[root@bigData-02 ~]# npm install -g brunch
- 检测
[root@bigData-02 ~]# brunch
Usage: brunch [command] [options]
Commands:
new [skeleton] [path] Create new brunch project in path [.]. Short-cut: n
build [options] Build a brunch project. Short-cut: b
watch [options] Watch brunch directory and rebuild if something changed. Short-cut: w
Options:
-h, --help output usage information
-V, --version output the version number
1.7 安装git
- 检测
[root@bigData-02 ~]# Git –version
- 安装
[root@bigData-02 ~]# yum install git
2 编译Ambari
2.1 下载
在官网下载最新版本2.5.0
解压之后上传到linux服务器上。
2.2 编译
进入到ambari的主目录中,执行mvn编译命令。
- 给ambari打上版本号
[root@bigData-02 ~]#
mvn versions:set -DnewVersion=
2.5
.
0.0
.
0
pushd ambari-metrics
mvn versions:set -DnewVersion=
2.5
.
0.0
.
0
popd
- 编译ambari
[root@bigData-02 ambari]#
mvn -B clean install
package
rpm:rpm -DnewVersion=
2.5
.
0.0
.
0
-DskipTests -Dpython.ver=
"python >= 2.6"
自此编译成功。
编译技巧:
1)需要注意的是此处maven编译大约要下载258M左右的依赖,在网络不好的情况下经常会出现time out的异常,并且需要反复编译,特别耗时,第一次编译大概花了一天时间,因此编译的时候可以对project进行逐个编译,节约时间。
2)项目中需要使用nodejs中的npm管理依赖,有些依赖特别难下载,下载好之后会存放在ambari-web/node_modules中,在下次编译的时候可以对ambari-web/node_modules备份,下次编译的时候,可以先对项目进行mvn clean删除,然后再将备份的node_modules拷入项目中,重新执行mvn install操作,可以节省很多时间。
psutils-compile错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin: 1.7 :run (psutils-compile) on project ambari-metrics-host-monitoring: An Ant BuildException has occured: exec returned: 1 [ERROR] around Ant part ... <exec failοnerrοr= "true" dir= "/root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable= "/root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap" > ... @ 4 : 275 in /root/apache-ambari- 2.5 .0 -src/ambari-metrics/ambari-metrics-host-monitoring/target/antrun/build-psutils-compile.xml[ERROR] -> [Help 1 ] 根据该错误信息,打开xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="psutils-compile" >
<target name="psutils-compile">
<exec failοnerrοr="true" dir="/root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil" executable="/root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap">
<arg value="setup.py"/>
<arg value="build"/>
<arg value="--build-platlib"/>
<arg value="/root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/target/psutil_build"/>
</exec>
</target>
</project>
带上参数执行了一下wrap:
[root@bluejoe0 apache-ambari-2.5.0-src]# /root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/uniython-wrap setup.py build --build-platlib /root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/target/psutil_build
/usr/bin/python2: can't open file 'setup.py': [Errno 2] No such file or directory
[root@bluejoe0 apache-ambari-2.5.0-src]# cd /root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/psutil
[root@bluejoe0 psutil]# /root/apache-ambari-2.4.2-src/ambari-metrics/ambari-metrics-host-monitoring/../../ambari-common/src/main/unix/ambari-python-wrap setup.py build --build-platlib /root/apache-ambari-2.5.0-src/ambari-metrics/ambari-metrics-host-monitoring/target/psutil_build
running build
running build_py
running build_ext
building '_psutil_linux' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.6 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_linux.o
psutil/_psutil_linux.c:12:20: error: Python.h: No such file or directory
In file included from psutil/_psutil_linux.c:23:
psutil/_psutil_linux.h:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.h:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.h:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.h:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.h:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.h:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.h:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
psutil/_psutil_linux.c: In function ‘ioprio_get’:
psutil/_psutil_linux.c:50: warning: implicit declaration of function ‘syscall’
类似这样的错误,在网上查了一下,告知需要安装Python-devel版本,因此:
yuminstall python-devel
遇到没有安装setuptools的话,运行下面的语句。
yum install python-pip
2.3 安装RPM包
Ambari安装需要ambari-server安装到管理机上,ambari-agent安装到集群节点上。
Ambari-server的rpm包
ambari-server/target/rpm/ambari-server/RPMS/noarch/ambari-server-*.noarch.rpm
Ambari-agent的rpm包
ambari-agent/target/rpm/ambari-agent/RPMS/x86_64/ambari-agent-*.rpm
操作指南,请查阅:
https://www.ibm.com/developerworks/cn/opensource/os-cn-bigdata-ambari/index.html