Support for other Data Bases other then H2 or PostGreSQL

Hi all,

Is there a plan to support other databases besides H2 or PostgreSQL? We are planning to migrate to the Pro version, but we have no DBA know-how on PostgreSQL, and it seems our current H2 database isn’t sufficient to handle our volume. Support for Oracle or MS SQL would be great.

If you guys are willing to give PostgreSQL a shot, it may be worth it in the end for portability reasons. I’ve worked with both windows servers and linux servers, and quite a few different types of databases. Migrating with MS SQL is quite a bit of headache, whereas postgresql is a few commands to install, works anywhere, and migrates easily and quickly.

Also, I feel your sentiments about getting it setup because, imo, the Sonatype documentation is kinda lacking. It took us about a bit over an hour to get PostgreSQL setup, only because the Sonatype docs had a lot of implied assumptions that led to more needed research.

If you like though, I can grab my notes and send em your way.

The reason I asked about Oracle or MS SQL is due to maintenance reasons, as I’m not sure how we can handle patches and security fixes as soon as they are available. I would appreciate getting your notes. It would help us while migrating from the current H2 to PostgreSQL.

Here’s how we upgraded from H2 to PostgreSQL

Official documentation: Migrating to a New Database

When you see my instructions, you’ll see why I’m not particularly thrilled about the official documentation. There’s a lot you have to figure out yourself. I hope Sonatype works on a documentation style of more examples and hyperlinks. But anywho…

NOTE: Make sure your PostgreSQL version is OK for your Nexus version. For the latest Nexus 3.77, it says 13+ I think, so I went straight to PostgreSQL 17, and it’s been OK so far (used for 2 weeks no issues).

Install PostgreSQL
Source: PostgreSQL 17 Installation on Ubuntu 24.04 - DEV Community

  1. ssh @<your_nexus_server>
  2. sudo su
  3. apt update

Note: next two commands lets you use apt to install postgresql-17

  1. sudo sh -c ‘echo “deb Index of /pub/repos/apt/ $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’
  2. curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
  3. apt update
  4. apt install postgresql-17 -y
  5. systemctl start postgresql
  6. systemctl enable postgresql
  7. systemctl status postgresql # To test
  8. ufw allow 5432/tcp # Only needed if you have uncomplicated firewall turned on (which it is by default)

Set PostgreSQL Password
Note: Not required, but a good idea

  1. sudo -u postgres psql
  2. ALTER USER postgres PASSWORD ‘VeryStronGPassWord@1137’;

Install Trigram Module
Note: Not sure what this is, but Nexus requires it
Source: Installing the Trigram Module

  1. sudo -u postgres psql
  2. create extension pg_trgm schema public;
  3. select * from pg_extension;
  4. quit # Leave PostgreSQL

Migrate Database
Source: Migrating to a New Database

  1. sudo su
  2. vi /etc/postgresql/17/main/postgresql.conf
    a. Search for “autovacuum = on“ and uncomment it
    b. Save and close (escape, :x, enter)
  3. systemctl restart postgresql
  4. systemctl status postgresql # To test
  5. sudo -u postgres psql
    a. CREATE USER nexus WITH PASSWORD ‘super_strong_password_123’;
    b. # Save password somewhere for your IT admins
    c. CREATE DATABASE “nexus”
    WITH OWNER “nexus”
    ENCODING ‘UTF8’
    LC_COLLATE = ‘en_US.UTF-8’
    LC_CTYPE = ‘en_US.UTF-8’ TEMPLATE template0;
  6. quit
  7. cd /opt/nexus-data/etc/fabric # YOUR DATA PATH MAY BE DIFFERENT
  8. cp nexus-store.properties nexus-store.properties.orig
  9. vi /opt/nexus-data/etc/fabric/nexus-store.properties
    a. Comment out the one line already there
    b. Add these lines to the bottom
    c. username=nexus
    password=super_strong_password_123
    jdbcUrl=jdbc:postgresql://localhost:5432/nexus
    advanced=maximumPoolSize=200
  10. Save and close (escape, :x, enter)
  11. vi /opt/nexus-data/etc/nexus.properties
    a. Add this to the bottom
    b. nexus.datastore.enabled=true
    c. Save and close (escape, :x, enter)
  12. Create a backup if you feel like it
    a. Source: Configure and Run the Backup Task
  13. cd /opt/nexus-data/db
  14. systemctl stop nexus
  15. #Download latest migrator from Download
    a. Example: wget https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.77.2-02.jar
  16. chown nexus:nexus nexus-db-migrator*
  17. #Run the following command, but replace the password with the real PostgreSQL nexus password
  18. java -Xmx4G -Xms4G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M
    -jar nexus-db-migrator-*.jar
    –migration_type=h2_to_postgres
    –db_url=“jdbc:postgresql://localhost:5432/nexus?user=nexus&password=super_strong_password_123”
  19. y at the prompt
  20. sudo -u nexus psql
  21. VACUUM(FULL, ANALYZE, VERBOSE);
  22. quit

Update Service Dependency
NOTE: This is probably different for your setup, but we run nexus as a service as follows
NOTE: This update ensures PostgreSQL loads up on bootup before Nexus does

  1. sudo su
  2. vi /etc/systemd/system/nexus.service
    a. At the bottom of the [Unit] section, add a new Requires and After. The full file should look like this
    b. [Unit]
    Description=nexus service
    After=network.target
    Requires=postgresql.service
    After=postgresql.service
    [Service]
    Type=forking
    LimitNOFILE=65536
    ExecStart=/opt/nexus/bin/nexus start
    ExecStop=/opt/nexus/bin/nexus stop
    User=nexus
    Restart=on-abort
    [Install]
    WantedBy=multi-user.target
    c. systemctl daemon-reload

Test And Start

  1. If you’re nervous, do this first to start the server in the foreground and see any errors
    a. sudo su
    b. cd /opt/nexus/bin
    c. sudo -H -u nexus bash -c ‘./nexus run’ # NOTE: This runs as user nexus
    d. Once you see the big logo, similar to as follows, try going to <your_nexus_server_url> in your browser
    e. “-------------------------------------------------”
    “Started Sonatype Nexus PRO 3.77.1-01”
    “-------------------------------------------------”
    f. If you’re satisfied with testing, hit ctrl+c ONLY ONE TIME, and wait for proper shutdown (will take a few seconds).
  2. systemctl start nexus
  3. #Wait a moment then check your browser
  4. # IMPORTANT: ENSURE REBOOTING WORKS
  5. reboot
  6. #Try not to ssh into or mess with the server. Just wait a few minutes and let it do its thing, then check Nexus in your browser.

Hi there! Sonatype Tech Writing Manager here.
Thank you for this feedback and your detailed instructions on how you managed your migration. My team will review your process and see if there is anything we might do to improve our official documentation.

1 Like

Hi @Joshua_Temple,

Many thanks for the detailed instructions. What I’m missing is understanding the flow. Your Nexus was already running on PRO 3.77.1-01 with H2, right? Based on that, was the migration done, or did you combine the migration with a Nexus upgrade somehow?

Correct. To change to Pro, I reached out to Sonatype asking for a trial license, and in the web UI, uploaded the license file they sent me. That was enough to switch to Pro. Once I was on Pro with H2, the web UI was giving me some warnings about limits and suggesting I switch to PostgreSQL, which is the only reason we bothered.