Nexus OSS3 Installation and Basic Configuration - chaitanyavangalapudi/devops-scripts GitHub Wiki

In this article we will discuss on Installing and Configuring Nexus OSS3 on RHEL/CentOS 7.

System requirements:

As per official nexus documentation for Nexus System Requirements

CPU

NXRM performance is primarily bounded by IO (disk and network) rather than CPU. So any reasonably modern 4 core (or better) CPU will generally be sufficient for normal uses of NXRM.

Memory

The default JRE min and max heap size of NXRM3 is pre-configured to be 1200MB, which should be considered an absolute minimum. The codebase will consume approximately another 1GB. So factoring in operating system overhead you will need at least 4GB of RAM on a dedicated NXRM host, assuming no other large applications are running on the machine.

Based on Instance Sizing Profiles, number of repositories and size, we need to select the Physical RAM required on the Nexus Host machine. In our case, let us take the large, enterprise profile which has

repositories > 50
total blobstore size > 200GB
diverse set of repository formats

and requires

16GB+ Physical RAM

Based on this Maximum Memory Configuration for Nexus is

-Xms4G
-Xmx4G
-XX:MaxDirectMemorySize=6717M

Disk Space

It's best to plan for a lot though, formats like Docker and Maven can use very large amounts of storage (500Gb easily).

Installation Steps:

Login as root to your Nexus host and perform below actions in order.

Step #1 Add nexus user on your Nexus Host

useradd -m -s /bin/bash nexus

Step #2 Install required Utilities and Java

yum clean all 
yum -y install sudo vim wget net-tools java-1.8.0-openjdk.x86_64

Step #3 Download and Install Nexus

Let us install Nexus in /opt directory. The installation doesn't involve running any yum commands. We just need to untar the binary downloaded from Nexus binary repository website.

  • cd /opt

  • wget nexus archive

wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.15.2-01-unix.tar.gz
OR
wget http://download.sonatype.com/nexus/3/latest-unix.tar.gz
  • Untar the nexus contents to /opt
tar -xvf nexus-3.15.2-01-unix.tar.gz –C /opt

Step #4 Create soft-links for convenience and make nexus user the owner for all Nexus related directories

ln -s /opt/nexus-3.15.2-01 /opt/nexus
ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
chown -R nexus:nexus /opt/nexus
chown -R nexus:nexus /etc/init.d/nexus
chown -R nexus:nexus /opt/sonatype-work

Step #5 Configure limits.conf for nexus user as specified in the System requirements

On most Linux systems, persistent limits can be set for a particular user by editing the /etc/security/limits.conf file. To set the maximum number of open files for both soft and hard limits for the nexus user to 65536, add the following line to the /etc/security/limits.conf file, where "nexus" should be replaced with the user ID that is being used to run the repository manager:

nexus - nofile 65536

This change will only take effect the next time the nexus process user opens a new session. Which essentially means that you will need to restart NXRM. On Ubuntu systems there is a caveat: Ubuntu ignores the /etc/security/limits.conf file for processes started by init.d.

Step #6 Configure nexus rc file to run Nexus process as nexus user

cat /opt/nexus/bin/nexus.rc
run_as_user="nexus"

Step #7 Configure Nexus VM Options

Edit -Xms, -Xmx, --XX:MaxDirectMemorySize properties based on your Memory (Physical RAM) based on the chart discussed above in System Requirements Section by Editing /opt/nexus/bin/nexus.vmoptions

-Xms4G
-Xmx4G
-XX:MaxDirectMemorySize=6717M

-XX:+UnlockDiagnosticVMOptions 
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
 
-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 
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp 
-Dkaraf.startLocalConsole=false

Step #8 Running Nexus as a service

Edit /opt/nexus/nexus/conf/nexus.properties file and change the nexus context path

nexus-webapp-context-path=/nexus

Start Nexus process using below commands.

chkconfig --add nexus
chkconfig --levels 345 nexus on
systemctl enable nexus
service nexus start

By default Nexus runs on port 8081, with

User Name: admin
Password: admin123

Step #9 Optional - Change the port of Nexus Process

$data-dir/etc/nexus.properties is created the first time Nexus is started. You can copy the nexus-default.properties to $data-dir/etc/nexus.properties and customize before having to start Nexus the first time.

cd /opt/sonatype-work/nexus3/etc/
cp nexus-default.properties nexus.properties

Edit nexus.properties and add below properties. If you want the port to be something different other than 8081, you can edit here

application-port=8081
nexus-context-path=/nexus

After this restart nexus process by

systemctl restart nexus

Step #10 Add fire-wall rules

If fire-wall process is running on your Nexus host, enable port 8081 by running

firewall-cmd --zone=public --permanent --add-port=8081/tcp
firewall-cmd --reload

You can access nexus at http://nexus-ip:8081/

References:


We are not going to use Nexus Repository Pro and IQ Server. These two are out of scope for this discussion.

Nexus IQ Server:

Nexus repository pro:

Nexus P2 Repositories: