Re: Highly academic: local etcd & Patroni Cluster for testing on a single host

From: Paul Förster <paul(dot)foerster(at)gmail(dot)com>
To: Ian Barwick <ian(dot)barwick(at)2ndquadrant(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Highly academic: local etcd & Patroni Cluster for testing on a single host
Date: 2020-02-26 07:55:29
Message-ID: 4F8DF27C-E82A-4CBC-B06E-AD4FCD3E66FF@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Ian,

> On 26. Feb, 2020, at 01:38, Ian Barwick <ian(dot)barwick(at)2ndquadrant(dot)com> wrote:
>
> Assuming the standby/replica is created using pg_basebackup, you can use the
> -T/--tablespace-mapping option to remap the tablespace directories.

no, with Patroni, replicas are always initiated by Patroni. Patroni copies the whole PGDATA including everything (postgresql.conf, etc.) in it to the replica site. When launching Patroni for the first time, all you need is its yaml configuration file and an empty PGDATA. It then will copy the whole master's PGDATA as is, launch the replica database cluster and start replication.

Even if Patroni uses pg_basebackup internally (which I assume it does), there is no way to pass parameters to it.

Then you can stop the Patroni process on the replica site which in turn takes the replica database cluster down, make some configuration changes and launch it again. You can of course only make changes to things which don't get replicated all over again or are managed by Patroni itself. This is, how I set up individual archive destinations for each replication member because the initial archive destination of course is replicated, and thus identical, when Patroni builds the replica database cluster.

Tablespace mapping just creates the links to the directories in ${PGDATA}/pg_tblspc to a different location. And since pg_basebackup isn't used, there is no way to do that. But I can do that by hand. That is not the problem.

The problem is that PostgreSQL keeps the tablespace location inside the database and not in some config file. If the latter would be the case then I could just as well set it individually per node as I can with the archive destination.

So, the tablespace location is always /data/pg01a/ts, even on the replica site where it should be /data/pg01b/ts. Hence, on my local cluster, the replica site 'b' always uses the tablespace directory (and thus the files) of the master 'a'.

Cheers,
Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Kukushkin 2020-02-26 08:19:24 Re: Highly academic: local etcd & Patroni Cluster for testing on a single host
Previous Message Thomas Kellerer 2020-02-26 06:25:50 Re: Backup & Restore