Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 76D9B1337C0C for ; Tue, 19 Apr 2011 05:09:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 09357-06 for ; Tue, 19 Apr 2011 08:09:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f46.google.com (mail-ew0-f46.google.com [209.85.215.46]) by mail.postgresql.org (Postfix) with ESMTP id 93F541337BA6 for ; Tue, 19 Apr 2011 05:09:06 -0300 (ADT) Received: by ewy4 with SMTP id 4so1623575ewy.19 for ; Tue, 19 Apr 2011 01:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=F/sXCOXTBZW8TJaCxIVE3eP6thfKerDmsH2/zSfb5BE=; b=LEQPALdOaNzmYyaaxBDDZPTXWAsERkuX7ze24MmsBvjpl1eSNXcylRpSguNVDtV6w6 Dtvk44aqRY/+YYNxFdJ/gnHFlDjKylV8Covxucv/4FNP5nHmDxsxGvwLGeTpcD4zQkhj 06cPFcIdQ6rdLJTxe5V6gRrebKhTI8Oq9FfTM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=DXdtIzTGKrTyw7Nq/gQQISN7BFeiMc5xDAYRu2ZtU5+Fje/H3xEhuHMFn0u2GfvfTG PTIhjn6DX11YjxHtGLFsz2IzxRoNoxEHJzLrUIwq1HJyC5s3m+4xAZP5JSDMX438trB0 s1QzdT0GKyCavYO9UERBIhOzpBxcD/lZoUA60= MIME-Version: 1.0 Received: by 10.213.8.22 with SMTP id f22mr2533879ebf.138.1303200544280; Tue, 19 Apr 2011 01:09:04 -0700 (PDT) Received: by 10.213.8.136 with HTTP; Tue, 19 Apr 2011 01:09:04 -0700 (PDT) In-Reply-To: <4DAC7205.8080203@kemen.it> References: <4DAC7205.8080203@kemen.it> Date: Tue, 19 Apr 2011 10:09:04 +0200 Message-ID: Subject: Re: Streaming replication: rsync to switchover From: Gerhard Hintermayer To: rd , pgsql-admin Content-Type: multipart/alternative; boundary=000e0ce071fe8351dc04a1410505 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.422 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, FS_REPLICA=3.599, HTML_MESSAGE=0.001, RFC_ABUSE_POST=0.001, SARE_SPEC_REPLICA=0.72 X-Spam-Level: ** X-Archive-Number: 201104/161 X-Sequence-Number: 37342 --000e0ce071fe8351dc04a1410505 Content-Type: text/plain; charset=ISO-8859-1 Hi, I do rsync -a --delete new_primary_server::postgresql-data/ /var/lib/postgresql/9.0/data/ Take care to use -a, I had -r and wondered, why the rsync took so long, despite the data was nearly the same. assuming you have configured rsyncd on the server as: [postgresql-data] uid = postgres path = /var/lib/postgresql/9.0/data comment = PostgreSQL 9.0 data dir exclude = postmaster.log pg_xlog/* postmaster.pid postgresql.conf The exclude might be tunable a litte (the confs eg. are not stored in the datadir anymore on my distro) Always rsync over the existing data dir (of course stop server before) The former master can also be stopped later. When the trigger file is created, the connection to it is closed anyhow. Don't forget to pg_start_backup pg_stop_backup on the new server before/after you do rsync. Gerhard On Mon, Apr 18, 2011 at 7:16 PM, rd wrote: > Hi, > > I've setup streaming replication + file-based log-shipping, with a > hot-standby. > > Everything's good, except I don't know which is the correct way to sync the > once-master db with the newly promoted master after a switchover, > > 1) I shutdown the master and touch the trigger_file on the slave. Now the > slave becomes the master. > 2) On the old-master I create recovery.conf + archive directory for > file-based log-shipping. > 3) I hope I can setup the old-master with a simple rsync, because the > operation could be really fast, being M and S almost identical, but I'm not > sure about the correct way to rsync them: > > a) should I rsync --delete? > b) should I delete the pg_xlog of the old master, before rsyncing? (I'm > wondering what could happen if some of them never made its way to the slave, > that now has become new-master) > c) am I missing something? For example, I've read somewhere that one should > copy pg_control and pg_stat from the old slave to the new slave but it > doesn't make sense to me. > > > thanks for any hint, > > > -- > rudi pettazzi > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > --000e0ce071fe8351dc04a1410505 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, I do rsync -a --delete new_primary_server::postgresql-data/ /var/lib/po= stgresql/9.0/data/

Take care to use -a, I had -r and wondered, why t= he rsync took so long, despite the data was nearly the same.

assumin= g you have configured rsyncd on the server as:

[postgresql-data]
=A0=A0=A0 uid =3D postgres
=A0=A0=A0 path =3D /= var/lib/postgresql/9.0/data
=A0=A0=A0 comment =3D PostgreSQL 9.0 data di= r
=A0=A0=A0 exclude =3D postmaster.log pg_xlog/* postmaster.pid postgres= ql.conf

The exclude might be tunable a litte (the confs eg. are not = stored in the datadir anymore on my distro)
Always rsync over the existing data dir (of course stop server before)
T= he former master can also be stopped later. When the trigger file is create= d, the connection to it is closed anyhow.
Don't forget to pg_start_b= ackup pg_stop_backup on the new server before/after you do rsync.

Gerhard

On Mon, Apr 18, 2011 at 7:16 = PM, rd <rudi= .pettazzi@kemen.it> wrote:
Hi,

I've setup streaming replication + file-based log-shipping, with a hot-= standby.

Everything's good, except I don't know which is the correct way to = sync the once-master db with the newly promoted master after a switchover,<= br>
1) I shutdown the master and touch the trigger_file on the slave. Now the s= lave becomes the master.
2) On the old-master I create recovery.conf + archive directory for file-ba= sed log-shipping.
3) I hope I can setup the old-master with a simple rsync, because the opera= tion could be really fast, being M and S almost identical, but I'm not = sure about the correct way to rsync them:

a) should I rsync --delete?
b) should I delete the pg_xlog of the old master, before rsyncing? (I'm= wondering what could happen if some of them never made its way to the slav= e, that now has become new-master)
c) am I missing something? For example, I've read somewhere that one sh= ould copy pg_control and pg_stat from the old slave to the new slave but it= doesn't make sense to me.


thanks for any hint,


--
rudi pettazzi

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

--000e0ce071fe8351dc04a1410505--