Categories
DevOps

How to install Nexus Repository Manager 3

Install Nexus Repository Manager (NXRM) 3.

Nexus Repository Manager (NXRM) 3

Prerequisites

Install required packages.

$ sudo apt-get install curl gnupg apt-transport-https

Install Java

Import AdoptOpenJDK GPG public key using curl.

$ curl --silent https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

Define AdoptOpenJDK repository.

$ cat <<EOF | sudo tee -a /etc/apt/sources.list.d/adoptopenjdk.list
deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ $(lsb_release  --codename --short) main
EOF

Update package index.

$ sudo apt update

Install Java 8.

$ sudo apt install adoptopenjdk-8-hotspot

Install Nexus Repository Manager 3

Import Sonatype GPG public key using curl.

$ curl --silent https://repo.sonatype.com/repository/community-hosted/pki/deb-gpg/DEB-GPG-KEY-Sonatype.asc | sudo apt-key add -

Define Sonatype community repository.

$ cat <<EOF | sudo tee -a /etc/apt/sources.list.d/sonatype-community.list
deb [arch=all] https://repo.sonatype.com/repository/community-apt-hosted/ bionic main
EOF

Update package index.

$ sudo apt update

Install Nexus Repository Manager 3.

$ sudo apt install nexus-repository-manager

Inspect service status.

$ sudo systemctl status nexus-repository-manager
● nexus-repository-manager.service - Nexus Repository Manager 3 Service
   Loaded: loaded (/opt/sonatype/nexus3/extra/daemon/nexus-repository-manager.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-10-14 22:40:26 GMT; 4s ago
  Process: 12137 ExecStart=/opt/sonatype/nexus3/bin/nexus start (code=exited, status=0/SUCCESS)
 Main PID: 12311 (java)
    Tasks: 39 (limit: 544)
   Memory: 246.3M
   CGroup: /system.slice/nexus-repository-manager.service
           └─12311 /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64 -Dexe4j.moduleName=/opt/sonaty
Oct 14 22:40:26 debian systemd[1]: Starting Nexus Repository Manager 3 Service...
Oct 14 22:40:26 debian nexus[12137]: Starting nexus
Oct 14 22:40:26 debian systemd[1]: Started Nexus Repository Manager 3 Service.

Use browser to access service on port 8081.

http://nexus.example.opg:8081/

Use initial password for admin user.

$ cat /opt/sonatype/sonatype-work/nexus3/admin.password
37e3ecea-8053-40a1-b069-7171df2e04cfvagrant@debian:/opt/sonatype$

Additional notes

JVM options are stored in nexus.vmoptions file.

$ cat /opt/sonatype/nexus3/bin/nexus.vmoptions
-Xms2703m
-Xmx2703m
-XX:MaxDirectMemorySize=2703m
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=/opt/sonatype/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=/opt/sonatype/sonatype-work/nexus3
-Dkaraf.log=/opt/sonatype/sonatype-work/nexus3/log
-Djava.io.tmpdir=/opt/sonatype/sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
#
# additional vmoptions needed for Java9+
#
# --add-reads=java.xml=java.logging
# --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED
# --patch-module=java.base=lib/endorsed/org.apache.karaf.specs.locator-4.2.9.jar
# --patch-module=java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-4.2.9.jar
# --add-opens=java.base/java.security=ALL-UNNAMED
# --add-opens=java.base/java.net=ALL-UNNAMED
# --add-opens=java.base/java.lang=ALL-UNNAMED
# --add-opens=java.base/java.util=ALL-UNNAMED
# --add-opens=java.naming/javax.naming.spi=ALL-UNNAMED
# --add-opens=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED
# --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED
# --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED
# --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED
# --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED
# --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED
#
# comment out this vmoption when using Java9+
#
-Djava.endorsed.dirs=lib/endorsed

Inspect log file in case of any trouble.

$ tail /opt/sonatype/sonatype-work/nexus3/log/jvm.log
[...]
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.491'/>
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.491'/>
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.491'/>
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.491'/>
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.492'/>
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.492'/>
<dependency_failed type='abstract_with_unique_concrete_subtype' ctxk='java/security/MessageDigest' x='java/security/MessageDigest$Delegate' witness='sun/security/ssl/CloneableDigest' stamp='53.492'/>
<writer thread='140604630718208'/>
<dependency_failed type='unique_concrete_method' ctxk='groovy/lang/Closure' x='groovy/lang/GroovyObjectSupport getMetaClass ()Lgroovy/lang/MetaClass;' witness='org/codehaus/groovy/runtime/IteratorClosureAdapter' stamp='55.552'/>

I love it!