Nexus Installation

  1. Prerequisites
  2. Installation
  3. Network configuration

Prerequisites

  1. EC2 Instance (over t2.medium)
    • With Internet Access
    • Security Group with Port 8081 open for internet
    • System requirement
      • CPU: Nexus Repository Manager performance is primarily bounded by IO (disk and network) rather than CPU.  So any reasonably modern 2-4 core CPU will generally be sufficient for normal use.
      • Memory: The default JRE max heap size of Nexus Professional is 768Mb, and the codebase of Nexus Repository Manager will consume approximately another 1GB.  So factoring in operating system overhead you will need at least 4GB of RAM, assuming no other large applications are running on the machine.

Installation

Download & Setup Stable version of Nexus

Move to the folder for installing the Nexus

$ cd /opt

Change the folder name and install

$ sudo yum update -y
$ sudo yum install wget -y
$ sudo wget sudo wget -O nexus.tar.gz https://download.sonatype.com/nexus/3/latest-unix.tar.gz
$ sudo tar -xvf nexus.tar.gz
$ sudo mv /opt/nexus-3* /opt/nexus

To execute nexus, you need Java

## Install openjdk 1.8
$ sudo yum install java-1.8.0-openjdk.x86_64 -y

For security reason, root user is not recommanded nexus-service. Add a Nexus user.

$ sudo su -
$ useradd nexus
$ passwd nexus
Changing password for user nexusadmin
New password:
Retype new password: 
passwd: all authentication tokens updated successfully.
$ sudo chown -R nexus:nexus /opt/nexus
$ sudo chown -R nexus:nexus /opt/sonatype-work

Grant sudo Access to nexus user

$ visudo

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
nexus ALL=(ALL) NOPASSWD: ALL

Add run as user

$ vi /opt/nexus/bin/nexus.rc
run_as_user="nexus" (file shold have only this line)

Add nexus as a service at boot time

$ sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus

systemd

This example is a script that uses systemd to run the repository manager service. Create a file called nexus.service. Add the following contents, then save the file in the  /etc/systemd/system/ directory:

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

https://help.sonatype.com/repomanager3/installation/run-as-a-service#RunasaService-PIDFile

Activate the service with the following commands:

$ su - nexus
$ sudo systemctl daemon-reload
$ sudo systemctl enable nexus.service
$ sudo systemctl start nexus.service
$ sudo systemctl status nexus.service
● nexus.service - nexus service
   Loaded: loaded (/etc/systemd/system/nexus.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-09-21 08:17:59 UTC; 5s ago
  Process: 3938 ExecStart=/opt/nexus/bin/nexus start (code=exited, status=0/SUCCESS)
 Main PID: 4137 (java)
   CGroup: /system.slice/nexus.service
           └─4137 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.amzn2.0.1.x...

or

$ sudo service nexus start

Login nexus server from browser on port 8081

$ cat /opt/sonatype-work/nexus3/admin.password

Network Configuration

By default, the repository manager listens on port 8081. You can change this port, by changing the value in the $NEXUS_HOME/conf/nexus.properties file shown in Contents of conf/nexus.properties . To change the port, stop the repository manager, change the value of application-port in this file, and then restart it. Once you do this, you should see a log statement in $NEXUS_HOME/logs/wrapper.log telling you that the repository manager is listening on the altered port.

# Sonatype Nexus
# ==============
# This is the most basic configuration of Nexus.

# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

https://help.sonatype.com/repomanager2/configuration/network-configuration#:~:text=By%20default%2C%20the%20repository%20manager,in%20Contents%20of%20conf%2Fnexus.

Leave a Reply

Your email address will not be published.

ANOTE.DEV