CentOS7 Ambari2.7.5編譯

目錄

 

1.前言

2.編譯環境安裝

3.下載源碼編譯

4.大包提前下載

5.報錯處理

5.1.報錯

5.2.報錯

5.3.報錯

5.4.報錯

5.5.報錯

5.6.報錯

5.7.報錯

6.編譯成功

7.官方說明


1.前言

本文講解了在純淨CentOS7環境下,編譯Ambari2.7.5所需進行的一系列操作及異常處理。

附參考資料連接:

編譯官方說明

https://cwiki.apache.org/confluence/display/AMBARI/Ambari+Development

部署官方說明

https://cwiki.apache.org/confluence/display/AMBARI/Installation+Guide+for+Ambari+2.7.5

git地址:https://github.com/apache/ambari

吐槽啊,此版本對應的HDP3.1.5無法下載,編譯後也無法完成全部的部署……

官方說明打開較慢,爲了方便大家,文末附官方說明。

 

2.編譯環境安裝

yum install -y java-1.8.0-openjdk

yum 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

tar xzvf apache-maven-3.6.3-bin.tar.gz

 

 

 

#pip安裝(官方中說安裝setuptools即可,pip比較好裝,包含了setuptools)

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

 

nodejs環境安裝

yum install epel-release

yum install nodejs -y

升級nodejs

sudo npm install n -g

sudo n stable

 

vi ~/.bash_profile

添加

export PATH=/usr/local/bin/:$PATH:/root/apache-maven-3.6.3/bin

 

再執行

source ~/.bash_profile

 

 

安裝yarn

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

sudo yum install yarn

 

npm install -g bower

npm install -g gulp

 

3.下載源碼編譯

http://www.apache.org/dyn/closer.cgi/ambari/ambari-2.7.5

找到鏡像服務器下載

https://mirrors.tuna.tsinghua.edu.cn/apache/ambari/ambari-2.7.5/apache-ambari-2.7.5-src.tar.gz

下載後解壓

tar xfvz apache-ambari-2.7.5-src.tar.gz
cd apache-ambari-2.7.5-src
mvn versions:set -DnewVersion=2.7.5.0.0


pushd ambari-metrics
mvn versions:set -DnewVersion=2.7.5.0.0
popd

#編譯
mvn -B clean install rpm:rpm -DnewVersion=2.7.5.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

 

覺得下載依賴包特別慢的,可以添加阿里雲鏡像

vi pom.xml

添加相應節點:

<repositories>
    <repository>
        <id>aliyun</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-apache snapshots</id>
        <url>https://maven.aliyun.com/repository/apache-snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-central</id>
        <url>https://maven.aliyun.com/repository/central</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-google</id>
        <url>https://maven.aliyun.com/repository/google</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-gradle-plugin</id>
        <url>https://maven.aliyun.com/repository/gradle-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-jcenter</id>
        <url>https://maven.aliyun.com/repository/jcenter</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-spring</id>
        <url>https://maven.aliyun.com/repository/spring</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-spring-plugin</id>
        <url>https://maven.aliyun.com/repository/spring-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-public</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-releases</id>
        <url>https://maven.aliyun.com/repository/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-snapshots</id>
        <url>https://maven.aliyun.com/repository/snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-grails-core</id>
        <url>https://maven.aliyun.com/repository/grails-core</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>aliyun-mapr-public</id>
        <url>https://maven.aliyun.com/repository/mapr-public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>aliyun-plugin</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-apache snapshots</id>
        <url>https://maven.aliyun.com/repository/apache-snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-central</id>
        <url>https://maven.aliyun.com/repository/central</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-google</id>
        <url>https://maven.aliyun.com/repository/google</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-gradle-plugin</id>
        <url>https://maven.aliyun.com/repository/gradle-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-jcenter</id>
        <url>https://maven.aliyun.com/repository/jcenter</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-spring</id>
        <url>https://maven.aliyun.com/repository/spring</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-spring-plugin</id>
        <url>https://maven.aliyun.com/repository/spring-plugin</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-public</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-releases</id>
        <url>https://maven.aliyun.com/repository/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-snapshots</id>
        <url>https://maven.aliyun.com/repository/snapshots</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-grails-core</id>
        <url>https://maven.aliyun.com/repository/grails-core</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>aliyun-plugin-mapr-public</id>
        <url>https://maven.aliyun.com/repository/mapr-public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

 

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-6.4.2</grafana.folder>

