当前位置: 首页 > 工具软件 > Apache Ambari > 使用案例 >

Apache Ambari2.7.3编译

何涵畅
2023-12-01

Apache Ambari2.7.3编译

Apache Ambari是一种基于Web的工具,支持Apache Hadoop集群的供应、管理和监控。Ambari已支持大多数Hadoop组件,包括HDFS、MapReduce、Hive、Pig、 Hbase、Zookeeper、Sqoop和Hcatalog等。
Apache Ambari是apache的一个开源项目。我们可以使用mvn对ambari源码包进行编译,生成rpm包。也可以直接使用Hortonworks提供的编译好的repo和rpm,用以安装。需要说明的是,Hortonworks也是ambari开源贡献者之一,ambari受Hortonworks影响极大。纵使是使用ambari源码编译,过程中也会依赖hortonworks的资源。
2018年10月13日,Cloudera与Hortonworks宣布合并。Cloudera有自己的manager(cloudera manager)来管理hadoop集群,但cm只提供部分基础服务的免费使用。如果是忧虑cloudera和hortonworks合并后对ambari项目的影响,最好做好阅读ambari源码的心理准备。

Ambari+hdp

  1. Ambari repo下载,这是目前能找到的安装包
OSFormatURL
RedHat 7 CentOS 7 Oracle Linux 7Base URLhttp://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0
Repo Filehttp://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo
Tarball md5 / aschttp://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari-2.7.3.0-centos7.tar.gz
  1. 目前网上有的stack,有IOP(IBM Open Platform for Apache Hadoop)和HDP(Hortonworks Data Platform)。如果不想自己配置stack,请使用hdp,方便快捷。
OSVersion NumberRepository NameFormatURL
RedHat 7 CentOS 7 Oracle Linux 7HDP-3.1.0.0HDP Version Definition File (VDF)http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/HDP-3.1.0.0-78.xml
Base URLhttp://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0
Repo Filehttp://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/hdp.repo
Tarball md5 / aschttp://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/HDP-3.1.0.0-centos7-rpm.tar.gz
HDP-UTILSBase URLhttp://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7
Tarball md5 / aschttp://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
HDP-GPLURLhttp://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.0.0/hdp.gpl.repo
Tarball md5 / aschttp://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.0.0/HDP-GPL-3.1.0.0-centos7-gpl.tar.gz
  1. 安装前请详细看看自己的环境与ambari对应版本的适配如何,避免入坑。
    https://supportmatrix.hortonworks.com/
    还有一些依赖包,尽量先装上

    yum and rpm (RHEL/CentOS/Oracle/Amazon Linux)
    zypper and php_curl (SLES)
    apt (Debian/Ubuntu)
    scp, curl, unzip, tar, wget, and gcc*
    OpenSSL (v1.01, build 16 or later)
    Python (with python-devel*)

  2. Repo配置
    解压tar包,修改repo文件的url为本地,rpm --import GPG key
    参考我的另一篇文章(CDH安装):https://blog.csdn.net/qq_44293181/article/details/85613187

  3. Ambari-server安装
    yum install ambari-server
    这一步没有太大问题

ambari-server setup
这里注意看一下描述,需要注意的是使用数据库的配置和LZO

  1. Ambari-server启动及配置
    ambari-server start
    这里使用hdp也没有多大问题,按集群需要配置吧

有时间还是去看看hortonworks的文档吧
https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/hdp_start_the_ambari_server.html

Apache Ambari编译

提前说一下,要用mvn编译ambari,需要很多jar包。如果是私库,不仅要配置maven,还有npm和yarn,还有下载一些较大的源包。编译过程也需要使用sh、rpm等linux命令。建议在外网linux环境进行编译。
https://cwiki.apache.org/confluence/display/AMBARI/Installation+Guide+for+Ambari+2.7.3

依赖

官网文档真的很不友善,很多依赖没有说明。
官网的依赖:
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)

还需要的依赖:
yum install python-devel
nodejs-v4.5.0-linux-x64
npm install -g bower
npm install -g gulp
yum install git
npm install -g brunch@1.7.20

需要强调的是,不要省事配个jre,一定要用jdk1.8。也不要省事,报错了再安装。

下载tar包

wget http://www.apache.org/dist/ambari/ambari-2.7.3/apache-ambari-2.7.3-src.tar.gz
或者手动下载上传
在ambari-metrics包中需下载一些较大的包,先下载吧
http://dev.hortonworks.com.s3.amazonaws.com/HDP/centos7/3.x/BUILDS/3.0.0.0-1634/tars/hbase/hbase-2.0.0.3.0.0.0-1634-bin.tar.gz
http://dev.hortonworks.com.s3.amazonaws.com/HDP/centos7/3.x/BUILDS/3.0.0.0-1634/tars/hadoop/hadoop-3.1.0.3.0.0.0-1634.tar.gz
https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0.linux-x64.tar.gz
http://dev.hortonworks.com.s3.amazonaws.com/HDP/centos7/3.x/BUILDS/3.0.0.0-1634/tars/phoenix/phoenix-5.0.0.3.0.0.0-1634.tar.gz
下载之后要在ambari-metrics/pom.xml里修改url为file///本地路径

编译

tar xfvz apache-ambari-2.7.3-src.tar.gz
cd apache-ambari-2.7.3-src
mvn versions:set -DnewVersion=2.7.3.0.0
pushd ambari-metrics
mvn versions:set -DnewVersion=2.7.3.0.0
popd

mvn -B clean install rpm:rpm -DnewVersion=2.7.3.0.0 -DbuildNumber=4295bb16c439cbc8fb0e7362f19768dde1477868 -DskipTests -Dpython.ver=“python >= 2.6”

过程中可能有如下问题:

  1. Too many files with unapproved license
    mvn命令加上-Drat.skip=true
    2.下载过程网络较差,长时间download没进度
    中断并重试,如报Unexpected character等问题可以试试删除该pom或jar文件重新下载
    3.虚拟机之前设置的1G内存报了内存溢出,我设置了4G就没问题了,建议至少设置2G内存。

这里单独讲一个报错:
—maven-compiler-plugin:3.2:compile(default-compile)@ambari-server—
COMPILATION ERROR
HostRoleCommandEntity.java cannot find symbol
Symbol:method indexes()
Location:@interface javax.persistence.Table

一开始我觉得是jdk或者compiler版本问题,尝试之后发现错误更多。
无奈之下将包导到windows的eclipse里,发现含有javax.persistence.Table的有多个jar包。将不含indexes方法的jar包找出来(commons-logging),通过mvn dependency:tree看看谁依赖引入这个包。在pom文件中dependency用exclusion去掉就解决了。

commons-logging
commons-logging

所以说还是要看看project里的详细信息。

安装

安装类似Hortonworks,yum install->setup->start
Start时报错slf4j,还是引包的问题,反复clean install,将commons-logging去除。
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/lib/ambari-server/commons-logging-1.1.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/lib/ambari-server/slf4j-log4j12-1.7.20.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread “main” java.lang.IncompatibleClassChangeError: Class ch.qos.logback.classic.LoggerContext does not implement the requested interface org.slf4j.ILoggerFactory
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at org.apache.ambari.server.controller.AmbariServer.(AmbariServer.java:181)

重新安装即可
安装过程参考hortonworks文档
https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/hdp_start_the_ambari_server.html

 类似资料: