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:275in /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