Nexus 3.70.1-02 with H2 Database - Sonatype Nexus Repository - Sonatype Community
Nexus 3.70.1-02 with H2 Database
post by sameer29nov on Mar 25, 2025
Hello there,
We want to use Nexus version 3.70.1-02 with the H2 database as the default DB. However, when we try to install it, it always starts with OrientDB.
We know that version 3.70.1-02 supports both databases, and we need to make some changes in the nexus.properties file. After trying several tweaks, we are still unsure where to add nexus.datastore.enabled=true — in nexus.properties or nexus-default.properties — so that Nexus 3.70.1-02 starts with H2 by default, not with OrientDB.
The requirement is that we can use a preconfigured nexus.properties file, ensuring that Nexus 3.70.1-02 starts with H2 as the default, not with OrientDB.
Can someone help here?
Regards,
SAM
post by laurencet on Mar 25, 2025
For a brand new deployment (no sonatype-work directory) you will have to create the path and file: /opt/<nexus directory>/sonatype-work/nexus3/etc/nexus.properties - in this file add the line 'nexus.datastore.enabled=true' and then start the application. This will start Nexus with the H2 database.
It is likely you were adding this in to nexus.properties found in the application directory such as /opt/<nexus directory>/nexus-3.70.1-02/etc which will not work.
If you have an existing deployment you would need to also run a DB migration to move the data from Orient to H2.
https://help.sonatype.com/en/migrating-to-a-new-database.html#migrating-from-orientdb-to-h2-162010
post by sameer29nov on Mar 25, 2025
Thank you for your response. Apologies if I misinterpreted your explanation; please correct me if I’m wrong. Since we are using Nexus as a container, do we need to do something like this?
- Create the directory
/opt/<nexus directory>/sonatype-work/nexus3/etc/ - Add the preconfigured
nexus.propertiesin the above path. - Then, start the Nexus services.
Regards,
SAM
post by laurencet on Mar 25, 2025
Hey Sam,
Since you’re running in a container it may be easier to just pass this as an environment variable. Depending on your method (docker run or docker compose) you could achieve this with the following:
Docker run:
-e INSTALL4J_ADD_VM_PARAMS="-Dnexus.datastore.enabled"
Docker compose:
environment:
- INSTALL4J_ADD_VM_PARAMS=-Dnexus.datastore.enabled
Hope this helps
post by sameer29nov on Mar 26, 2025
Hello @laurencet
I tried the suggestions you asked me to test:
- I added
ENV INSTALL4J_ADD_VM_PARAMS=-Dnexus.datastore.enabledin the Dockerfile. - I also added the same environment variable in the Compose file.
( Note: I didn’t create path and preconfigured nexus.properties file you mentioned in your first answer in this case )
However, in both cases, I am encountering the following errors:
2025-03-26 05:08:42,174+0100 INFO [jetty-main-1] *SYSTEM org.eclipse.jetty.server.session - DefaultSessionIdManager workerName=node0
... (error logs omitted for brevity)
It seems that Nexus is still trying to use OrientDB initially. I am using Debian Bookworm as the base image and Java 17 as the default Java version for Nexus 3.70.1-02. The goal is to start Nexus 3.70.1-02 with the H2 database for a fresh deployment.
Our intention is to test Nexus 3.70.1-02 with the H2 database, and once successful, we plan to migrate from OrientDB to H2.
Regarding the migration guide could you clarify the actual purpose of backing up the old database? Is it a precautionary step, or is it mandatory to back up the old database before starting the DB migrator?
Apologies for asking so many questions, but we want to ensure we’re on the right track and planning this activity correctly.
Your guidance will be greatly appreciated
regards,
SAM
post by laurencet on Mar 26, 2025
Hey Sam,
Have you deleted the ‘sonatype-work’ directory since your previous attempts? Once nexus has started once with Orient then it will default to that. That being said it looks like Nexus is still trying to use Orient. You shouldn’t need to add anything to the Dockerfile just to your compose file should be sufficient.
Here is an example of running Nexus 3 with docker compose which should work for H2:
services:
nexus3:
image: sonatype/nexus3:3.70.4
ports:
- "8081:8081"
environment:
- INSTALL4J_ADD_VM_PARAMS=-Xms4G -Xmx4G -XX:MaxDirectMemorySize=4G -Djava.util.prefs.userRoot=/nexus-data/javaprefs -Dnexus.licenseFile=/etc/nexus-license/license.lic
- NEXUS_DATASTORE_ENABLED=true
volumes:
- /opt/nexus/docker-volumes/docker-compose-nexus3:/nexus-data
post by laurencet on Mar 26, 2025
Apologies, forgot to address this part. The task to export the DB files is a requirement as these are used for the migration utility. As with any activity of this type, it’s always recommended to take comprehensive backups (and test them)!
post by sameer29nov on Mar 27, 2025
Yes, I am removing the old repository to start fresh.
I’m not sure, maybe I’m missing something. Even after adding NEXUS_DATASTORE_ENABLED=true, in ENV it still points to OrientDB.
But the interesting part is that I created this path: /opt/sonatype/sonatype-work/nexus3/etc/ and added my preconfigured nexus.properties.
Then, Nexus started with the H2 database for fresh deployments.
For now, this is enough for me to start my testing, and I really appreciate your support and time in addressing my query.
I will mark this as resolved, but share my observations just for tracking. Thank you once again!!!