Configuring Nexus Repository Pro for H2 or PostgreSQL
Only available in Nexus Repository Pro. Interested in a free trial? Start here .
If you're standing up a new instance of Nexus Repository Pro and wish to begin in a new database mode, follow these instructions:
Installing Nexus Repository Pro
- Download the latest Nexus Repository 3 version
- Expand and install the archive as with the standard installation instructions
- Follow the instructions for your chosen database
Configuring for the Embedded H2
Create the <data-dir>/etc/nexus.properties
file and add the following line:
nexus.datastore.enabled=true
You can now start your Nexus Repository instance and use an embedded H2 database.
Configuring for External PostgreSQL
To use an external PostgreSQL database, follow these additional instructions:
- Create a database in a PostgreSQL server.
Create the
<data-dir>/etc/nexus.properties
file. Add a property to enable external database access:
nexus.datastore.enabled=true
- Note that, by default, the repository manager will detect other nodes accessing the same database. If you wish to modify any of the default values in the
<data-dir>/etc/nexus.properties
file pertaining to this setting, you can adjust the following properties:nexus.heartbeat.enabled=true
- This enables the repository manager to detect other nodes accessing the same database.nexus.heartbeat.interval=600
- This is the time interval for detecting other nodes accessing the same database. By default, this is set to 600 seconds (10 minutes).nexus.heartbeat.history=30
- This configures the number of days to retain old records. By default, this is set to 30 days.
- Create a
<data-dir>/etc/fabric
directory. In the
<data-dir>/etc/fabric
directory, create a text file namednexus-store.properties
Below is a sample that you will need to update with the appropriate configuration.
username=<postgres_user> password=<postgres_password> jdbcUrl=jdbc\:postgresql\://<database-host>\:<database-port>/nxrm
If using AWS Aurora as your database, you will need to includegssEncMode=disable
as a query parameter of the JDBC URL.Note that you can also use the following JVM arguments to specify connection information; you can also specify these in the
sonatype-work/nexus3/etc/nexus.properties
file without the preceding-D
:-Dnexus.datastore.enabled
-Dnexus.datastore.nexus.jdbcUrl
- -Dnexus.datastore.nexus.username
- -Dnexus.datastore.nexus.password
- You can also pass the following connectivity details as environment variables:
NEXUS_DATASTORE_NEXUS_JDBCURL
NEXUS_DATASTORE_NEXUS_USERNAME
NEXUS_DATASTORE_NEXUS_PASSWORD
Nexus Repository uses system and environment variables to populate the
nexus-store.properties
file; so, configuration via these methods can only be done once. Priority order is as follows:- sonatype-work/nexus3/etc/fabric/nexus-store.properties
- System properties
- Environment variables
You can now start your Nexus Repository instance and and use a PostgreSQL database.
Extra Configuration Options for PostgreSQL
Servers under heavy load may also need to configure the connection pool size for the database. Nexus Repository uses a default pool of 100, but you may increase this by appending a line like the following example to nexus-store.properties
:
username=<postgres_user> password=<postgres_password> jdbcUrl=jdbc\:postgresql\://<database-host>\:<database-port>/<database-name> advanced=maximumPoolSize\=200
If you use a container orchestration tool, relational database service, or other infrastructure to launch Nexus Repository, you should configure your maxLifetime
for database connections.
Ensure your maxLifetime
is set to be several seconds shorter than your infrastructure-imposed connection time limit.
By default, maxLifetime
is set to 30 minutes (1800000ms), but you may change this by appending a line like the following example to your nexus-store.properties
file:
username=<postgres_user> password=<postgres_password> jdbcUrl=jdbc\:postgresql\://<database-host>\:<database-port>/<database-name> advanced=maxLifetime\=840000
How Does Nexus Repository Pro Determine Which Database To Use
If you've omitted nexus.datastore.enabled
or set it to false
, then Nexus Repository will use OrientDB.
If you've configured nexus.datastore.enabled=true
, then Nexus Repository determines which database it is meant to use based on configuration source.
Nexus Repository Pro will look for configuration information from <data-dir>/etc/fabric/
nexus-store.properties
before falling back to the embedded database, which is H2.