Nexus Repository Manager : What is it & how to configure it on a Digital Ocean Droplet?

In case you are engaged on an enormous challenge which might take very long time, repository supervisor is the factor which might prevent plenty of effort and time.

As an instance you’re constructing a Java-Maven utility. It makes use of Maven Central Repository for resolving dependencies. Now if you wish to use a bundle not supplied by Java by default, you might want to get it from Maven Central. With repository managers, these packages are saved within the repository supervisor itself so you do not have to search for completely different packages at completely different locations.

A Repository supervisor is a devoted server location which is used to handle all of the repositories an growth crew will want all through the event cycle.

We are able to think about Repository Supervisor as a Warehouse for components. Simply as a Warehouse serves as a centralized location for storage of components and manages receiving, sending and all the pieces in between, a Repository Supervisor manages all of the components concerned within the software program growth course of.



Repository v/s Repository Supervisor

A Repository is a storage location the place parts like artifacts, binaries or containers are retrieved to allow them to be put in or used whereas a **Repository Supervisor **is a devoted utility which manages your entire inner or proxy repositories.



Why do you want it? πŸ€”

As an instance you’re employed in an organization which is working upon a number of initiatives. Few of that are construct utilizing Java, .NET and Python. Every of those will produce several types of artifacts. Now you may want completely different software program to retailer every of them. A Repository supervisor solves this drawback and gives a centralized platform to retailer all of the parts concerned within the software program growth course of. Few of the opposite options of a repository supervisor are :

πŸ‘‰ Saving time and bandwidth as a consequence of decreased variety of downloads off distant repositories.

πŸ‘‰ Backup and Restore

πŸ‘‰ Cleanup Insurance policies

πŸ‘‰ Search Performance

πŸ‘‰ Multi-format help



Nexus Repository Supervisor is a FREE-to-use artifact repository supervisor by Sonatype. It helps all kinds of codecs like APT, NuGET, Maven and Docker. Listing of all supported codecs might be discovered here.

Now that you understand what Nexus Repository Supervisor is, let me present you find out how to configure it on a cloud server. We’ll configure Nexus on Digital Ocean Droplet(cloud server) for this weblog however you are able to do the identical on virtually another cloud service. Click on here to get a FREE $100 credit score on Digital Ocean for 60 days.




STEP 1 : Create a Droplet (cloud server)

I’ve chosen Ubuntu 20.04 LTS however you’re free to make use of distribution of your alternative. You possibly can select the datacenter area which is nearest to your location. In my case it is Bangalore. You should use Password Authentication(much less safe) or SSH keys(safer) for authentication.

Notice : Ensure you select 8 GB/ 4 vCPUs droplet as a result of Nexus takes up a ton of reminiscence and has excessive CPU utilization at occasions.

Image description




STEP 2 : Log in to the droplet utilizing it is public IP handle

When you used SSH key Authentication, you will not be prompted for password however in the event you used Password Authentication, you might want to enter your password to authenticate your self.

Notice : The default consumer for any digital ocean droplet is root.

ssh root@<IP_address>

Enter fullscreen mode

Exit fullscreen mode

Image description




STEP 3 : Set up Java model 8 and networking instruments.

Nexus repository supervisor requires Java model 8 to be put in to run.

We’ll use netstat utility to verify which port our utility is listening to for which we’d like net-tools bundle to be put in.

To put in Java model 8 and net-tools use the command :

apt set up openjdk-8-jre-headless -y
apt set up net-tools
Enter fullscreen mode

Exit fullscreen mode

To verify if Java is correctly put in, use the command :

java -version
Enter fullscreen mode

Exit fullscreen mode

The above command should give the output :

