Checking out Ambari source
The following uses the Ambari git repository for the development process.
git clone https://git-wip-us.apache.org/repos/asf/ambari.git cd ambari
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, get it from the apple store)
- JDK 1.6.0
- Apache Maven 3.0.5 <- Maven 3.1.0 results in errors when building ambari-agent
Tip: In order to persist your changes to the JAVA_HOME environment variable and add Maven to your path, create the following files:File: ~/.profilesource ~/.bashrc
File: ~/.bashrcexport 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"
- Python 2.6
Python setuptools - python 2.6: Download or python 2.7: Download and run:
2.6:sh setuptools-0.6c11-py2.6.egg
2.7
sh setuptools-0.6c11-py2.7.egg
- rpmbuild (rpm-build package)
- g++ (gcc-c++ package)
NodeJS - Latest version tested for compatibility is v0.10.31 (as of Sept 16, 2014). Download the binary tarball, extract, and put the bin directory in your PATH. Verify that you can run the command node and npm. Alternatively, you can use yum to install NodeJS if you are on Fedora 18:
#Fedora 18: sudo yum update audit; sudo yum --enablerepo=updates-testing install nodejs npm
Brunch 1.7.17 (to install it, run the following command after NodeJS is installed):
npm install -g brunch@1.7.17
Verify that you can run the command brunch. Later versions may work, but 1.7.17 is the latest version that has been tested (as of Oct 1, 2014).
Running Unit Tests
- mvn clean test
NOTE: Please make sure you have npm in the path before running the unit tests.
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)
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} mvn -B clean install package rpm:rpm -DnewVersion=${AMBARI_VERSION} -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} mvn -B clean install package rpm:rpm -DnewVersion=${AMBARI_VERSION} -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl
SUSE/SLES 11:
mvn versions:set -DnewVersion=${AMBARI_VERSION} mvn -B clean install package rpm:rpm -DnewVersion=${AMBARI_VERSION} -DskipTests -Psuse11 -Dpython.ver="python >= 2.6" -Preplaceurl
Ubuntu 12:
mvn versions:set -DnewVersion=${AMBARI_VERSION} mvn -B clean install package jdeb:jdeb -DnewVersion=${AMBARI_VERSION} -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
- 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.
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.