pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrus <kobruleht2@hot.ee>
To: Paul Förster <paul.foerster@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to start slave after pg_basebackup. Why min_wal_size and wal_keep_segments are duplicated
Date: Mon, 1 Jun 2020 11:17:19 +0300
Message-ID: <DC1BA2AF303246A3A349C8B0F8B01E1D@dell2> (raw)
In-Reply-To: <EBFD984A-90DC-4C6A-A6D8-233F08472C31@gmail.com>
References: <26EC9619620649D1B55C9C95811E4ADB@dell2>
	<B7E0C7C6-865B-4632-B10A-11B2E468D40A@gmail.com>
	<69FF4F48E6FE4A63A2EBD820C5B2B3A3@dell2>
	<EBFD984A-90DC-4C6A-A6D8-233F08472C31@gmail.com>

Hi!

> I have tried to re-initiate replica serveral times in low-use time but this error occurs again.
>remove the whole replica's PGDATA/* and do a pg_basebackup again. But before that, make sure wal_keep_segments in big enough on the 
>master and,

I renamed whole cluster before pg_basebackup

>just as much important, do a vacuumdb -a (takes much space during the process) and use archiving!

I run vacuumdb --full --all before pg_basebackup

> If named replication slot is used commands like
> vacuumdb --all --full
> will cause main server crash due to disk space limit. pg_wal directory will occupy free disk space. After that main server stops.
>>if you have disk constraints you will run into trouble sooner or later anyway. Make sure, you have enough disk space. There's no 
>>way around that anyway.

This space is sufficient for base backup and replication.

>> I tried using wal_keep_segments =180
>> Will setting wal_keep_segments to higher value allw replication start after pg_basebackup ?
>it depends. If you start the replica immediately and don't wait for hours or days, you should be good to go. But that depends on 
>different factors, for example, how >many WAL files are written during the pg_basebackup and pg_ctl start of the replica. If more 
>than 180 WALs have gone by on the master because it is really busy, >then you're probably lost again. Point being, you'll have to 
>launch the replica before WALs are expired!
>Again: Make sure you have enough disk space, use archiving and use a replication slot.

I tried with wal_keep_segments=360 but problem persisists.
Server generates lot of less than 300 wal files.

Shell script starts server after pg_basebackup completes automatically:

PGHOST=example.com
PGPASSWORD=mypass
PGUSER=replikaator
export PGHOST  PGPASSWORD PGUSER
/etc/init.d/postgresql stop
mv /var/lib/postgresql/12/main /var/lib/postgresql/12/mainennebaasbakuppi
pg_basebackup --verbose --progress --write-recovery-conf -D /var/lib/postgresql/12/main
chmod --recursive --verbose 0700 /var/lib/postgresql/12/main
chown -Rv postgres:postgres /var/lib/postgresql/12/main
/etc/init.d/postgresql start

How to create replication server ?

Andrus.






view thread (17+ messages)  latest in thread

Message-ID: <DC1BA2AF303246A3A349C8B0F8B01E1D@dell2>
Permalink:  ../DC1BA2AF303246A3A349C8B0F8B01E1D@dell2/
Also on:    postgresql.org/message-id/DC1BA2AF303246A3A349C8B0F8B01E1D@dell2

 · 

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: kobruleht2@hot.ee, paul.foerster@gmail.com
  Subject: Re: How to start slave after pg_basebackup. Why min_wal_size and wal_keep_segments are duplicated
  In-Reply-To: <DC1BA2AF303246A3A349C8B0F8B01E1D@dell2>
  References: <26EC9619620649D1B55C9C95811E4ADB@dell2> <B7E0C7C6-865B-4632-B10A-11B2E468D40A@gmail.com> <69FF4F48E6FE4A63A2EBD820C5B2B3A3@dell2> <EBFD984A-90DC-4C6A-A6D8-233F08472C31@gmail.com> <DC1BA2AF303246A3A349C8B0F8B01E1D@dell2>

* 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