pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: normandavis1990 <normandavis1990@proton.me>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Create a standby server
Date: Mon, 11 Mar 2024 08:13:45 -0400
Message-ID: <Ze71eTN6uCCPDzZF@tamriel.snowman.net> (raw)
In-Reply-To: <e7wKZVtesjLCiU0KkgL8YhjecAtJgdjCUm7mA05IwziSLXQxciKU7dtj9tzw_mvXuGNLBznonqQOs52mlTGtdUcO8xeFjqurjQkNdXFwCAk=@proton.me>
References: <e7wKZVtesjLCiU0KkgL8YhjecAtJgdjCUm7mA05IwziSLXQxciKU7dtj9tzw_mvXuGNLBznonqQOs52mlTGtdUcO8xeFjqurjQkNdXFwCAk=@proton.me>

Greetings,

* normandavis1990 (normandavis1990@proton.me) wrote:
> I have a master and tow standby servers. I want to create another one. These servers are made by someone else and I am a newbie in PostgreSQL.
> I found the following two tutorials:

[...]

> A) Which on is better and easier?

One referred to 9.2, which is extremly old and no longer supported, and
the other said it was archived ... so I'm not sure either is really
great to be used today.

> B) In these articles, to create a Standby server, a user is created in the database. Because there are already two Standby servers, this user is probably created. How can I find it? Can I use that user to build a third server?

If those systems are connected to the primary, you can query the view
pg_stat_replication and see what user they are connected with:

SELECT * FROM pg_stat_replication;

You should be able to use the existing user to create a new standby.
I'd recommend using pg_basebackup to create it with a command along
these lines:

pg_basebackup -h existing.server.com -U username -D /destination/directory -c fast -C -S standbyslotname -R -P -v

Running pg_basebackup this way will:
- Have pg_basebackup connect to 'existing.server.com' (should be your
  primary)
- Connect as user 'username' (pull this from the 'usename' field in
  pg_stat_replication)
- Store the data files for the new system into /destination/directory on
  the system where pg_basebackup is run
- Start the backup immediately by doing a 'fast' checkpoint
- Create a replication slot to use to make sure the WAL is kept on the
  primary until the new standby system collects it (you should monitor
  this though- if you destroy this new system, WAL could build up on the
  primary).
- Use 'standbyslotname' as the name of the slot that's created
- Instructs pg_basebackup to write out the connection information to
  connect to the primary and start streaming when it starts up.
- Enabled progress reporting from pg_basebackup
- Enables verbose mode of pg_basebackup

Full documentation of pg_basebackup is here:

https://www.postgresql.org/docs/current/app-pgbasebackup.html

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (6+ messages)  latest in thread

Message-ID: <Ze71eTN6uCCPDzZF@tamriel.snowman.net>
Permalink:  ../Ze71eTN6uCCPDzZF@tamriel.snowman.net/
Also on:    postgresql.org/message-id/Ze71eTN6uCCPDzZF@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sfrost@snowman.net, normandavis1990@proton.me
  Subject: Re: Create a standby server
  In-Reply-To: <Ze71eTN6uCCPDzZF@tamriel.snowman.net>
  References: <e7wKZVtesjLCiU0KkgL8YhjecAtJgdjCUm7mA05IwziSLXQxciKU7dtj9tzw_mvXuGNLBznonqQOs52mlTGtdUcO8xeFjqurjQkNdXFwCAk=@proton.me> <Ze71eTN6uCCPDzZF@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox