This section covers the details involved in getting, installing, and running ONOS. Both single- and multi-instance cases are described.
ONOS and its test scripts are developed and tested on OS X (Mavericks and later) and Ubuntu (14.04 64-bit), with focus on the latter.
We recommend the following if a VM is used for running ONOS:
- Ubuntu Server 14.04 LTS 64-bit
- 2GB or more RAM
- 2 or more processors
In order to build and run ONOS the following are required:
- Java 8 JDK (Oracle Java recommended; OpenJDK is not as thoroughly tested)
- Apache Maven (3.0 and later)
- bash (for packaging & testing)
- Apache Karaf (3.0.2 and later)
Many of these have installers or packages, or, in the case of Karaf, simply be installed by extracting the tar archives to the desired install location.
Finally, to take full advantage of the ONOS test suite and various developer conveniences, it is also recommended that developers have the following tools available on their machines:
- IDE (IntelliJ, Eclipse, etc.)
- VirtualBox (or other VM hosting software)
Java and Maven
The ONOS install process relies on the environment variable JAVA_HOME being properly set. In other words, both
mvn --version and
java -version should report the same Java version:
The best way to prevent this version mismatch is to install Maven before Java 8.
Upgrading to Java 8
For OS X, the latest Oracle Java 8 SDK can be downloaded from Oracle.
For Ubuntu, the following steps will upgrade the installation to Java 8:
You will have to accept the Oracle binary license terms
If not set automatically during the Java 8 installation process, The JAVA_HOME environment variable should be set to the JRE installation location for Java 8. The process for verifying/setting the proper version varies with platform.
On OS X: The current JAVA_HOME may be verified with:
To set the version, either run or add the following to the shell profile:
On Ubuntu: To verify the JAVA_HOME:
If JAVA_HOME is not set or incorrect, either run or add the following to the shell profile:
The ONOS source can be checked out using git:
This clones the repository to your home directory, under a directory named 'onos'.
If the above generates the following error:
make sure that a public key has been uploaded to the ONOS Gerrit by following the steps in the dropdown below.
Generate a key. Keep the default file name and location. This will generate an id_rsa and id_rsa.pub file in ~/.ssh:
- Upload the SSH public key. After logging into the Gerrit account, go to Settings > SSH Public Keys. Paste the contents of id_rsa.pub into the "Add SSH Public Key" box and hit Add:
To get the most from the tools and instructions discussed in the following sections, it is highly recommended that the ONOS_ROOT environment variable is exported in the shell profile (.bash_aliases, .profile, etc.) to refer to the top of the ONOS source tree. For example:
If this is not done, at the very minimum, one should make sure to adjust their path as follows:
Adding Karaf related commands to PATH
To use karaf or onos command described in following sections, $KARAF_HOME/bin needs be added to the PATH environment variable.
By default $ONOS_ROOT/tools/dev/bash_profile expects $KARAF_HOME to be ~/Applications/apache-karaf-$KARAF_VERSION and add them to the PATH.
If you have installed Apache Karaf to a different path, define $KARAF_HOME pointing to the correct path before including $ONOS_ROOT/tools/dev/bash_profile
ONOS uses Maven for managing the build process. To build the ONOS code-base from the top-most level, and from scratch, simply type the following:
This triggers a full build, complete with unit testing. This may take several minutes, depending on the compute resources of the machine used. When complete, there should be an output similar to the following:
ONOS may be run on the build machine directly, or packaged and launched on remote machines or VMs. This section describes both launching ONOS on the build machine (locally), and packaging and deploying on a remote (target) machine.
Deployment Scenario: Running locally on build machine
Karaf must first be configured to load the ONOS-related modules. In
Append the following to featuresRepositories:
Append the following to featuresBoot:
The above loads the trivial (single-instance) ONOS core, forwarding and topology viewer applications.
After running maven as described in Building ONOS and making the above changes,
karaf can be used to start ONOS and attach to its CLI:
At this point, typing
help onos at the prompt should still bring up a list of available commands. Hitting <Ctrl-D> or
logout will exit the CLI.
Launching karaf may bring up the default karaf prompt, without the 'ONOS' ASCII art. This is purely cosmetic, and shouldn't affect functionality.
If the branding is desired, one can move the branding bundle created during the build process to karaf's lib directory:
And relaunch karaf.
Deployment Scenario: Running remotely with
Remote installations are useful when one wishes to run multiple ONOS instances in a cluster. This section demonstrates remote installation on a single remote machine.
The ONOS build process produces a number of OSGi bundles, which are essentially Java jar files. One could simply deploy these bundles in any OSGi container to run ONOS, but this would require that such container be installed, properly configured, and that the bundles be collected and properly staged. The ONOS utility scripts,
onos-install, simplifies this task by packaging the ONOS binaries into a distributable compressed tar.
The prerequisites for using these scripts are:
- The Apache Karaf binaries (either .zip or .tar.gz format) are available in ~/Downloads of the build machine
- The ONOS source has been built
- The install target has a Java 8 JRE installed
onos-install relies on
ssh to deploy the package to the target machine. Therefore:
- Either the target machine should have a user named 'sdn', or on the build machine, the ONOS_USER environment variable should be exported with the username used in the target machine
- Password-less (e.g. key-based) login should be enabled on the target.
If 1 is met, the onos-push-keys utility can be used to transfer one's public keys to targets. This requires that the keys have been generated prior to using the utility. Additionally, the ONOS_FEATURES variable should be set to the list of modules Karaf should start up:
onos-package produces a self-contained tar archive.
As seen above, the file has the naming convention "onos-1.0.0.<username>.tar.gz", and is created under the /tmp/ directory.
This file can be deployed by pointing
onos-install to the remote target to run ONOS on (192.168.56.20 in this example):
Once ONOS is running, the
onos utility can be used to attach to the remote instance's CLI:
onos-install -f [target]will force a reinstall.
Handling multiple remote targets
For dealing with multiple remote machines, the behavior of the ONOS utilities can be streamlined by employing test cells. Test cells are discussed under Test Environment Setup in the Developer's Guide.
If Things go Wrong
Both Maven and Karaf rely on network access for some of their functionality. One of the first points to check if a build fails is to check for connectivity, and rebuild the project once it is restored.
In Karaf, connectivity issues may manifest as bundles not loading (e.g. not being able to use any ONOS-related commands, or
help onos returning nothing). It may also take some time for ONOS to fully boot up, in which case some commands may not be available for the first minute or so.