Re: pg_update to a new machine?

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: pg_update to a new machine?
Date: 2018-02-24 21:10:08
Message-ID: 20180224211008.GT2416@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings,

* Ron Johnson (ron(dot)l(dot)johnson(at)cox(dot)net) wrote:
> On 02/24/2018 08:18 AM, Stephen Frost wrote:
> >* Ron Johnson (ron(dot)l(dot)johnson(at)cox(dot)net) wrote:
> >>2. install 8.4 on the new server,
> >>3. install 9.6.6 on the new server,
> >For pg_upgrade, you do need both versions installed on the server you're
> >running pg_upgrade on, yes. Please be sure to use the latest minor
> >version of each major version if you go that route.
> >
> >>2. rsync CURSERVER://var/lib/pgsql/data to
> >>NEWSERVER://var/lib/pgsql/8.4/data, and then
> >You can only perform this rsync with the database shut down, just to be
> >clear. If you wanted to pull the data across with the database online,
> >you'd need to set up an archive_command and use a tool which works with
> >8.4 to perform an online backup (such as pgBackRest).
>
> To set up log shipping on 8.4, I do this, which works well:
>
> select pg_start_backup('some_meaningful_tag');
> nohup rsync -avz /var/lib/pgsql/data/* postgres(at)${DESTIP}:/var/lib/pgsql/data/ &
> select pg_stop_backup();

That's not log shipping, for log shipping you need to specify an
archive_command and actually capture all of the WAL generated, or, at a
minimum, the WAL generated between the start and stop backup calls.

Note that the above also doesn't do anything to verify that the data is
written out to the disk on the destination side.

> Would I, essentially (or in fact), have to set up log shipping from old to new?

You must capture the WAL generated between the start and stop backup for
a backup to be valid. Beyond that, if you want the warm standby to
replay the changes made to the primary through WAL, you need to be
capturing the WAL generated on the primary using archive_command and
then specify a restore_command on the warm standby which will get the
WAL segments to be replayed.

> >>3. pg_upgrade?
> >If you perform an online backup and then capture all of the WAL using
> >archive_command, you could stand up a warm standby with 8.4 on the new
> >server which is replaying the WAL as it's generated on the primary by
> >specifying a restore_command on the new server.
>
> I guess that means "yes, set up log shipping"?

I'm not sure what you're asking here, but if you wish to minimize
downtime, then, yes, set up a warm standby which is being updated
through log shipping.

> > Doing this, combined
> >with using pg_upgrade in --link mode, you would be able to perform the
> >flip from the old-server-on-8.4 to the new-server-with-9.6 in a
> >relatively short period of time (on the order of minutes-to-an-hour,
> >potentially).
>
> >>Are there better ways?  (The pipe from current DC to new DC will be 10Gbps.)
> >The above approach would work, but you wouldn't be able to enable
> >checksums on the new server, which is something I'd certainly recommend
> >doing if you're able to.
>
> We'll benchmark it.
>
> > To get page-level checksums, you would need to
> >make sure you initdb the new server with them and then use the newer
> >pg_dump version to dump the 8.4 data out and then into the 9.6 server.
> >This could possibly be done as a pipe, but I'd probably find 1TB of
> >space somewhere and use parallel pg_dump
>
> Is parallel pg_dump available on 8.4, or am I misinterpreting you?

The pg_dump you'll be using is from the version you're upgrading *to*,
so it will support parallel jobs. With an 8.4 server, you'll need to
stop all write traffic before running the pg_dump and you'll have to
specify '--no-synchronized-snapshots' as that's a feature which the 8.4
server doesn't support.

Thanks!

Stephen

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2018-02-25 00:35:43 Re: pg_update to a new machine?
Previous Message jotpe 2018-02-24 18:07:11 Re: extract properties from certificates