Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id A0DEB14FB14 for ; Thu, 10 May 2012 21:12:07 -0300 (ADT) Received: from esrismtp2.esri.com ([198.102.62.103] helo=Vail.esri.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SSdSm-0006XE-JF for pgsql-admin@postgresql.org; Fri, 11 May 2012 00:12:07 +0000 Received: from redmxhub1.esri.com (redmxhub1.esri.com [10.50.4.137]) by Vail.esri.com (8.13.7+Sun/8.13.7) with ESMTP id q4B0Bp8U014217 for ; Thu, 10 May 2012 17:11:51 -0700 (PDT) Received: from redmx2.esri.com ([10.49.4.18]) by redmxhub1.esri.com ([10.50.4.137]) with mapi; Thu, 10 May 2012 17:11:50 -0700 From: Kasia Tuszynska To: "pgsql-admin@postgresql.org" Date: Thu, 10 May 2012 17:11:49 -0700 Subject: PG 9.1 wal archiving Thread-Topic: PG 9.1 wal archiving Thread-Index: Ac0vCqjhozlVE1J4SryAP5JDPdXMrA== Message-ID: <232B5217AD58584C87019E8933556D1103765FDAB0@redmx2.esri.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_232B5217AD58584C87019E8933556D1103765FDAB0redmx2esricom_" MIME-Version: 1.0 X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201205/56 X-Sequence-Number: 39545 --_000_232B5217AD58584C87019E8933556D1103765FDAB0redmx2esricom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Everybody, I am testing the new features in 9.1 related to backups and restores. I want to establish a workflow for doing a base backup, archiving wals for = a primary server and be able to restore the primary server from those. Testing Environment: Testing on Windows Server 2008 R2 Postgresql.conf settings, different from default: wal_level =3D hot_standby checkpoint_segments =3D 1 archive_mode =3D on archive_command =3D 'copy "%p" "C:\\postgres_archive\\%f"' max_wal_senders =3D 3 wal_keep_segments =3D 1 perform a plane basebackup: pg_basebackup.exe -h -D -Fp -U So, I have a basebackup and a wal archive. My questions are about the behavior of the wal creation and archive. Q1: I tried to minimize the number of wals created with the checkpoing_segm= ents and wal_keep_segments parameters, I was hoping that reducing the value= s for those parameters would result in about 3 wals. But I am still gettin= g about 8 walls created. What else could I do to limit or control the number of wals created? I am d= oing this just for testing purposes ... Q2: If I load some data into the db I do see the date on a wal under pg_xlo= g to get updated which is the record of the transactions, I do see the wals= being overwritten, which is the log switch when the 16megs gets overwritte= n, what I do not see is the immediate reflection of the last written to wal= file in the archive location. Which is what I would expect. I think I am seeing the archive location written to when pg cycles through = all 8 wals. Which does not make sense to me, b/c in the case of failure I w= ould be missing 7 wals for recovery. Q3: When I do get this archiving business figured out I would like to perfo= rm a recovery of the primary server using pg_basebackup and archived wals. I am assuming that I would need to apply the result of pg_basebackup + all = wals archived since the backup + the last wal segment salvaged from the ori= ginal PGDATA location. If that assumption is correct than I would need to save the archive_status = folder, and place it in the new PGDATA \pg_xlog location? I am assuming th= at the archive_status folder holds the wal segment that is currently being = written into. This is where I am most confused: The result of the plane pg_basebackup would be copied and pasted into the P= GDATA location The archived wals would be read from the recovery.conf recovery_command, re= ad after the cluster is started up again. But the archive_status folder would be placed in the pg_xlog collation manu= ally? I guess there is no other way to do it, but I want to make sure that I did = not miss something in the doc. The doc discusses more complex scenarios dealing with a secondary server, a= t the moment I am only interested in recovering the primary server. Thank you, Sincerely, Kasia --_000_232B5217AD58584C87019E8933556D1103765FDAB0redmx2esricom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Everybody,

I am testing the new features in 9.1 relat= ed to backups and restores.

I want to es= tablish a workflow for doing a base backup, archiving wals for a primary se= rver and be able to restore the primary server from those.

<= p class=3DMsoNormal> 

Testing Envir= onment:

Testing on Windows Server 2008 R= 2

 

Postgresql.conf settings, different from default:

wal_level =3D hot_standby

= checkpoint_segments =3D 1

archive_mode = =3D on

archive_command =3D ‘copy &= #8220;%p” “C:\\postgres_archive\\%f”’

max_wal_senders =3D 3

wal_keep_segments =3D 1

 <= /o:p>

perform a plane basebackup:

pg_basebackup.exe –h <hostname>  -D <= ;location to backup to> -Fp –U <replication user>=

 

So, I ha= ve a basebackup and a wal archive.

My qu= estions are about the behavior of the wal creation and archive.<= /p>

 

Q1: I tri= ed to minimize the number of wals created with the checkpoing_segments and = wal_keep_segments parameters, I was hoping that reducing the values for tho= se parameters would result in about 3 wals.  But I am still getting ab= out 8 walls created.

What else could I d= o to limit or control the number of wals created? I am doing this just for = testing purposes …

 

Q2: If I load some data into the db I do see the= date on a wal under pg_xlog to get updated which is the record of the tran= sactions, I do see the wals being overwritten, which is the log switch when= the 16megs gets overwritten, what I do not see is the immediate reflection= of the last written to wal file in the archive location.  Which is wh= at I would expect.

I think I am seeing t= he archive location written to when pg cycles through all 8 wals. Which doe= s not make sense to me, b/c in the case of failure I would be missing 7 wal= s for recovery.

 

Q3: When I do get this archiving business figured out I = would like to perform a recovery of the primary server using pg_basebackup = and archived wals.

I am assuming that I= would need to apply the result of pg_basebackup + all wals archived since = the backup + the last wal segment salvaged from the original PGDATA locatio= n. 

If that assumption is correct = than I would need to save the archive_status  folder, and place it in = the new PGDATA \pg_xlog location? I am assuming that the archive_status fol= der holds the wal segment that is currently being written into.<= /p>

 

This is w= here I am most confused:

The result of t= he plane pg_basebackup would be copied and pasted into the PGDATA location<= o:p>

The archived wals would be read from the= recovery.conf recovery_command, read after the cluster is started up again= .

But the archive_status folder would be= placed in the pg_xlog collation manually?

I guess there is no other way to do it, but I want to make sure that I d= id not miss something in the doc.

&= nbsp;

The doc discusses more complex scenario= s dealing with a secondary server, at the moment I am only interested in re= covering the primary server.

 = ;

Thank you,

Sincerely,

Kasia

= --_000_232B5217AD58584C87019E8933556D1103765FDAB0redmx2esricom_--