Discovering connection strings v5
You can install PGD CLI on any system that can connect to the PGD cluster. To use PGD CLI, you need a user with PGD superuser privileges or equivalent. The PGD user with superuser privileges is the bdr_superuser role. An example of an equivalent user is edb_admin on an EDB BigAnimal distributed high-availability cluster.
PGD CLI and database connection strings
You might not need a database connection string. For example, when Trusted Postgres Architect installs the PGD CLI on a system, it also configures the connection to the PGD cluster. This means that PGD CLI can connect to the cluster when run.
Getting your database connection string
Because of the range of different configurations that PGD supports, every deployment method has a different way of deriving a connection string for it. Generally, you can obtain the required information from the configuration of your deployment. You can then assemble that information into connection strings.
For a TPA-deployed PGD cluster
Because TPA is so flexible, you have to derive your connection string from your cluster configuration file (config.yml
).
- You need the name or IP address of a host with the role pgd-proxy listed for it. This host has a proxy you can connect to. Usually the proxy listens on port 6432. (Check the setting for
default_pgd_proxy_options
andlisten_port
in the config to confirm.) - The default database name is
bdrdb
. (Check the settingbdr_database
in the config to confirm.) - The default PGD superuser is enterprisedb for EDB Postgres Advanced Server and postgres for PostgreSQL and EDB Postgres Extended Server.
You can then assemble a connection string based on that information:
To illustrate this, here are some excerpts of a config.yml
file for a cluster:
The connection string for this cluster is:
Host name versus IP address
The example uses the IP address because the configuration is from a Docker TPA install with no name resolution available. Generally, you can use the host name as configured.
For an EDB BigAnimal distributed high-availability cluster
- Log in to the BigAnimal clusters view.
- In the filter, set Cluster Type to Distributed High Availability to show only clusters that work with PGD CLI.
- Select your cluster.
- In the view of your cluster, select the Connect tab.
- Copy the read/write URI from the connection info. This is your connection string.
For a cluster deployed with EDB PGD for Kubernetes
As with TPA, EDB PGD for Kubernetes is very flexible, and there are multiple ways to obtain a connection string. It depends, in large part, on how the services were configured for the deployment:
- If you use the Node Service Template, direct connectivity to each node and proxy service is available.
- If you use the Group Service Template, there's a gateway service to each group.
- If you use the Proxy Service Template, a single proxy provides an entry point to the cluster for all applications.
Consult your configuration file to determine this information.
Establish a host name or IP address, port, database name, and username. The default database name is bdrdb
, and the default username is enterprisedb for EDB Postgres Advanced Server and postgres for PostgreSQL and EDB Postgres Extended Server.
You can then assemble a connection string based on that information:
If the deployment's configuration requires it, add sslmode=<sslmode>
.