Installing Nexus Repository Pro with a PostgreSQL Database
This topic covers installing Sonatype Nexus Repository with an external PostgreSQL database; note that using an external PostgreSQL database requires a paid Pro license.
Sonatype Nexus Repository's legacy embedded OrientDB database entered extended maintenance in August 2024. All Sonatype Nexus Repository customers are highly encouraged to migrate off of OrientDB.
Users that cannot migrate need to remain on the 3.70.x version line. Nexus Repository versions 3.71.0 and above will not support OrientDB.
New installations of Nexus Repository version 3.71.0 and above default to using an embedded H2 database.
Data Store Configuration View to Determine Current Database
Use the Data Store
view to determine the database model Nexus Repository is using.
Instances using H2 will see a reference to H2 in their JDBC URL.
Instances using PostgreSQL will not see a reference to H2 in the JDBC URL.
Best Practices
Nexus Repository supports 3 methods for providing the database configuration settings: as environment variables, as JVM arguments, or in the properties file.
When Nexus Repository starts, the first connection method encountered is used while the others are ignored. Mixing methods are not supported.
Choose the method that fits your infrastructure requirements. In containerized environments, use environment variables or JVM arguments to avoid modifying the property files in the container.
Any new configuration settings take effect on restart of the Nexus Repository service.
Installation Instructions
The following instructions are to start Nexus Repository using an external PostgreSQL database.
Before proceeding, ensure you meet the PostgreSQL requirements in the system requirements with the required trigram module installed.
Download the latest Sonatype Nexus Repository version; expand and install the archive.
Create a PostgreSQL database using the UTF8 character set for compatibility with Nexus Repository.
For more information, see the PostgreSQL documentation on setting the character set.
Modify the
<data-dir>/etc/nexus.properties
file with the following properties.nexus.licenseFile=/path/to/your/sonatype-license.lic
The license file is only needed and used for the initial run; after which the value is managed in the database.
The connection configuration is set using any of the following 3 different methods.
Pass the connectivity details as environment variables:
NEXUS_DATASTORE_NEXUS_JDBCURL NEXUS_DATASTORE_NEXUS_USERNAME NEXUS_DATASTORE_NEXUS_PASSWORD
Specify the properties as JVM arguments:
-Dnexus.datastore.enabled -Dnexus.datastore.nexus.username -Dnexus.datastore.nexus.password -Dnexus.datastore.nexus.jdbcUrl
Create the
<data-dir>/etc/fabric/nexus-store.properties
directory and file with your PostgreSQL configuration.username=<postgres_user> password=<postgres_password> jdbcUrl=jdbc\:postgresql\://<database-host>\:<database-port>/<database-name>
Colons in the JDBC URL need to be escaped with a backslash (\). For AWS Aurora databases, include the
gssEncMode=disable
query parameter in the JDBC URL
Start the Nexus Repository instance using a PostgreSQL database.
Configuration Options for PostgreSQL
Set optional configuration settings through the same methods used above. Set multiple advanced
properties in the JVM arguments by delimiting the values with "\n
".
advanced=maximumPoolSize\=200\nmaxLifetime\=840000
Maximum Pool Size
Servers under heavy load may need increased connection pool size for the database. Nexus Repository uses a default pool of 100.
Note
Note that, for high availability deployments, you must increase the number of connections that PostgreSQL allows so that your Maximum Connection Pool size does not exceed your the maximum number of allowed connections. See Prerequisite Step: Adjust max_connections.
Pass an environment variable
NEXUS_DATASTORE_NEXUS_ADVANCED="maximumPoolSize=200"
Use a JVM argument
-Dnexus.datastore.nexus.advanced=maximumPoolSize\=200
In the nexus-store.properties file
maximumPoolSize=N advanced=maximumPoolSize\=200
Only one setting from above is used. The
maximumPoolSize
takes precedence over theadvanced
Max Lifetime
Configure the max lifetime for database connections when using container orchestration tools, relational database services, or other infrastructure to launch Nexus Repository.
The default max lifetime is set to 30 minutes (1800000ms)
Set the max lifetime to be several seconds shorter than any infrastructure-imposed connection time limit.
Pass as an environment variable
NEXUS_DATASTORE_NEXUS_ADVANCED="maxLifetime=840000"
Use a JVM argument
-Dnexus.datastore.nexus.advanced=maxLifetime\=840000
In the nexus-store.properties file
advanced=maxLifetime\=840000