Nexus is a Sonatype Artifactory repository manager [OSS]. It allows you to store, distribute, and retrieve build artifacts whenever it’s required. Using Nexus, developers can easily access and deploy build artifacts in an organization from a single location. What’s more, they can be easily distributed.
It is mostly used for hosting Apache Maven, and currently supports formats like Docker, Maven, npm, NuGet, Ruby Gems, Yum proxy/host, Apt*, R*, Raw, P2* and more.
Nexus is available in Nexus OSS and Nexus Pro versions. Nexus Pro has features like LDAP, Auth tokens, Runtime storage expansion/migration, Advanced repository health check, custom component metadata and deploy to npm and docker groups.
In my blog today, I’m going to walk you through what Nexus is made up of.
First, let’s take a look at the directory structure of Nexus.
bin: It contains Nexus startup script and related configuration files.
etc: It contains all the configuration files.
lib: It contains binary libraries.
Public: It contains public resources of the application.
System: it contains all the components and plugins.
The default location of data directory is ../Sona type-work/nexus3. It includes subdirectories that contain all the components, repositories, configurations, and other data of the repository manager.
The subdirectories are:
It is the default location of the blob store, provide a fully qualified path when creating a new blob store, it may not end up in this directory.
It contains information on currently cached Karaf bundles [Karaf can be used as a standalone container supporting wide range of applications and technologies].
It contains the orient db databases which are the primary storage for our repository manager’s metadata.
It contains the currently configured state of Elasticsearch [Elasticsearch allows us to store, search and analyze huge volumes of data quickly].
It contains cached reports from the repository health check feature.
It contains the automatically generated key used to identify our repository manager.
It contains several log files information regarding various running repository manager.log files found in this directory include:
It can be used for temporary storage.
Nexus provides for the three different kinds of repositories:
A repository that is linked to a remote repository, Nexus configured with the Apache snapshots and central proxy repositories. Any request for a component is verified against the local content of the proxy repository, if a local component is not found the request is forwarded to the remote repository.
It is hosted by the repository manager and configured with the third party, releases, and snapshots.
It has its own access point and a combined repository of locally published and remotely cached components.
Now that you are familiar with what Nexus can provide, allow me to explain the benefits of Nexus.
Allow me to explain further with the help of two interesting case studies.
docker build -t <Docker file path>
docker login <nexus repo url path>
docker tag <image Id or image Name> <nexus-hostname>:<repository-port>/<image>:<tag>
docker push <nexus-hostname>:<repository-port>/<image>:<tag>
Login as a root user.
sudo su - cd /opt yum install tar wget -y wget http://download.sonatype.com/nexus/3/nexus-3.15.2-01-unix.tar.gz tar -zxvf nexus-3.15.2-01-unix.tar.gz mv /opt/nexus-3.15.2-01 /opt/nexus
Create a Nexus user.
useradd nexus
Give the sudo access to Nexus user.
$ visudo nexus ALL=(ALL) NOPASSWD: ALL
Change ownerships and permissions.
chown -R nexus:nexus /opt/nexus chown -R nexus:nexus /opt/sonatype-work chmod -R 775 /opt/nexus chmod -R 775 /opt/sonatype-work
Open /opt/nexus/bin/nexus.rc file and uncomment run_as_user parameter and set as nexus user.
vi /opt/nexus/bin/nexus.rc run_as_user="nexus"
Create Nexus as a service.
ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
Switch to Nexus user.
su - nexus
Enable and start Nexus.
sudo systemctl enable nexus sudo systemctl start nexus
I hope my blog has acquainted you with the workings of Nexus! Reach out to us with your feedback about this blog and visit us at Nitor Infotech to learn more about us.
Subscribe to our fortnightly newsletter!