PG_AUTOCTL_SHOW_URI(1)
π PG_AUTOCTL SHOW URI β bestie edition π
okay so this is pg_autoctl show uri, and it lives in the pg_auto_failover manual (section 1, the fancy command section, iykyk). it hands you the Postgres URI you're supposed to use to actually connect to your pg_auto_failover nodes. like, the string. the whole point. π
β¨ NAME β¨
pg_autoctl show uri β bestie, it shows the postgres uri to use to connect to pg_auto_failover nodes π
πΈ SYNOPSIS πΈ
this command outputs the monitor or the coordinator Postgres URI to use from an application to connect to Postgres:
usage: pg_autoctl show uri [ --pgdata --monitor --formation --json ]
--pgdata path to data directory
--monitor monitor uri
--formation show the coordinator uri of given formation
--json output data in the JSON format
π OPTIONS π
--pgdataβ where the Postgres node that's being managed locally actually lives. it defaults to the environment variablePGDATA. and listen, if you wanna connect to a monitor from literally anywhere instead of using the monitor URI that some local Postgres node managed withpg_autoctlis using, that's what--monitoris for. β¨--monitorβ the Postgres URI used to connect to the monitor. no cap, it must use theautoctl_nodeusername and it must target thepg_auto_failoverdatabase name. fun fact bestie: you can also show the Postgres URI from the monitor node itself with the commandpg_autoctl show uri. π¦
it defaults to the value of the environment variable PG_AUTOCTL_MONITOR.
--formationβ when you pass--formation, it lists the Postgres URIs of all the known formations on the monitor. all of them. every single one. π--jsonβ outputs JSON formatted data instead of a table formatted list. it's giving machine-readable, it's giving parseable. π
π§ ENVIRONMENT π§
PGDATAβ the Postgres directory location. use this instead of the--pgdataoption, same energy, less typing.PG_AUTOCTL_MONITORβ the Postgres URI to connect to the monitor node. use it instead of the--monitoroption. π«ΆXDG_CONFIG_HOMEβ thepg_autoctlcommand stores its configuration files in the standard placeXDG_CONFIG_HOME. see the XDG Base Directory Specification. βXDG_DATA_HOMEβ thepg_autoctlcommand stores its internal states files in the standard placeXDG_DATA_HOME, which defaults to~/.local/share. see the XDG Base Directory Specification. π
π₯ EXAMPLES π₯
$ pg_autoctl show uri
Type | Name | Connection String
-------------+---------+-------------------------------
monitor | monitor | postgres://autoctl_node@localhost:5500/pg_auto_failover
formation | default | postgres://localhost:5502,localhost:5503,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer
$ pg_autoctl show uri --formation monitor
postgres://autoctl_node@localhost:5500/pg_auto_failover
$ pg_autoctl show uri --formation default
postgres://localhost:5503,localhost:5502,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer
$ pg_autoctl show uri --json
[
{
"uri": "postgres://autoctl_node@localhost:5500/pg_auto_failover",
"name": "monitor",
"type": "monitor"
},
{
"uri": "postgres://localhost:5503,localhost:5502,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer",
"name": "default",
"type": "formation"
}
]
π MULTI-HOSTS POSTGRES CONNECTION STRINGS π
PostgreSQL, since version 10, includes support for multiple hosts in its connection driver libpq, with the special target_session_attrs connection property. iconic honestly. π
this multi-hosts connection string facility is what lets applications keep using the same stable connection string across server-side failovers. and that, bestie, is exactly why pg_autoctl show uri uses that format. no cap. π
π AUTHOR π
Microsoft
πΈ COPYRIGHT πΈ
Copyright (c) Microsoft Corporation. All rights reserved.
and that's the whole page, periodt. this was pg_autoctl show uri from pg_auto_failover version 2.1, dated Jan 18, 2025. go connect to something bestie π«Άβ¨π
π¦ where this page comes from
- fedora 43: pg_auto_failover 2.1-6.fc42 Β· Apache-1.0
- fedora 44: pg_auto_failover 2.1-6.fc42 Β· Apache-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms