By Furkan
5 minute read

Installing Standalone Nexus Repository

Nexus Repository Manager is a tool for managing and distributing software components from a central location. This guide will walk you through the steps to install and configure a standalone Nexus Repository

Installation Requirements

  • CPU and RAM: Requires at least 4 CPUs and 8GB (6GB for pro with external db) of memory
  • Supported CPU Architectures: Intel 64-bit (x86_64), AMD 64-bit (x86_64), Arm 64-bit (aarch64)
  • Database: Orientdb (NoSQL – Built-in), PostgreSQL (for pro) and H2 (for pro)
  • Disk: The recommended starting is 500GB of storage
  • Operating Systems: Linux (commonly available distros)
  • Connections:
    • Outbound
      • 443 TCP to https://clm.sonatype.com : Secure access to Sonatype Data Services.
    • Inbound
      • 8070 TCP: Main HTTP access port used by all clients.
      • 8071 TCP: HTTP access for monitoring tools for monitoring and operational functions.
  • Internet Protocols supported: IPv4, IPv6
  • Supported Java Versions: OpenJDK 8 and 11 are supported in release 63 and later

See more help.sonatype.com/en/system-requirements.html

Nexus Basic Directories

When managing a Nexus Repository Manager installation, it’s crucial to understand the key directories involved.

 ./nexus
 ├── nexus-2.6.4-02/
 ├── nexus-professional-2.14.1-01/
 ├── nexus-3.1.0-04/
 ├── nexus-3.2.0-01/
 └── sonatype-work/
     ├── nexus/
     └── nexus3/

These examples show how different versions of the repository manager might appear when unpacked over time

Installation Directory

./nexus
 ├── nexus-2.6.4-02/
 ├── nexus-professional-2.14.1-01/
 ├── nexus-3.1.0-04/
 ├── nexus-3.2.0-01/
 └── sonatype-work/
     ├── nexus/
     └── nexus3/

This directory serves as the central location for all files associated with the Sonatype Nexus Repository Manager. Created manually by you in a location of your choice, it will house both the Application Directory and Data Directory. It acts as the primary operating system path for managing all Nexus Repository Manager files.

Application Directory

 ./nexus
 ├── nexus-2.6.4-02/
 ├── nexus-professional-2.14.1-01/
 ├── nexus-3.1.0-04/
 ├── nexus-3.2.0-01/
 └── sonatype-work/
     ├── nexus/
     └── nexus3/

As a subdirectory of the Installation Directory, this folder holds the runtime application binary files specific to each version of Nexus. It includes essential components such as the Eclipse Jetty Server, Nexus core libraries, and control scripts. The name of this directory follows a pattern depending on the distribution used:

Nexus 2.x OSS Edition: nexus-<version>
Nexus 2.x Professional Edition: nexus-professional-<version>
Nexus 3.x OSS or Pro Edition: nexus-<version>

Data Directory (Work Directory)

 ./nexus
 ├── nexus-2.6.4-02/
 ├── nexus-professional-2.14.1-01/
 ├── nexus-3.1.0-04/
 ├── nexus-3.2.0-01/
 └── sonatype-work/
     ├── nexus/
     └── nexus3/

This is the main directory for storing Nexus configuration files, as well as component and artifact-related data specific to your runtime environment. The default location of this directory varies depending on the installer archive that was extracted.

Nexus 2.x: under the Installation Directory as sonatype-work/nexus
Nexus 3.x: under the Installation Directory as sonatype-work/nexus3

Nexus 3 installation

In these examples,

  • installation path: /opt/nexus/
  • version: 3.70.0-02
  • os: ubuntu 22.04
  • Java Version : openjdk 11.0.23

Execute the following command to install the JRE from OpenJDK 11:

apt install default-jre

Java version we completed the installation

furkan@nexusprod:~$ java --version
openjdk 11.0.23 2024-04-16
OpenJDK Runtime Environment (build 11.0.23+9-post-Ubuntu-1ubuntu122.04.1)
OpenJDK 64-Bit Server VM (build 11.0.23+9-post-Ubuntu-1ubuntu122.04.1, mixed mode, sharing)

Create a user group called nexus

sudo groupadd nexus

Create a new system user called nexus

sudo useradd -r -g nexus -m nexus

Create and authorize the main nexus folder

sudo mkdir -p /opt/nexus
sudo chown nexus:nexus /opt/nexus

Switch to Nexus user and go to the home folder

su nexus
cd /opt/nexus

Download Archives

wget https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.70.1-02-java11-unix.tar.gz

tar -xzvf nexus-3.70.1-02-java11-unix.tar.gz

see more help.sonatype.com/en/download-archives—repository-manager-3.html

Run as a service

We can configure the Nexus repository manager to run as a service with init.d or systemd. In this case, we will configure it as a systemd service. Define nexus user you created in the bin/nexus.rc .

/opt/nexus/nexus-3.70.1-02/bin/nexus.rc

run_as_user="nexus"

Systemd

We will create a script to run the repository manager service using systemd. We are creating a nexus.service file in the /etc/systemd/system/ directory with the following command:

sudo cat > /etc/systemd/system/nexus.service <<EOF
[Unit]
Description=nexus service
After=network.target
  
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/nexus-3.70.1-02/bin/nexus start
ExecStop=/opt/nexus/nexus-3.70.1-02/bin/nexus stop
User=nexus
Restart=on-abort
TimeoutSec=600
  
[Install]
WantedBy=multi-user.target
EOF

Make sure systemd reloads services files

systemctl daemon-reload

enable and start nexus service

systemctl enable nexus
systemctl start nexus

see more help.sonatype.com/en/run-as-a-service.html

Logging

General Logging

The repository manager records events in the /opt/nexus/sonatype-work/nexus3/logs/nexus.log file. Additionally, a specialized user interface is available for configuring and reviewing the log.

Audit Log

Audit events are not included in the main application log. Instead, they are stored separately at /opt/nexus/sonatype-work/nexus3/log/audit/. The most recent audit log file is named audit.log, while older logs are archived and compressed with the naming convention audit-yyyy-MM-dd.log.gz.

Audit logging operates exclusively at the INFO level. Consequently, adjusting the audit logger to ALL, TRACE, or DEBUG will not impact the logging behavior, and setting it to WARN, ERROR, or OFF will disable audit logging.

Request Log

The last active request log is found at /opt/nexus/sonatype-work/nexus3/log/request.log and archived logs are compressed with the name pattern of request-yyyy-MM-dd.log.gz.

see more help.sonatype.com/en/logging-configuration.html

InstallationnexusNexus Repository Managerreporepository
Leave a Reply