Confirm Postgres Working

How do I confirm that Postgres is now the database? I followed the directions from Configuring Nexus Repository Pro for H2 or PostgreSQL for Postgres on my Docker deployment and I can’t confirm I am now using PostgreSQL. I edited the following two files in my Nexus container and restarted the containers.

/nexus-data/etc/nexus.properties
and
/nexus-data/etc/fabric/nexus-store.properties

Here is my docker-compose.yml

version: "3"
services:
  # HTTPS proxy
  nginx-proxy:
    image: nginx:latest
    container_name: nginx-proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      # Config
      - /root/nexus3/default.conf:/etc/nginx/conf.d/default.conf
      
      # Keep the dhparams (Should generate on the first run)
      - dhparam:/etc/nginx/dhparam
      
      # Fix the upload size issue
      - /root/nexus3/my_custom_proxy_settings.conf:/etc/nginx/conf.d/my_custom_proxy_settings.conf:ro
      
      # Push the certs to nginx
      - /root/nexus3/certs:/etc/nginx/certs:ro
    depends_on:
      - nexus

  # Artifact storage
  nexus:
    image: sonatype/nexus3:latest
    container_name: nexus
    restart: always
    stop_grace_period: 2m
    volumes:
        - nexus-data:/nexus-data
        - /mnt/nexus_mvn_mirror_repo_data:/nexus-mvn-mirror-repo-data
        - /mnt/nexus_docker_repo_data:/nexus-docker-repo-data
        - /mnt/nexus_mvn_repo_data:/nexus-mvn-repo-data
    depends_on:
        - postgres

  # PostgreSQL Database
  postgres:
    image: postgres:latest
    container_name: postgresql
    restart: always
    environment:
        POSTGRES_USER: nexus3
        POSTGRES_PASSWORD: REDACTED
    volumes:
        - pgdata:/var/lib/postgresql/data

volumes:
  nexus-data:
  dhparam:
  pgdata:

/nexus-data/etc/nexus.properties

# Jetty section
# application-port=8081
# application-host=0.0.0.0
# nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
# nexus-context-path=/${NEXUS_CONTEXT}

# Nexus section
# nexus-edition=nexus-pro-edition
# nexus-features=\
#  nexus-pro-feature
# nexus.clustered=false

nexus.datastote.enabled=true

/nexus-data/etc/fabric/nexus-store.properties

username=nexus3
password=REDACTED
name=nexus
type=jdbc
jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus3

Check your nexus.log for log line with "MyBatis databaseId: "

1 Like

/nexus-data/log/nexus.log |grep databaseId returns nothing.

To confirm, are you a Nexus Pro user, postgresql is only available for licensed customers.

If you are a licensed user this may give some ideas on how you could install the license in your docker container - How to Install a Nexus Repository Manager 3 License – Sonatype Support

@mpiggott Nexus 3 Pro licensed for 25 users through Sun, Sep 18, 2022. License was installed through the web UI. Trying to switch to PostgreSQL.

Upon closer inspection you have a typo in your properties file :wink:

datastote -> datastore

1 Like

Ugh. Thank you very much! That was it.

Followup question, when PostgreSQL starts, it does not migrate the existing internal database to PostgresSQL. Is there a way to do this?

Not automatically, you’d want follow the help documentation to do it - Migrating to a New Database

You should ensure you have a backup of the blobstores and database in case you need to roll back, once your start using PostgreSQL the blobstore will diverge from the old database which would cause issues.

Let us know if there are problems or ambiguity with the instructions.

2 Likes

@mpiggott thanks Matthew for your help! I apologize, I JUST found that article. Again, thanks for your help today.

1 Like