1PG_AUTOCTL SHOW URI(1) pg_auto_failover PG_AUTOCTL SHOW URI(1)
2
3
4
6 pg_autoctl show uri - pg_autoctl show uri
7
8 pg_autoctl show uri - Show the postgres uri to use to connect to
9 pg_auto_failover nodes
10
12 This command outputs the monitor or the coordinator Postgres URI to use
13 from an application to connect to Postgres:
14
15 usage: pg_autoctl show uri [ --pgdata --monitor --formation --json ]
16
17 --pgdata path to data directory
18 --monitor monitor uri
19 --formation show the coordinator uri of given formation
20 --json output data in the JSON format
21
23 --pgdata
24 Location of the Postgres node being managed locally. Defaults to
25 the environment variable PGDATA. Use --monitor to connect to a
26 monitor from anywhere, rather than the monitor URI used by a lo‐
27 cal Postgres node managed with pg_autoctl.
28
29 --monitor
30 Postgres URI used to connect to the monitor. Must use the au‐
31 toctl_node username and target the pg_auto_failover database
32 name. It is possible to show the Postgres URI from the monitor
33 node using the command pg_autoctl show uri.
34
35 Defaults to the value of the environment variable PG_AU‐
36 TOCTL_MONITOR.
37
38 --formation
39 When --formation is used, lists the Postgres URIs of all known
40 formations on the monitor.
41
42 --json Output a JSON formatted data instead of a table formatted list.
43
45 PGDATA
46 Postgres directory location. Can be used instead of the --pgdata op‐
47 tion.
48
49 PG_AUTOCTL_MONITOR
50 Postgres URI to connect to the monitor node, can be used instead of
51 the --monitor option.
52
53 XDG_CONFIG_HOME
54 The pg_autoctl command stores its configuration files in the stan‐
55 dard place XDG_CONFIG_HOME. See the XDG Base Directory Specifica‐
56 tion.
57
58 XDG_DATA_HOME
59 The pg_autoctl command stores its internal states files in the stan‐
60 dard place XDG_DATA_HOME, which defaults to ~/.local/share. See the
61 XDG Base Directory Specification.
62
64 $ pg_autoctl show uri
65 Type | Name | Connection String
66 -------------+---------+-------------------------------
67 monitor | monitor | postgres://autoctl_node@localhost:5500/pg_auto_failover
68 formation | default | postgres://localhost:5502,localhost:5503,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer
69
70 $ pg_autoctl show uri --formation monitor
71 postgres://autoctl_node@localhost:5500/pg_auto_failover
72
73 $ pg_autoctl show uri --formation default
74 postgres://localhost:5503,localhost:5502,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer
75
76 $ pg_autoctl show uri --json
77 [
78 {
79 "uri": "postgres://autoctl_node@localhost:5500/pg_auto_failover",
80 "name": "monitor",
81 "type": "monitor"
82 },
83 {
84 "uri": "postgres://localhost:5503,localhost:5502,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer",
85 "name": "default",
86 "type": "formation"
87 }
88 ]
89
91 PostgreSQL since version 10 includes support for multiple hosts in its
92 connection driver libpq, with the special target_session_attrs connec‐
93 tion property.
94
95 This multi-hosts connection string facility allows applications to keep
96 using the same stable connection string over server-side failovers.
97 That's why pg_autoctl show uri uses that format.
98
100 Microsoft
101
103 Copyright (c) Microsoft Corporation. All rights reserved.
104
105
106
107
1082.0 Sep 13, 2023 PG_AUTOCTL SHOW URI(1)