Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j6kio-0007JB-Mg for pgsql-general@arkaria.postgresql.org; Wed, 26 Feb 2020 00:38:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j6kim-0003a0-6D for pgsql-general@arkaria.postgresql.org; Wed, 26 Feb 2020 00:38:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j6kil-0003Zt-L9 for pgsql-general@lists.postgresql.org; Wed, 26 Feb 2020 00:38:39 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j6kie-0008GX-5t for pgsql-general@lists.postgresql.org; Wed, 26 Feb 2020 00:38:38 +0000 Received: by mail-pf1-x443.google.com with SMTP id y5so465793pfb.11 for ; Tue, 25 Feb 2020 16:38:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=I6Ll4pZW+m0JeNatXySmCK/2A1up3jDc+QISxm4ScCQ=; b=u1JzHOsjW8rApNzgaPYEkw06qnsNghCEGNwMO3IXJOAyf9biBYnJ7rqIkDBQzFmKhq /e1YQk8+Cgxwk5IAme+XfxTa6YW/5lZxyv92t3BoNNWMa69++obOtCRfQBTUkOk7lvjQ UfZzhGgoGXqClbzF3xmDXseZ1ol+40ZBStSOPYDMuk8rj9VKt2RBiB0nGJEI+SMdgwcw D0aVZ9gr//ABiDSyyWh0mskB//FARgZAy8NqkMYiuJAu9vLzqF1pagiyoJUEufC7mYko 8LfME76ffiFugi7gPh0hPwz9ictrIBOvaXgiGZNyt83xTmufFpqlEOC8rrJCL2buqmhK Z+SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=I6Ll4pZW+m0JeNatXySmCK/2A1up3jDc+QISxm4ScCQ=; b=JHP0MFtVNxAVKj3jIQzEU+O7MJQpbO+lxtivAldQk2LmfpFT12UxqBjELuXDfEZjQF oW7fmC3YA5bdZ+EeNY19mRBPmdAq9XbeTMglwRiPPlFw0NSE2i7niNG01w59xO1gJXnv n6y4NqkwVCoUXSf9j2fkV8d0WWcySr6bXcYAjF+aAC/oh8ZonaL4STHwNs3pzXDVu9+a dwodfStTgG7I8aDoEoOWo0IRvlnB740F75QyrbT2uak4aIHw47esKE3D2VuYC8aNLrzC N/7dRw8d3wAL30eSJxaaLJ7V6GB/oR80tRRRe07RIvL8XZZGusjiw+nAW4bAP8da29LR JEiQ== X-Gm-Message-State: APjAAAVcFVRroad5Xb/xANE36BXPlqpnKjuWlDXSFSI0357nrlm285GC 8J0wuqQjMJdVYi+AukB6GnKSMZ1zaO0oQm2IMPaJdpOF7M7WHR9hPexTMCrg7UK1Cw1VauykG0g 0fQmTpjt0IwW6uCdtmUwUPK0yft5oViynSjhm0BR997WIZa+47KgfXS1FPkjLuRiMMr0oSVQaFf 5tAsc5TgWfoEXEeLDsRg== X-Google-Smtp-Source: APXvYqxqycSwMJxaFWLiY+Q2ci3NPpdOSFBrEu6DyIt+3A2qEuaFiBdbEZjLyc6ASMqnGLmDIChm0w== X-Received: by 2002:a63:f20a:: with SMTP id v10mr1090734pgh.420.1582677510148; Tue, 25 Feb 2020 16:38:30 -0800 (PST) Received: from osaka.octopusnet (p8608034-ipngn39201marunouchi.tokyo.ocn.ne.jp. [180.46.196.34]) by smtp.gmail.com with ESMTPSA id s23sm262875pjq.17.2020.02.25.16.38.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Feb 2020 16:38:29 -0800 (PST) Subject: Re: Highly academic: local etcd & Patroni Cluster for testing on a single host To: =?UTF-8?Q?Paul_F=c3=b6rster?= , pgsql-general@lists.postgresql.org References: <51854B87-A964-4F64-8EC4-8ABF51A0716E@gmail.com> From: Ian Barwick Message-ID: Date: Wed, 26 Feb 2020 09:38:27 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <51854B87-A964-4F64-8EC4-8ABF51A0716E@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/02/26 0:41, Paul Förster wrote: > Hi, > > I have set up an etcd & Patroni cluster on a single machine for testing purposes as follows: > > /data/pg01a/db as data directory for the first "node" > /data/pg01b/db as data directory for the second "node" > > I have set up Patroni to make each PostgreSQL database cluster archive to its own destination, so they won't interfere with each other. All is well and working fine so far. Failover/Switchover works, they are syncing properly, etc. > > Now: > > Inside /data/pg01a and /data/pg01b I also have a directory ts, i.e. /data/pg01a/ts and /data/pg01b/ts to simulate different filesystems. > > If I do a 'create tablespace' and specify its location, I must of course specify either /data/pg01a/ts or /data/pg01b/ts. > > Files with Tables get created as usual, but since it's a replication (sync, by the way), the other tablespace directory will not hold any files, but instead, the replica uses the same files as does the master. > > Is there any way around that, i.e. make the replica use its own files? I found a way to make each archive destination individual despite Patroni, but I can't seem to find a way to do something similar to the tablespaces. Even correcting the symlinks in ${PGDATA}/pg_tblspc manually (and then restart) does not work. > > The explanation is simple: the location is stored inside the database cluster information and is per definition the same across all nodes. So, if 'a' is master and I do "create tablespace test location '/data/pg01a/ts'" it creates files there with the replica 'b' using the *same* destination. > > Still, is there a way to make each node store that information individually? I know, this is highly academic but I only have a single host to do etcd & Patroni cluster experiments on. Assuming the standby/replica is created using pg_basebackup, you can use the -T/--tablespace-mapping option to remap the tablespace directories. Regards Ian Barwick -- Ian Barwick https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services