Re: WAL archive cleanup om master

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: WAL archive cleanup om master
Date: 2014-01-06 16:45:52
Message-ID: 20140106164551.GC23118@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 06, 2014 at 08:17:37AM -0800, Adrian Klaver wrote:
> On 01/06/2014 07:35 AM, Martijn van Oosterhout wrote:
> >On Mon, Jan 06, 2014 at 07:16:25AM -0800, Adrian Klaver wrote:
> >>On 01/06/2014 03:18 AM, Martijn van Oosterhout wrote:
> >>>Hoi,
> >>>
> >>>
> >
> >I'm not sure what you mean, isn't this the recommended way of doing
> >things? The configuration comes from here:
> >
> >http://wiki.postgresql.org/wiki/Hot_Standby
> >
> >The master saves the archives to a directory, rsync copies them to
> >the slave, where there restore_command can find them.
>
> Well this is the above is where is could be redundant. In your
> original post it would seem the archive_command and restore_command
> are pointing at the same directory. I realize they are just
> placeholder names, so is that the case? If so I am not sure what
> the rsync accomplishes. If not why not just make it so?

Well, they're the same directory on different machines. The directory
is actually /var/lib/postgresql/9.2/xlogs on both, but that's not
really relevent.

There's a cronjob on the master that says:

rsync -avz /var/lib/postgresql/9.2/xlogs/* slave:/var/lib/postgresql/9.2/xlogs/

The question is: what is it that prevents the WAL files in
/var/lib/postgresql/9.2/xlogs from filling the disk on the master?

> The minimal cover your bases setup is usually given as:
>
>
> Primary(Machine1) --> Archive --> Archive Directory(Machine2)
> | |
> | Streaming Restore |
> -> Standby(Machine3) < -
>
> Excuse the ASCII art.

The ascii art is fine, but you have the same problem: on the Machine1
the WAL files are stored prior to copying to Machine2. How do you know
when you can delete files safely on Machine1?

Anyway, I found this page on the wiki:

http://wiki.postgresql.org/wiki/Binary_Replication_Tutorial

which says that:

archive_command = 'rsync -a %p 192.168.0.2:/var/lib/pgsql/data/archive/%f'

is acceptable and also avoids the problem. I'll just test what happens
with network failure (hopefully it doesn't kill the master).

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
-- Arthur Schopenhauer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-01-06 17:05:01 Re: WAL archive cleanup om master
Previous Message Stephen Woodbridge 2014-01-06 16:38:42 Re: How to check for pending CancelRequest from C/C++ function