Artifactory HA PostgreSQL Configuration with Ansible
Configure JFrog Artifactory HA to use PostgreSQL HA by setting multi-host JDBC connection strings with automatic primary failover in system.yaml.
You can deploy external PostgreSQL instances in High Availability configurations for increased resiliency.
To configure Artifactory HA with PostgreSQL HA:
-
Stop the Artifactory service.
-
Edit the
system.yamlfile and update the following values.
Note
Artifactory uses multiple drivers. Configure the connection strings separately for each driver.
-
The
urlfield under theshareddatabase section in the following format.jdbc:postgresql://<PostgreSQL Database 1 URL>,..., <PostgreSQL Database N URL>/artifactory?targetServerType=primary -
The
urlfield under themetadatadatabase 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=primaryandtarget_session_attrs=read-writeparameters 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"
...- Start the Artifactory service.
Updated 5 days ago
