Skip to main content

Configuring the Runtime Environment

Configuring the specifics of the repository manager runtime involves configuration for all components in various configuration files and startup scripts. This section details these and provides recipes for specific tasks. The startup of the JVM running the repository manager is managed via files in the $install-dir/bin directory within the installation.

The application startup loads JVM arguments from the Java properties file $install-dir/bin/nexus.vmoptions:

Example nexus.vmoptions properties file content

-Xms2703m
-Xmx2703m
-XX:MaxDirectMemorySize=2703m
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Dkaraf.log=../sonatype-work/nexus3/log
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djava.endorsed.dirs=lib/endorsed

The main location for configuration files is the etc directory. It includes one properties file and a number of nested directories:

$ ls -1 nexus-<version>/etc
fabric
jetty
karaf
logback
nexus-default.properties
ssl

fabric

Configuration files for Ehcache, Elasticsearch, and OrientDB

karaf

Configuration files for Apache Karaf, including:

    • config.properties - The main configuration for the Apache Karaf runtime. This file should not be modified.

    • custom.properties - Customizable configuration used by Apache Karaf. This file can be used to pass additional parameters to the Apache Karaf container.

    • org.apache.* andorg.ops4j.*- various Karaf and OSGi related configuration files

    • system.properties- system properties used for the JVM and application start up

jetty

Configuration files for Eclipse Jetty

logback

Configuration files for logback including:

    • logback.xml - Contains default logger definitions for log file names, log levels, pattern layouts and rotation rules for the nexus.log and tasks/*.log files

    • logback-access.xml - Contains the default logger definition for the log file name, log level, pattern layout and rotation rules for the request.log file

See Logging for more information on repository manager logging and the recommended approach for adjusting the logging configuration to meet your needs.

nexus-default.properties

This file should not be modified. A sample of default property values are listed in this file such as the main HTTP connector port and the webapp context path.

Change or add new configuration properties in $data-dir/etc/nexus.properties.

The file $data-dir/etc/nexus.properties is created the first time NXRM is started. If configuration is needed before first start then manually create $data-dir/etc/nexus.properties and add customizations there.

ssl

A directory to put keystores when configuring HTTPS

Configuring Memory

Before changing the default memory settings, review our memory guidelines. Changing any one setting will require adjusting all 3 settings. The -Xms and -Xmx settings must always have the same value.

To change JVM memory

  1. Open $install-dir/bin/nexus.vmoptions in a text editor

  2. Find the lines which configure memory:

    Default memory settings

    -Xms2703M
    -Xmx2703M
    -XX:MaxDirectMemorySize=2703M
  3. Edit the values of each settting using the following format. Thesizeis a number and the literal unit letters represent gigabytes (g,G) , megabytes (m,M), or kilobytes (k,K).

    -Xmssize[g|G|m|M|k|K]

    -Xmxsize[g|G|m|M|k|K]

    -XX:MaxDirectMemorySize=size[g|G|m|M|k|K]

  4. Save the file with permission and ownership of the user that will own the repository manager process.

Configuring Java Tool Options

The file $install-dir/bin/nexus.vmoptions specifies java tool arguments, one per line, in Java properties file format.

To edit java options

  1. Open $install-dir/bin/nexus.vmoptions in a text editor

  2. Specify each java option on a new line.

    Make sure the last property is followed by an end of line character or a new blank line. Otherwise the last specified property will not be loaded.

  3. Save the file with permission and ownership of the user that will own the repository manager process.

Changing the HTTP Port

The default value for the HTTP port used to access the repository manager user interface and resources is 8081. Therefore the user interface would be available at http://localhost:8081/. To change or update the port, locate the lineapplication-port=8081 in$data-dir/etc/nexus.properties, then edit the number. Here is an example where you would change the port to9081:

application-port=9081

Therefore, the exposed URL will be http://localhost:9081/.

Or setup HTTPS

Additionally, or instead, your use case may require you to run your server on HTTPS. This includes both business policy and usage of some NXRM features or repository formats. See our security article on setting up SSL for the means to do this.

Changing the Context Path

To change or update the context path in the instance you want point to a specific webapp or component, locate the nexus-context-path=/ line in the $data-dir/etc/nexus.properties. Here is an example where you expose the user interface to a components directory.

nexus-context-path=/components/

Therefore, if the port is set to 9081, the exposed URL will be http://localhost:9081/components/.

Configuring the Data Directory

You can use $install-dir/bin/nexus.vmoptions to define a new location for data you want to preserve. In the configuration file change the values of -Dkaraf.data, -Djava.io.tmpdir, -Dkaraf.log and -XX:LogFile to designate an absolute path you prefer to use. The nexus service will look to add the data directory to the absolute path that you configure. For example, to use the absolute path/opt/sonatype-work/nexus3 change the values as follows:

-Dkaraf.data=/opt/sonatype-work/nexus3
-Djava.io.tmpdir=/opt/sonatype-work/nexus3/tmp
-XX:LogFile=/opt/sonatype-work/nexus3/log/jvm.log
-Dkaraf.log=/opt/sonatype-work/nexus3/log

Configuring the Temporary Directory

Repository manager uses the Java virtual machine temporary directory for important runtime files.

The temporary directory is set to be inside of the Nexus Repository data directory at $data-dir/tmp. The advantage is file ownership and permissions can be isolated under a single directory tree.

If you wish to change the default temporary location, keep in mind the following requirements:

  • the tmp directory requires exec permissions by the user owning the repository manager process. Do not use the noexec mount option on Linux for the location that contains the tmp directory. If noexec is set on the tmp directory, repository manager startup will fail with an java.lang.UnsatisfiedLinkError message of failed to map segment from shared object: Operation not permitted . If the repository manager docker image is being used, one may need to adjust the permissions on the host directory that's being mounted as a docker volume to allow execution.

  • do not manipulate any files put into the temp directory, especially when repository manager is running

  • make sure the disk hosting the directory has at least 1GB free space

To Change the Temporary Directory

  1. Open $install-dir/bin/nexus.vmoptions in a text editor

  2. Edit the line which contains -Djava.io.tmpdir=../sonatype-work/nexus3/tmp. The value can either be an absolute path or a path relative to the $install-dir/bin directory.

  3. Save the file with permission and ownership of the user that will own the repository manager process.