Apache Ambari 2.4.2 源码安全前的环境准备

第1步:检查Ambari源

以下将Ambari git存储库用于开发过程。

git clone https://git-wip-us.apache.org/repos/asf/ambari.git
cd ambari

在本文档中我们将顶级“ambari”目录称为AMBARI_DIR

第2步:构建Ambari所需的工具

从源码构建Ambari需要以下工具。

  1. xCode (如果使用Mac,从苹果商店得到它)
  2. JDK 7 (Ambari 2.0及以下版本可以使用JDK 6编译)
  3. Apache Maven 3.0.5 <- 当构建Ambari代理时Maven 3.1.0 会导致错误

Tip: 为了保持对JAVA_HOME环境变量的更改并将Maven添加到您的路径,请创建以下文件:

File: ~/.profile

source ~/.bashrc

File: ~/.bashrc

export PATH=/usr/local/apache-maven-3.0.5/bin:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
export _JAVA_OPTIONS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"

4.Python 2.6

Python安装工具- python 2.6: 下载 或者 python 2.7: 下载 并且 运行:

2.6:

sh setuptools-0.6c11-py2.6.egg

2.7

sh setuptools-0.6c11-py2.7.egg

5.rpmbuild (rpm-build package)
6.g++ (gcc-c++ package)
7.NodeJS - 最新版本测试的兼容性是v0.10.44(截至2016年4月5日)。 0.12.x将不工作。

下载二进制的tarball, 解压缩,并将bin目录放在PATH中。 验证是否可以运行命令节点和npm。或者,如果使用Fedora 18,可以使用yum安装NodeJS:

#Fedora 18: sudo yum update audit; sudo yum --enablerepo=updates-testing install nodejs npm

Centos
获取nodejs 资源,找到需要的版本

8.Brunch 1.7.20 (要安装它,在安装NodeJS后运行以下命令):

npm install -g brunch@1.7.20

验证是否可以运行命令brunch。最新的版本可能起作用,但1.7.20是已经测试过的最新版本(截至2015年12月10日)。

第3步:运行单元测试

mvn clean 测试

在单节点模式中运行单元测试:

mvn -pl ambari-server test

仅运行Java测试:

mvn -pl ambari-server -DskipPythonTests

仅运行特定的Java测试:

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

只运行Python测试:

mvn -pl ambari-server -DskipSurefireTests test

只运行特定的Python测试:

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

只运行Checkstyle和RAT测试:

mvn -pl ambari-server -DskipTests test

NOTE: 在运行单元测试之前,请确保路径中有npm。

第4步:生成Findbugs报告

mvn clean 安装

这将在target / findbugs目录下生成xml和html报告。还可以添加标志以跳过单元测试,以更快地生成报告。

第5步:构建Ambari

Note: 如果在构建时遇到打开太多文件的错误,则运行:ulimit -n 10000(例如) 要构建Ambari RPM,请运行以下命令。

Note: 将$ {AMBARI_VERSION}替换为一个所需要组件的4位的版本(例如,-DnewVersion = 1.6.1.1)

Note:如果由于缺少jms,jmxri,jmxtools的组件而导致编译ambari-metrics软件包遇到错误时:

[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

解决方法是手动安装三个缺失的组件:

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

如果当编译它时似乎卡住了,你可能已经增加了Java和Maven的堆大小,可能是Ambari视图有很多组件, rat-check阻塞了。在这种情况下,尝试运行如下命令:

git clean -df (这将删除未跟踪的文件和目录)
mvn clean package -DskipTests -Drat.ignoreErrors=true

或者

mvn clean package -DskipTests -Drat.skip

RHEL/Fedora/CentOS 5:

#Fedora 18: You may have to install rpmbuild if its not already installed...
yum --enablerepo=updates-testing install rpm-build

mvn versions:set -DnewVersion=${AMBARI_VERSION}

#Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM. 
#Hence you also need to set ambari-metrics project version as well.
pushd ambari-metrics
mvn versions:set -DnewVersion=${AMBARI_VERSION}
popd

mvn -B clean install package rpm:rpm -DskipTests -Pcentos5 -Dpython.ver="python26" -Preplaceurl
#Note: Or you can use '-Dpython.ver="python > 2.6' as an alternative, which seems to work better in at least one RHEL instance."

RHEL/CentOS 6:

mvn versions:set -DnewVersion=${AMBARI_VERSION}

#Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM.
#Hence you also need to set ambari-metrics project version as well.
pushd ambari-metrics
mvn versions:set -DnewVersion=${AMBARI_VERSION}
popd

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

SUSE/SLES 11:

mvn versions:set -DnewVersion=${AMBARI_VERSION}

#Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM.
#Hence you also need to set ambari-metrics project version as well.
pushd ambari-metrics
mvn versions:set -DnewVersion=${AMBARI_VERSION}
popd

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

Ubuntu 12:

mvn versions:set -DnewVersion=${AMBARI_VERSION}

#Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM.
#Hence you also need to set ambari-metrics project version as well.
pushd ambari-metrics
mvn versions:set -DnewVersion=${AMBARI_VERSION}
popd

mvn -B clean install package jdeb:jdeb -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl
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: 以root身份运行以下所有内容。

第6步:建立Ambari-metrics

如果计划安装Ambari-metrics服务,还需要构建Ambari-metrics项目。

cd ambari-metrics
mvn clean package -Dbuild-rpm -DskipTests

For Ubuntu:

cd ambari-metrics
mvn clean package -Dbuild-deb -DskipTests

Note: metrics rpms将在以下位置找到:ambari-metrics-assembly / target /。这些将需要安装Ambari-metrics服务。

第7步:运行Ambari服务器

首先,安装Ambari服务器RPM
RHEL/CentOS:

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

SUSE/SLES:

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

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

初始化Ambari服务器:

ambari-server setup

启动Ambari 服务器:

ambari-server start

查看 Ambari 服务器日志:

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

要访问Ambari

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

使用admin用户名和密码从Web浏览器登录

第8步:在群集中的每个主机上手动安装和启动Ambari代理

安装Ambari代理RPM

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

通过在 /etc/ambari-agent/conf/ambari-agent.ini 中编辑 hostname line来编辑Ambari服务器的位置

启动Ambari代理:

ambari-agent start

查看Ambari代理日志:

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

第9步:在Eclipse中设置Ambari

$ mvn clean eclipse:eclipse

完成上述操作后,应该能够通过Eclipse导入项目“Import > Maven > Existing Maven Project”,选择克隆git存储库的根目录

能够在eclipse上看到以下项目:

ambari
|
|- ambari-project
|- ambari-server
|- ambari-agent
|- ambari-web

选择顶层“Ambari的pom.xml”,然后单击完成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值