openjdk model "1.8.0_312"
OpenJDK Runtime Atmosphere (construct 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (construct 25.312-b07, combined mode)
Enter fullscreen mode

Exit fullscreen mode




STEP 4: Obtain Nexus Repository Supervisor and untar it.

To obtain Nexus Repository supervisor in /decide use command :

cd /decide
wget https://obtain.sonatype.com/nexus/3/nexus-3.38.1-01-unix.tar.gz
Enter fullscreen mode

Exit fullscreen mode

To untar it, use the command :

tar -zxvf nexus-3.38.1-01-unix.tar.gz
Enter fullscreen mode

Exit fullscreen mode

After executing the above instructions, when executing the command ls(record recordsdata and directories) , it will need to have 2 new directories specifically nexus-3.38.1-01 and sonatype-work.

root@ubuntu-s-4vcpu-8gb-intel-blr1-01:/decide# ls
digitalocean  nexus-3.38.1-01  nexus-3.38.1-01-unix.tar.gz  sonatype-work
Enter fullscreen mode

Exit fullscreen mode




STEP 5: Create a brand new consumer nexus, give it acceptable permissions and alter nexus configuration to run as a nexus consumer.

Notice : Companies ought to not run with Root consumer permissions.

Greatest Follow : Create a brand new consumer for every service.

To create a brand new consumer nexus, use the command :

adduser nexus
Enter fullscreen mode

Exit fullscreen mode

It should ask for consumer info and password. To skip filling some values, press Enter key.

root@ubuntu-s-4vcpu-8gb-intel-blr1-01:~# adduser nexus
Including consumer `nexus' ...
Including new group `nexus' (1000) ...
Including new consumer `nexus' (1000) with group `nexus' ...
Creating dwelling listing `/dwelling/nexus' ...
Copying recordsdata from `/and so forth/skel' ...
New password:
Retype new password:
passwd: password up to date efficiently
Altering the consumer info for nexus
Enter the brand new worth, or press ENTER for the default
        Full Identify []: Nexus
        Room Quantity []:
        Work Cellphone []:
        Dwelling Cellphone []:
        Different []:
Is the knowledge appropriate? [Y/n] Y
Enter fullscreen mode

Exit fullscreen mode

Change the possession of directories nexus-3.38.1-01 and sonatype-work from root to nexus. To take action, use the command :

cd /decide
chown -R nexus:nexus nexus-3.38.1-01/
chown -R nexus:nexus sonatype-work/
Enter fullscreen mode

Exit fullscreen mode

To verify if the possession was modified, use the command :

ls -l
Enter fullscreen mode

Exit fullscreen mode

It should output :

drwxr-xr-x  4 root  root  4096 Apr  3 05:51 digitalocean
drwxr-xr-x 10 nexus nexus 4096 Apr  3 17:26 nexus-3.38.1-01
drwxr-xr-x  3 nexus nexus 4096 Apr  3 17:26 sonatype-work
Enter fullscreen mode

Exit fullscreen mode

To vary nexus configuration to run as a nexus consumer, open the file nexus.rc utilizing :

vim nexus-3.38.1-01/bin/nexus.rc
Enter fullscreen mode

Exit fullscreen mode

Exchange it is contents with :

run_as_user="nexus"
Enter fullscreen mode

Exit fullscreen mode




STEP 6: Login as nexus and begin nexus service

To modify consumer from root to nexus, use the command su - <user_name>.

su - nexus
Enter fullscreen mode

Exit fullscreen mode

Now, to start out nexus, use the command :

/decide/nexus-3.38.1-01/bin/nexus begin
Enter fullscreen mode

Exit fullscreen mode

It should give the output :

nexus@ubuntu-s-4vcpu-8gb-intel-blr1-01:~$ /decide/nexus-3.38.1-01/bin/nexus begin
Beginning nexus
Enter fullscreen mode

Exit fullscreen mode

To verify if it began efficiently or not, kind :

ps aux | grep nexus
Enter fullscreen mode

Exit fullscreen mode

It should give the output :

nexus@ubuntu-s-4vcpu-8gb-intel-blr1-01:~$ ps aux | grep nexus
root       20134  0.0  0.0  10132  3868 pts/0    S    19:08   0:00 su - nexus
nexus      20137  0.0  0.0  10028  5092 pts/0    S    19:08   0:00 -bash
nexus      20353  170 24.3 6618988 1986448 pts/0 Sl   19:10   3:13 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/java-8-openjdk-amd64/jre -Dexe4j.moduleName=/decide/nexus-3.38.1-01/bin/nexus -XX:+UnlockDiagnosticVMOptions -Dinstall4j.launcherId=245 -Dinstall4j.swt=false -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=../sonatype-work/nexus3/log/jvm.log -XX:-OmitStackTraceInFastThrow -Djava.internet.preferIPv4Stack=true -Dkaraf.dwelling=. -Dkaraf.base=. -Dkaraf.and so forth=and so forth/karaf -Djava.util.logging.config.file=and so forth/karaf/java.util.logging.properties -Dkaraf.information=../sonatype-work/nexus3 -Dkaraf.log=../sonatype-work/nexus3/log -Djava.io.tmpdir=../sonatype-work/nexus3/tmp -Dkaraf.startLocalConsole=false -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=lib/endorsed -Di4j.vpt=true -classpath /decide/nexus-3.38.1-01/.install4j/i4jruntime.jar:/decide/nexus-3.38.1-01/lib/boot/nexus-main.jar:/decide/nexus-3.38.1-01/lib/boot/activation-1.1.1.jar:/decide/nexus-3.38.1-01/lib/boot/jakarta.xml.bind-api-2.3.3.jar:/decide/nexus-3.38.1-01/lib/boot/jaxb-runtime-2.3.3.jar:/decide/nexus-3.38.1-01/lib/boot/txw2-2.3.3.jar:/decide/nexus-3.38.1-01/lib/boot/istack-commons-runtime-3.0.10.jar:/decide/nexus-3.38.1-01/lib/boot/org.apache.karaf.main-4.3.6.jar:/decide/nexus-3.38.1-01/lib/boot/osgi.core-7.0.0.jar:/decide/nexus-3.38.1-01/lib/boot/org.apache.karaf.specs.activator-4.3.6.jar:/decide/nexus-3.38.1-01/lib/boot/org.apache.karaf.diagnostic.boot-4.3.6.jar:/decide/nexus-3.38.1-01/lib/boot/org.apache.karaf.jaas.boot-4.3.6.jar com.install4j.runtime.launcher.UnixLauncher begin 9d17dc87 0 0 org.sonatype.nexus.karaf.NexusMain
nexus      20778  0.0  0.0  10616  3300 pts/0    R+   19:12   0:00 ps aux
nexus      20779  0.0  0.0   8160   732 pts/0    S+   19:12   0:00 grep --color=auto nexus
Enter fullscreen mode

Exit fullscreen mode

In my case the method with course of ID 20353. By default it’s accessible on the port 8081. We are able to verify it utilizing the command :

netstat -lpnt
Enter fullscreen mode

Exit fullscreen mode

It might give the output :

nexus@ubuntu-s-4vcpu-8gb-intel-blr1-01:~$ netstat -lpnt
(Not all processes might be recognized, non-owned course of information
 won't be proven, you would need to be root to see all of it.)
Lively Web connections (solely servers)
Proto Recv-Q Ship-Q Native Deal with           International Deal with         State       PID/Program identify
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      20353/java
tcp        0      0 127.0.0.1:44945         0.0.0.0:*               LISTEN      20353/java
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
Enter fullscreen mode

Exit fullscreen mode

We are able to verify from the above output that 20353/java(nexus service) is accessible at port 8081.

If it does not present up in your case, give it a while(atleast 5 min) earlier than restarting
the service.


We are able to entry Nexus from Browser however for that we have to configure the firewall of our droplet to permit incoming requests to port 8081.

To take action,

πŸ‘‰ Click on on the droplet

πŸ‘‰ Open Networking part

πŸ‘‰ Scroll all the way down to the underside and click on on Edit button below Firewall

πŸ‘‰ Click on on Create Firewall

πŸ‘‰ Identify the Firewall rule

πŸ‘‰ Below inbound guidelines(guidelines for incoming requests), create a brand new Customized rule. Let the protocol be TCP and alter the port to 8081. Take away All IPv4 and All IPv6 from sources and put your Public IP handle in that subject as a result of you don’t need your nexus service to be accessible to anybody.

You will get your Public IP handle from the URL :

https://ifconfig.me/
Enter fullscreen mode

Exit fullscreen mode

firewall.gif

Now to entry it out of your browser, open up your browser and within the handle bar kind:

<Droplet's_IPv4>:8081
Enter fullscreen mode

Exit fullscreen mode

for instance it is 143.110.189.99:8081 in my case the place 143.110.189.99 is my Droplet’s IPv4 and 8081 is the port quantity.

nexusinbrowser.gif

CongratulationsπŸ₯³! You are all set to make use of Nexus in your Browser🀩.


When you learnt one thing new from this weblog, be sure you give it a like, share and observe me on the platform. Additionally, be happy to attach with me on Twitter. Thanks for studying!πŸ“ƒ



Add a Comment

Your email address will not be published. Required fields are marked *