Configure Artifactory HA to Use PostgreSQL Database in HA in Ansible

Configure JFrog Artifactory HA in Ansible to use external PostgreSQL instances deployed in high-availability mode for increased resiliency.

You can deploy external PostgreSQL instances in High Availaibility configurations for increased resiliency.

To configure Artifactory HA with PostgreSQL HA:

  1. Stop the Artifactory service.

  2. Edit the system.yaml file and update the following values.

📘

Note

Artifactory uses multiple drivers. Configure the connection strings separately for each driver.

  1. The url field under the shared database section in the following format.

    jdbc:postgresql://<PostgreSQL Database 1 URL>,..., <PostgreSQL Database N URL>/artifactory?targetServerType=primary
  2. The url field under the metadata database section in the following format.

    jdbc:postgresql://<PostgreSQL Database 1 URL>,..., <PostgreSQL Database N URL>/artifactory?target_session_attrs=read-write
📘

Understanding the connection parameters

The targetServerType=primary and target_session_attrs=read-write parameters apply to the entire connection, not to any individual host in the list. List all PostgreSQL HA nodes (primary and replicas) in the URL, separated by commas. The JDBC driver automatically discovers which node is currently the primary and connects to it.

This enables automatic failover: if the primary changes, the driver reconnects to the new primary on the next connection attempt.

The following sample shows an example system.yaml file configuration.

systemYaml:
 shared:
   logging:
   ...
   database:
     type: postgresql
     url: "jdbc:postgresql://17.21.0.2:5432,17.21.0.3:5432/artifactory?targetServerType=primary"
     driver: org.postgresql.Driver
     username: "artifactory"
     password: "password"
 artifactory:
   Database:
 ...
 frontend:
 ...
 access:
 ...
 metadata:
   database:
     type: postgresql
     url: "jdbc:postgresql://17.21.0.2:5432,17.21.0.3:5432/artifactory?target_session_attrs=read-write"
     driver: org.postgresql.Driver
     username: "artifactory"
     password: "password"
...
  1. Start the Artifactory service.