Re: Setting up streaming replication with new server as master? - Mailing list pgsql-admin

From Stephen Frost
Subject Re: Setting up streaming replication with new server as master?
Date
Msg-id 20160205202729.GZ3331@tamriel.snowman.net
Whole thread Raw
In response to Setting up streaming replication with new server as master?  (Dave Johansen <davejohansen@gmail.com>)
Responses Re: Setting up streaming replication with new server as master?
List pgsql-admin
* Dave Johansen (davejohansen@gmail.com) wrote:
> We would like to start using streaming replication, but the catch is that
> we want the new server to be the master. The server is still in use and
> receiving new data, so we would like to minimize down time, and I would
> prefer to be able to copy all, or at least the large majority of the data
> to the new server before doing the final sync to make it the master.
>
> Will pg_basebackup work?

Partially.

> Can it be run multiple times? (i.e. start it now to copy all of the data
> over the weekend and then a second time on Monday before doing the switch)

No.

> Do I need to manually copy the files with rsync?

I wouldn't suggest rsync, unless you do it when the database is shut
down and you checksum the files.

> What's the recommended way to handle this?

I'd suggest pg_basebackup and then set up the new system as a follower
of the primary using a recovery.conf.  When you shut down the current
server, all of the WAL changes should be streamed over to the new server
and then you can trigger it to become a read/write master, once it has
the last of the WAL from the current server, and then you can just
redirect new connections to it, or flip it into place by giving it the
new IP, etc.

If you want to do actual incremental backups as you were thinking
pg_basebackup might do, you could use pgBackRest, which does support
that.

Thanks!

Stephen

Attachment

pgsql-admin by date:

Previous
From: Dave Johansen
Date:
Subject: Setting up streaming replication with new server as master?
Next
From: Dave Johansen
Date:
Subject: Re: Setting up streaming replication with new server as master?