<grafana.tar>https://dl.grafana.com/oss/release/grafana-6.4.2.linux-amd64.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地址,下載使用更快捷

 

5.報錯處理

5.1.報錯

[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

 

5.2.報錯

[ERROR] warning [email protected]: The platform "linux" is incompatible with this module.

解決

npm install pm2@latest -g

pm2 install pm2-slack

(執行後上面的錯誤也還存在,但是可以往下走,這裏發現了需要安裝bower,安裝這個即可)

安裝bower的依賴包(個人在ambari-admin/src/main/resources/ui/admin-web/下執行)

bower install --allow-root

 

5.3.報錯

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是一個大於報錯信息中的數量。

 

 

5.4.報錯

ClassNotFoundException : Com.Sun.Jersey.Spi.Container.Servlet.ServletContainer

解決

vi ambari-metrics/ambari-metrics-timelineservice/pom.xml

添加依賴(注意version與其他一致即可)

<dependency>

<groupId>com.sun.jersey</groupId>

<artifactId>jersey-bundle</artifactId>

<version>1.11</version>

</dependency>

 

5.5.報錯

[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

 

5.6.報錯

/root/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-aggregator/src/test/java/org/apache/hadoop/metrics2/host/aggregator/AggregatorWebServiceTest.java:[22,33] 程序包com.sun.jersey.api.client不存在

 

解決

vi ambari-metrics/ambari-metrics-host-aggregator/pom.xml

添加依賴

<dependency>

<groupId>com.sun.jersey</groupId>

<artifactId>jersey-client</artifactId>

<version>1.11</version>

</dependency>

5.7.報錯

[ERROR] /root/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-aggregator/src/test/java/org/apache/hadoop/metrics2/host/aggregator/AggregatorWebServiceTest.java:[31,34] 程序包org.codehaus.jackson.jaxrs不存在

[ERROR] /root/apache-ambari-2.7.5-src/ambari-metrics/ambari-metrics-host-aggregator/src/test/java/org/apache/hadoop/metrics2/host/aggregator/AggregatorWebServiceTest.java:[49,55] 找不到符號

符號: 類 JacksonJaxbJsonProvider

位置: 類 org.apache.hadoop.metrics2.host.aggregator.AggregatorWebServiceTest

解決

vi ambari-metrics/ambari-metrics-host-aggregator/pom.xml

添加依賴

<dependency>

<groupId>org.codehaus.jackson</groupId>

<artifactId>jackson-jaxrs</artifactId>

<version>1.9.13</version>

</dependency>

注意要看清是codehaus的,不是fasterxml的,別添加錯了

 

6.編譯成功

[INFO] Rat check: Summary over all files. Unapproved: 0, unknown: 0, generated: 0, approved: 17 licenses.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Ambari Main 2.7.5.0.0 .............................. SUCCESS [  5.378 s]
[INFO] Apache Ambari Project POM 2.7.5.0.0 ................ SUCCESS [  0.170 s]
[INFO] Ambari Web 2.7.5.0.0 ............................... SUCCESS [01:00 min]
[INFO] Ambari Views 2.7.5.0.0 ............................. SUCCESS [  1.265 s]
[INFO] Ambari Admin View 2.7.5.0.0 ........................ SUCCESS [ 26.880 s]
[INFO] ambari-utility 1.0.0.0-SNAPSHOT .................... SUCCESS [ 15.939 s]
[INFO] ambari-metrics 2.7.5.0.0 ........................... SUCCESS [  0.626 s]
[INFO] Ambari Metrics Common 2.7.5.0.0 .................... SUCCESS [  4.607 s]
[INFO] Ambari Metrics Hadoop Sink 2.7.5.0.0 ............... SUCCESS [  2.358 s]
[INFO] Ambari Metrics Flume Sink 2.7.5.0.0 ................ SUCCESS [  1.527 s]
[INFO] Ambari Metrics Kafka Sink 2.7.5.0.0 ................ SUCCESS [  1.630 s]
[INFO] Ambari Metrics Storm Sink 2.7.5.0.0 ................ SUCCESS [  1.693 s]
[INFO] Ambari Metrics Storm Sink (Legacy) 2.7.5.0.0 ....... SUCCESS [  1.743 s]
[INFO] Ambari Metrics Collector 2.7.5.0.0 ................. SUCCESS [02:56 min]
[INFO] Ambari Metrics Monitor 2.7.5.0.0 ................... SUCCESS [  2.459 s]
[INFO] Ambari Metrics Grafana 2.7.5.0.0 ................... SUCCESS [  1.618 s]
[INFO] Ambari Metrics Host Aggregator 2.7.5.0.0 ........... SUCCESS [  5.608 s]
[INFO] Ambari Metrics Assembly 2.7.5.0.0 .................. SUCCESS [01:00 min]
[INFO] Ambari Service Advisor 1.0.0.0-SNAPSHOT ............ SUCCESS [  0.531 s]
[INFO] Ambari Server 2.7.5.0.0 ............................ SUCCESS [03:25 min]
[INFO] Ambari Functional Tests 2.7.5.0.0 .................. SUCCESS [  0.550 s]
[INFO] Ambari Agent 2.7.5.0.0 ............................. SUCCESS [ 51.679 s]
[INFO] ambari-logsearch 2.7.5.0.0 ......................... SUCCESS [  1.299 s]
[INFO] Ambari Logsearch Appender 2.7.5.0.0 ................ SUCCESS [  0.262 s]
[INFO] Ambari Logsearch Config Api 2.7.5.0.0 .............. SUCCESS [  0.239 s]
[INFO] Ambari Logsearch Config JSON 2.7.5.0.0 ............. SUCCESS [  0.196 s]
[INFO] Ambari Logsearch Config Solr 2.7.5.0.0 ............. SUCCESS [  0.199 s]
[INFO] Ambari Logsearch Config Zookeeper 2.7.5.0.0 ........ SUCCESS [  0.185 s]
[INFO] Ambari Logsearch Config Local 2.7.5.0.0 ............ SUCCESS [  0.182 s]
[INFO] Ambari Logsearch Log Feeder Plugin Api 2.7.5.0.0 ... SUCCESS [  0.179 s]
[INFO] Ambari Logsearch Log Feeder Container Registry 2.7.5.0.0 SUCCESS [  0.346 s]
[INFO] Ambari Logsearch Log Feeder 2.7.5.0.0 .............. SUCCESS [  3.645 s]
[INFO] Ambari Logsearch Web 2.7.5.0.0 ..................... SUCCESS [ 55.186 s]
[INFO] Ambari Logsearch Server 2.7.5.0.0 .................. SUCCESS [  5.825 s]
[INFO] Ambari Logsearch Assembly 2.7.5.0.0 ................ SUCCESS [  0.176 s]
[INFO] Ambari Logsearch Integration Test 2.7.5.0.0 ........ SUCCESS [  0.887 s]
[INFO] ambari-infra 2.7.5.0.0 ............................. SUCCESS [  0.166 s]
[INFO] Ambari Infra Solr Client 2.7.5.0.0 ................. SUCCESS [01:03 min]
[INFO] Ambari Infra Solr Plugin 2.7.5.0.0 ................. SUCCESS [  0.490 s]
[INFO] Ambari Infra Manager 2.7.5.0.0 ..................... SUCCESS [  5.827 s]
[INFO] Ambari Infra Assembly 2.7.5.0.0 .................... SUCCESS [  0.165 s]
[INFO] Ambari Infra Manager Integration Tests 2.7.5.0.0 ... SUCCESS [  1.310 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12:51 min
[INFO] Finished at: 2020-03-11T17:11:54+08:00
[INFO] ------------------------------------------------------------------------

成功

一系列漫長的折磨,斷斷續續兩三天,終於成功了!

總結教訓:

1.用阿里雲鏡像,能加速很多

2.關注幾個常用的編譯工具,問題出現在這些點上的時候要想到是不是他沒安裝的問題。

感慨啊

這麼牛的開源項目還缺少maven依賴包配置,也是醉了……

 

 

 

7.官方說明

Build and install Ambari 2.7.5

 

Refer Ambari Development for prerequisites and additional information on how to build Apache Ambari.

 

Step 1: Download and build Ambari 2.7.5 source

Go to http://www.apache.org/dyn/closer.cgi/ambari/ambari-2.7.5 and find the suggested mirror for download. The process to verify the download is described is at http://www.apache.org/dyn/closer.cgi#verify

wget https://www-eu.apache.org/dist/ambari/ambari-2.7.5/apache-ambari-2.7.5-src.tar.gz (use the suggested mirror from above) tar xfvz apache-ambari-2.7.5-src.tar.gz cd apache-ambari-2.7.5-src mvn versions:set -DnewVersion=2.7.5.0.0 pushd ambari-metrics mvn versions:set -DnewVersion=2.7.5.0.0 popd

 

RHEL (CentOS 7) & SUSE (SLES 12 SP2 & SP3):

mvn -B clean install rpm:rpm -DnewVersion=2.7.5.0.0 -DbuildNumber=5895e4ed6b30a2da8a90fee2403b6cab91d19972 -DskipTests -Dpython.ver="python >= 2.6"

 

Ubuntu/Debian:

mvn -B clean install jdeb:jdeb -DnewVersion=2.7.5.0.0 -DbuildNumber=5895e4ed6b30a2da8a90fee2403b6cab91d19972 -DskipTests -Dpython.ver="python >= 2.6"

 

Note: You need to have tools such as rpm-build tool, brunch, etc.  For details on prerequisites, please see Ambari Development.

Step 2: Install Ambari Server

Install the rpm package from ambari-server/target/rpm/ambari-server/RPMS/noarch/

[For CentOS 7]

yum install ambari-server*.rpm    #This should also pull in postgres packages as well.

[For SLES 12]

zypper install ambari-server*.rpm    #This should also pull in postgres packages as well.

[For Ubuntu/Debian]

apt-get install ./ambari-server*.deb   #This should also pull in postgres packages as well.

Step 3: Setup and Start Ambari Server

Run the setup command to configure your Ambari Server, Database, JDK, LDAP, and other options:

ambari-server setup

Follow the on-screen instructions to proceed.

Once set up is done, start Ambari Server:

ambari-server start

Step 4: Install and Start Ambari Agent on All Hosts

Note: This step needs to be run on all hosts that will be managed by Ambari.

Copy the rpm package from ambari-agent/target/rpm/ambari-agent/RPMS/x86_64/ and run:

[For CentOS 7]

yum install ambari-agent*.rpm

[For SLES 12]

zypper install ambari-agent*.rpm

[Ubuntu/Debian]

apt-get install ./ambari-agent*.deb

Edit /etc/ambari-agent/ambari.ini

... [server] hostname=localhost ...

Make sure hostname under the [server] section points to the actual Ambari Server host, rather than "localhost".

ambari-agent start

Step 5: Deploy Cluster using Ambari Web UI

Open up a web browser and go to http://<ambari-server-host>:8080.

Log in with username admin and password admin and follow on-screen instructions. Secure your environment by ensuring your administrator details are changed from the default values as soon as possible.

Under Install Options page, enter the hosts to add to the cluster.  Do not supply any SSH key, and check "Perform manual registration on hosts and do not use SSH" and hit "Next".

 

Ambari Development

轉至元數據結尾

轉至元數據起始

Checking out Ambari source

Follow the instructions under Checkout source code section of "How to contribute" guide.

We'll refer to the top-level "ambari" directory as AMBARI_DIR in this document.

Tools needed to build Ambari

The following tools are needed to build Ambari from source.

Alternatively, you can easily launch a VM that is preconfigured with all the tools that you need.  See the Pre-Configured Development Environment section in the Quick Start Guide.

  • xCode (if using Mac - free download from the apple store)
  • JDK 8 (Ambari 2.6 and below can be compiled with JDK 7, from Ambari 2.7, it can be compiled with at least JDK 8)
  • Apache Maven 3.3.9 or later

Tip: In order to persist your changes to the JAVA_HOME environment variable and add Maven to your path, create the following files:

File: ~/.profile

 

source ~/.bashrc

File: ~/.bashrc

 

export PATH=/usr/local/apache-maven-3.3.9/bin:$PATH

export JAVA_HOME=$(/usr/libexec/java_home)

export _JAVA_OPTIONS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"

  • Python 2.6 (Ambari 2.7 or later require Python 2.7 as minimum supported version)
  • Python setuptools:

for Python 2.6: Download setuptools and run:

sh setuptools-0.6c11-py2.6.egg

for Python 2.7:  Download setuptools and run:

sh setuptools-0.6c11-py2.7.egg

  • rpmbuild (rpm-build package)
  • g++ (gcc-c++ package)

Running Unit Tests

  • mvn clean test
  • Run unit tests in a single module:

mvn -pl ambari-server test

  • Run only Java tests:

mvn -pl ambari-server -DskipPythonTests

  • Run only specific Java tests:

mvn -pl ambari-server -DskipPythonTests -Dtest=AgentHostInfoTest test

  • Run only Python tests:

mvn -pl ambari-server -DskipSurefireTests test

  • Run only specific Python tests:

mvn -pl ambari-server -DskipSurefireTests -Dpython.test.mask=TestUtils.py test

  • Run only Checkstyle and RAT checks:

mvn -pl ambari-server -DskipTests test

NOTE: Please make sure you have npm in the path before running the unit tests.

Generating Findbugs Report

  • mvn clean install

This will generate xml and html report unders target/findbugs. You can also add flags to skip unit tests to generate report faster.

Building Ambari

Note: if you can an error that too many files are open while building, then run: ulimit -n 10000 (for example)

To build Ambari RPMs, run the following.

Note: Replace ${AMBARI_VERSION} with a 4-digit version you want the artifacts to be (e.g., -DnewVersion=1.6.1.1)

Note: If running into errors while compiling the ambari-metrics package due to missing the artifacts of jms, jmxri, jmxtools:

 

[ERROR] Failed to execute goal on project ambari-metrics-kafka-sink: Could not resolve dependencies for project org.apache.ambari:ambari-metrics-kafka-sink:jar:2.0.0-0: The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories WagonRepositoryConnectorFactory

The work around is to manually install the three missing artifacts:

 

mvn install:install-file -Dfile=jms-1.1.pom -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 -Dpackaging=jar

mvn install:install-file -Dfile=jmxtools-1.2.1.pom -DgroupId=com.sun.jdmk -DartifactId=jmxtools -Dversion=1.2.1 -Dpackaging=jar

mvn install:install-file -Dfile=jmxri-1.2.1.pom -DgroupId=com.sun.jmx -DartifactId=jmxri -Dversion=1.2.1 -Dpackaging=jar

 

If when compiling it seems stuck, and you've already increased Java and Maven heapsize, it could be that Ambari Views has a lot of artifacts, and the rat-check is choking up. In this case, try running

git clean -df (this will remove untracked files and directories)

mvn clean package -DskipTests -Drat.ignoreErrors=true

or

mvn clean package -DskipTests -Drat.skip

 

Setting the Version Using Maven

Ambari 2.8+ uses a newer method to update the version when building Ambari. 

RHEL/CentOS 6:

# Update the revision property to the release version

mvn versions:set-property -Dproperty=revision -DnewVersion=2.8.0.0.0

 

mvn -B clean install package rpm:rpm -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl

 

SUSE/SLES 11

# Update the revision property to the release version

mvn versions:set-property -Dproperty=revision -DnewVersion=2.8.0.0.0

  

mvn -B clean install package rpm:rpm -DskipTests -Psuse11 -Dpython.ver="python >= 2.6" -Preplaceurl

 

Ubuntu 12:

# Update the revision property to the release version

mvn versions:set-property -Dproperty=revision -DnewVersion=2.8.0.0.0

  

mvn -B clean install package jdeb:jdeb -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl

 

Ambari 2.7 and Earlier Releases (Deprecated)

RHEL/CentOS 6: 展開源碼

 

SUSE/SLES 11 展開源碼

 

Ubuntu 12: 展開源碼

 

Ambari Server will create following packages

  • RPM will be created under AMBARI_DIR/ambari-server/target/rpm/ambari-server/RPMS/noarch.
  • DEB will be created under AMBARI_DIR/ambari-server/target/

Ambari Agent will create following packages

  • RPM will be created under AMBARI_DIR/ambari-agent/target/rpm/ambari-agent/RPMS/x86_64.
  • DEB will be created under AMBARI_DIR/ambari-agent/target

Optional parameters:

  • -X -e: add these options for more verbose output by Maven.  Useful when debugging Maven issues.
  • -DdefaultStackVersion=STACK-VERSION
  • Sets the default stack and version to be used for installation (e.g., -DdefaultStackVersion=HDP-1.3.0)
  • -DenableExperimental=true
  • Enables experimental features to be available via Ambari Web (default is false)
  • All views can be packaged in RPM by adding -Dviews parameter
    • mvn -B clean install package rpm:rpm -Dviews -DskipTests
  • Specific views can be built by adding --projects parameter to the -Dviews
    • mvn -B clean install package rpm:rpm --projects ambari-web,ambari-project,ambari-views,ambari-admin,contrib/views/files,contrib/views/pig,ambari-server,ambari-agent,ambari-client,ambari-shell -Dviews -DskipTests

 

NOTE: Run everything as root below.

Building Ambari Metrics

If you plan on installing the Ambari Metrics service, you will also need to build the Ambari Metrics project. 

cd ambari-metrics

mvn clean package -Dbuild-rpm -DskipTests

 

For Ubuntu:

cd ambari-metrics

mvn clean package -Dbuild-deb -DskipTests

Note:

The metrics rpms will be found at: ambari-metrics-assembly/target/. These would be need for installing the Ambari Metrics service.

Running the Ambari Server

First, install the Ambari Server RPM.

On RHEL/CentOS:

yum install ambari-server/target/rpm/ambari-server/RPMS/noarch/ambari-server-*.noarch.rpm

On SUSE/SLES:

zypper install ambari-server/target/rpm/ambari-server/RPMS/noarch/ambari-server-*.noarch.rpm

On Ubuntu 12:

  

dpkg --install ambari-server/target/ambari-server-*.deb          # Will fail with missing dependencies errors

apt-get update                                                   # Update locations of dependencies

apt-get install -f                                               # Install all failed dependencies

dpkg --install ambari-server/target/ambari-server-*.deb          # Will succeed

Initialize Ambari Server:

ambari-server setup

Start up Ambari Server:

ambari-server start

See Ambari Server log:

tail -f /var/log/ambari-server/ambari-server.log

To access Ambari, go to

http://{ambari-server-hostname}:8080

from your web browser and log in with username admin and password admin.

Install and Start the Ambari Agent Manually on Each Host in the Cluster

Install the Ambari Agent RPM.

On RHEL/CentOS:

yum install ambari-agent/target/rpm/ambari-agent/RPMS/x86_64/ambari-agent-*.rpm

SUSE/SLES:

zypper install ambari-agent/target/rpm/ambari-agent/RPMS/x86_64/ambari-agent-*.rpm

Ubuntu12:

dpkg --install ambari-agent/target/ambari-agent-*.deb

Edit the location of Ambari Server in /etc/ambari-agent/conf/ambari-agent.ini by editing the hostname line.

Start Ambari Agent:

ambari-agent start

See Ambari Agent log:

tail -f /var/log/ambari-agent/ambari-agent.log

Setting up Ambari in Eclipse

$ mvn clean eclipse:eclipse

After doing the above you should be able to import the project via Eclipse "Import > Maven > Existing Maven Project". Choose the root directory where you cloned the git repository. You should be able to see the following projects on eclipse:

ambari

|

|- ambari-project

|- ambari-server

|- ambari-agent

|- ambari-web

Select the top-level "ambari pom.xml" and click Finish.

Coding Guidelines for Ambari

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章