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.3.1
- bash (for packaging & testing)
- Apache Karaf 3.0.3
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)
Installation - Java, Maven, and Karaf
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.
Maven and Karaf
The binaries for both Maven and Karaf can be downloaded as tar archives, where installation entails extracting them to the desired location. For example, if your archives were downloaded to ~/Downloads, and you wish to install Maven and Karaf into ~/Applications:
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:
Development Environment Setup
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:
Adding Karaf related commands to PATH
To use karaf or onos command described in following sections, $KARAF_ROOT/bin needs be added to the PATH environment variable.
By default $ONOS_ROOT/tools/dev/bash_profile expects $KARAF_ROOT 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_ROOT pointing to the correct path before including $ONOS_ROOT/tools/dev/bash_profile
Building and packaging ONOS
Build using Maven
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. ONOS developer tool-kit also includes
onos-build command and alias
ob, both of which build the entire code tree from any location.
When complete, there should be an output similar to the following:
Packaging ONOS tar.gz or zip distributions
Once the build has completed, we can use the
onos-package shell tool to produce an installable compressed tar file, which contains ONOS artifacts as well as ONOS-branded distribution of Apache Karaf. If your development machine has the zip command available, the
onos-package tool will also produce a ZIP file variant with the same contents as the tar file. As with
onos-build, onos-package also has an alias called
op. The following shows what one should expect to see when running
Running ONOS locally on development machine
This section describes both launching ONOS on the build machine locally, which can be useful when developing functionality that does not require an ONOS cluster. To allow running ONOS directly on the development machine, ONOS toolbox comes with
onos-karaf command, and corresponding
ok alias, which makes sure that Apache Karaf is installed and properly configured to run ONOS before starting it.
Note: This tool is purposefully designed for development machines and is not intended to be used for production environments. It accepts the same arguments as does the original karaf command.
Selecting IP address
For the time-being, in order to run ONOS locally, we have to export
ONOS_NIC environment variables with the IP address prefix to configure ONOS clustering component. This requirement will disappear before the Cardinal release however. For example:
Selecting ONOS apps to activate
To configure ONOS with a set of applications that should be automatically activated on startup, use the ONOS_APPS environment variable as follows:
To pre-stage applications and appropriately configure ONOS, use the
onos-karaf tool using the same arguments as would normally be used for the stock
At this point, typing
help onos at the prompt should still bring up a list of available commands. Pressing Ctrl-D or
logout will exit the CLI.
Deploying ONOS remotely using ONOS test tools
This section describes how to deploy and run ONOS using the various developer and test tools, specifically
onos-install available in the ONOS source tree.
Remote installations are useful when one wishes to run ONOS on a remote machine (or a VM), or 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. These bundles can be deployed in any OSGi container, 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 down to two steps:
onos-packagepackages the ONOS binaries into a distributable compressed tar. Then,
onos-installpushes the package created by
onos-packageonto the remote VM and ignites the ONOS service.
Some preparations are needed for using these scripts:
On the build machine:
- The Apache Karaf binaries (either .zip or .tar.gz format) are available in ~/Downloads
- The ONOS source has been built
The ONOS_APPS variable should be set to the list of ONOS apps that should be auto-ignited:
On the target VM:
- The Oracle Java 8 JRE and Maven are installed
A user named sdn with password-less
sudoprivilege, or, on the build machine, the ONOS_USER environment variable is set to the preferred user for the VM.
To enable sudo without a password, edit the sudoers configuration. To do this, run
sudo visudowithin the VM, and add the following line:
onos-install relies on
ssh to deploy the package to the target machine. To make the process easier, password-less (e.g. key-based) login to the VM is recommended. The onos-push-keys utility can be used to transfer one's public keys to the VM:
This requires that the keys have been generated prior to using the utility. As shown above, it will ask for the password twice.
to produce a self-contained tar archive:
As seen above, the file has the naming convention "onos-1.2.0.<username>.tar.gz", and is created under the /tmp directory.
Deploy the binary by pointing
onos-installto the remote target to run ONOS on (192.168.56.20 in this example):If ONOS has been previously installed on a remote machine,
onos-install -f [target]will force a reinstall.
Once ONOS is running, the
onos utility can be used to attach to the remote instance's CLI:
Alternatively, pointing a browser at
http://<onos-ip>:8181/onos/ui will display the ONOS Web GUI.
Handling multiple remote targets
For deploying ONOS on multiple remote machines (i.e., as a cluster), the behavior of the ONOS utilities can be configured by employing test cells. Test cells are discussed under Test Environment Setup in the Developer's Guide.
Deploying ONOS using only the onos.tar.gz file
For deployers who just want to install ONOS software from the distributable onos.tar.gz file, without checking out the ONOS source code, they can follow these simple steps to get ONOS up and running.
First, untar the
onos.tar.gz via the following command
After that change to the newly created directory and configure the network interface that ONOS should use for clustering using the onos-config tool, for example:
Note: If you are installing on multiple machines which you intend to cluster, make sure you use the same command to configure them.
At this point, you are ready to run the ONOS as a standalone instance. To do that, you can use the
onos-service tool as follows.
Alternatively, you can integrate the
onos-service into your Linux init daemon of choice. Note that
etc/onos.conf can be copied to the system
/etc/init directory to use the Linux upstart deamon.
Forming an ONOS cluster from individual ONOS instances
If you wish to form a cluster from individually installed ONOS instances, use the
onos-form-cluster tool with the IP addresses of all the ONOS instances, as in the following example:
This tool generates a cluster configuration and uploads it to all the ONOS instances via ONOS REST API. Note that this request will trigger all ONOS instances to restart. When they finish the restart process, they will all be part of the same cluster.
Attaching ONOS console
To attach a console to the local instance, you can use the
bin/onos tool or you can remotely ssh on port 8181 as in the following example:
To setup password-less login via SSH keys, please follow documentation on Apache Karaf 3.0.3 web pages.
If Things go Wrong
Maven and Karaf
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.
Karaf System Console
ONOS by default activates the
webconsole feature of Apache Karaf, so you can point your browser at
http://<onos-ip>:8181/system/console to trouble-shoot features, bundles and component dependencies.
Running in a VM
Make sure that the primary user in the VM (sdn) has superuser privilege, or is part of sudoers.
Also be sure that there is a .m2 directory in the user's home directory. Running Maven at least once in the VM will generate the directory.