Обсуждение: WAL segment management on a standby

Поиск
Список
Период
Сортировка

WAL segment management on a standby

От
John Scalia
Дата:
Again, thanks to all to have assisted me with getting the WAL segments to both my standby servers. Everything with that
isnow working quite well. I do have a related followup  
question, however. On these standby's nothing is built in to manage those WAL segments in the archive directory. Thus,
thatdirectory can grow to the point where it fills up the  
disk rather quickly. Any good strategies for dealing with the WAL segments that get put in there. Do I really need them
afterpostgresql has copied them up into the pg_xlog  
directory? If so, how far back should I keep them? Yes, I know about keeping everything between backups. So, if my
directorylooks like: 

00000000300000000C000000A1
00000000300000000C000000A2
00000000300000000C000000A3
00000000300000000C000000A3.backup
00000000300000000C000000A4

Could I safely delete the *A1, *A2, and maybe even the *A3 files?
--
Jay


Re: WAL segment management on a standby

От
Matheus de Oliveira
Дата:

On Fri, Jul 11, 2014 at 1:49 PM, John Scalia <jayknowsunix@gmail.com> wrote:
00000000300000000C000000A1
00000000300000000C000000A2
00000000300000000C000000A3
00000000300000000C000000A3.backup
00000000300000000C000000A4

Could I safely delete the *A1, *A2, and maybe even the *A3 files?

If you only care to storing files needed for backup made at 00000000300000000C000000A3, you can remove 00000000300000000C000000A1 and 00000000300000000C000000A2, but not the others.

Regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

Re: WAL segment management on a standby

От
John Scalia
Дата:
Thanks Matheus,

What I guess I'm more than curious about is as this is one of two standbys and I could always rebuild it again from either of the other two machines, is what am I risking if delete everything except maybe the last handful of WAL segments? When I start the database, I usually only see one or maybe two references to WAL segments being used to sync up. And being that the standby streams anyway, I'm not all that concerned if another pg_basebackup has to run to rebuild the standby. I only want it to start cleanly in the event of a stoppage. Which almost never happens anyway.
--
Jay

On 7/11/2014 12:58 PM, Matheus de Oliveira wrote:

On Fri, Jul 11, 2014 at 1:49 PM, John Scalia <jayknowsunix@gmail.com> wrote:
00000000300000000C000000A1
00000000300000000C000000A2
00000000300000000C000000A3
00000000300000000C000000A3.backup
00000000300000000C000000A4

Could I safely delete the *A1, *A2, and maybe even the *A3 files?

If you only care to storing files needed for backup made at 00000000300000000C000000A3, you can remove 00000000300000000C000000A1 and 00000000300000000C000000A2, but not the others.

Regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres


Re: WAL segment management on a standby

От
Craig Ringer
Дата:
On 07/12/2014 12:49 AM, John Scalia wrote:
> Again, thanks to all to have assisted me with getting the WAL segments
> to both my standby servers. Everything with that is now working quite
> well. I do have a related followup question, however. On these standby's
> nothing is built in to manage those WAL segments in the archive
> directory. Thus, that directory can grow to the point where it fills up
> the disk rather quickly. Any good strategies for dealing with the WAL
> segments that get put in there. Do I really need them after postgresql
> has copied them up into the pg_xlog directory? If so, how far back
> should I keep them? Yes, I know about keeping everything between
> backups. So, if my directory looks like:
>
> 00000000300000000C000000A1
> 00000000300000000C000000A2
> 00000000300000000C000000A3
> 00000000300000000C000000A3.backup
> 00000000300000000C000000A4
>
> Could I safely delete the *A1, *A2, and maybe even the *A3 files?

Take a look at the pg_archivecleanup tool.

You might also want to look at PgBarman to automate this.


--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: WAL segment management on a standby

От
John Scalia
Дата:
Thanks Craig, I didn't know about pg_archivecleanup. (it's hard to figure out every utility when you're not given the
timeto thoroughly study the system.) 

I altered the recovery.conf per the suggestion on the documentation page for it. It does seem a little aggresive, but
I'mguessing that because all the transactions have been  
recorded from the streaming walreceiver.  If I might, I'd like to ask one final question on this matter. In looking
throughthe standby after configuring this and restarting the  
system, the log file shows a few warnings.

First, it whined about no history.0000004 file, which as the last WAL segment is 0000000030000000E00000004E, I'm
guessingthe standby thought the timeline might have been changed,  
but it was not. Then, it complained about no history.00000003 file in the archive area. This file had already been
copiedup into pg_xlog and deleted from the archive. Finally, the  
last complaint was that it couldn't find 0000000030000000E00000004F in the archive. It appears that under streaming a
standbyserver will write concurrently with the primary any  
WAL segment the primary is still generating. I say this as that missing WAL segment ("...4F") was already in the
pg_xlogdirectory, but it hadn't yet made it into the archive area.  
Eventually, 10 minutes later, 4F did appear in the archive. Is my interpretation here correct, that a standby will
concurrentlywrite a WAL segment in streaming replication mode? 

I just want to be able to explain this thoroughly to my QA folks.
--
Jay

On 7/13/2014 10:18 PM, Craig Ringer wrote:
> On 07/12/2014 12:49 AM, John Scalia wrote:
>> Again, thanks to all to have assisted me with getting the WAL segments
>> to both my standby servers. Everything with that is now working quite
>> well. I do have a related followup question, however. On these standby's
>> nothing is built in to manage those WAL segments in the archive
>> directory. Thus, that directory can grow to the point where it fills up
>> the disk rather quickly. Any good strategies for dealing with the WAL
>> segments that get put in there. Do I really need them after postgresql
>> has copied them up into the pg_xlog directory? If so, how far back
>> should I keep them? Yes, I know about keeping everything between
>> backups. So, if my directory looks like:
>>
>> 00000000300000000C000000A1
>> 00000000300000000C000000A2
>> 00000000300000000C000000A3
>> 00000000300000000C000000A3.backup
>> 00000000300000000C000000A4
>>
>> Could I safely delete the *A1, *A2, and maybe even the *A3 files?
> Take a look at the pg_archivecleanup tool.
>
> You might also want to look at PgBarman to automate this.
>
>



Re: WAL segment management on a standby

От
Craig Ringer
Дата:
On 07/14/2014 09:57 PM, John Scalia wrote:
>
> First, it whined about no history.0000004 file, which as the last WAL
> segment is 0000000030000000E00000004E, I'm guessing the standby thought
> the timeline might have been changed, but it was not. Then, it
> complained about no history.00000003 file in the archive area. This file
> had already been copied up into pg_xlog and deleted from the archive.

No immediate answer for you there.

> Finally, the last complaint was that it couldn't find
> 0000000030000000E00000004F in the archive. It appears that under
> streaming a standby server will write concurrently with the primary any
> WAL segment the primary is still generating. I say this as that missing
> WAL segment ("...4F") was already in the pg_xlog directory, but it
> hadn't yet made it into the archive area. Eventually, 10 minutes later,
> 4F did appear in the archive. Is my interpretation here correct, that a
> standby will concurrently write a WAL segment in streaming replication
> mode?

The xlog files get written to in pg_xlog until they're rotated. When
rotated, they get archived; when the archive command completes, they
become accessible to standby servers.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services