Have any tricks not to recreate a standby server to switch to the former primary?

From: vvoody <wxj(dot)g(dot)sh(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Have any tricks not to recreate a standby server to switch to the former primary?
Date: 2010-12-19 03:23:30
Message-ID: AANLkTiky9nv7bd1YgQ2suuP0waQfWjnh3ux5ZR=03_aK@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello, guys ;-)

Env: PostgreSQL 8.4.5 + CentOS 4.8

I have two servers, one primary and one standby, which doing warm
standby. Every thing works fine at the beginning. The primary
generates the archive WAL log files and the standby fetchs them to
merge.

Then, I want to let the standby become primary. So I stop the
postgresql(service postgresql stop) manually, copy the last WAL file
and files under pg_xlog/ to the standby. The former standby now
becomes primary and the data is ok. BTW, it still started as archive
mode.

Not end yet. After the standby running for a while and generating some
data, I want to switch back to the former primary. And I repeat the
above steps: stop the postgresql service manuall, copy WAL log files
and files under pg_xlog/ to the former primary. I delete the pg_xlog/
and files under archive directory. Then the postgresql starts, but the
data generated after last switching do not come over.

The doucment(24.4.3. paragraph 5) said "To return to normal operation
we must fully recreate a standby server". I understand that, but it is
under failover, not a case like my switching normally. Recreating a
standby server costs too much for us(the initial one is ok). We are
building a high availability system, so I hope the postgresql be able
to switch over and over fast without data losing and inconsistent.

Any ideas are appreciated ;-)
Best regards.

--
Free as freedom, slack as Slackware.
vvoody

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Glenn Maynard 2010-12-19 08:13:46 Re: FTS phrase searches
Previous Message Adrian Klaver 2010-12-18 23:05:17 Re: Copy From suggestion