Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMdUq-0004VK-4r for pgsql-general@arkaria.postgresql.org; Sat, 26 May 2018 18:00:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fMdUk-0004XG-Kd for pgsql-general@arkaria.postgresql.org; Sat, 26 May 2018 18:00:46 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMdUi-0004X6-DQ for pgsql-general@lists.postgresql.org; Sat, 26 May 2018 18:00:46 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMdUa-0003z1-TD for pgsql-general@postgresql.org; Sat, 26 May 2018 18:00:43 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2E59721C38; Sat, 26 May 2018 14:00:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 26 May 2018 14:00:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=fFdW5BJNq62Hzz9+XYme4QLzq49Di 5hjZRhbKEbUVzE=; b=bnZGwMpKEdasafmxgUJ9hb7xjnhfGcwvQYU9o0GwstyLh S/EGztDKGedGIhqh1ZGdbjqBbcf4AEC+SbW4A0jcPDIlRkoaFmdQ4rIkYE0CVh7O 2fGSsrsCcraMAIrJNeDwagJqJk3AnrOoJDaqU1+f00vA/rVnK0z4gV1xCvzXnxHL DQOPQ/eSmuwLD2Ns9drYG8bXI9tf0osDOxPrIxMHfcR8ITc3j4hAjYbs+Gqy6k30 rnLgSQ0WeLT/sy0vZAY4z35uADCFRnVqB3HoIACzBbogLKKTAJEgt1hy0Gwu6y7c NuzMp243GD49HPOKJLt3SxmcYjlPQ5mFyMpP8Anew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=fFdW5B JNq62Hzz9+XYme4QLzq49Di5hjZRhbKEbUVzE=; b=COIcvDmm2XKKCUeomx7U4d r6ekjJ8t7P98vkYxYHwJwmcmjblB+p3Dvpb8WgqX0gj2d7tPa/LJhr7ptp/6y7OP bYawD5fQGFvqRBsXZoCKDpybmVF9XjFKIMVTYkIoQqmnQfGyLE2x7EEnmPNbQQ2O Mlthb5qqDgTI78w1X/o0Ku38N00QfYdnisPLenK4cY5CTCGl9Jr9xV0/9XBS2Ur2 h8fhC9u0Qdhcy2QjeUrjHc1vcPfY8VP5tqU1cYrDv1kOrp7ua6JuMuey+C+ZCs4y Jvyu+qoOC3oKG0rKJEV1Tqh8kl/CydZuoos6jj4SyCu2/Gc6xB6sTO7Zv+Gy2jRg == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.2] (unknown [71.212.135.74]) by mail.messagingengine.com (Postfix) with ESMTPA id 88FD6E471F; Sat, 26 May 2018 14:00:34 -0400 (EDT) Subject: Re: Fast logical replication jump start with PG 10 To: Olivier Gautherot Cc: pgsql-general@postgresql.org References: <729c1726-2e61-f03f-fe7e-c1dcf3f59e85@aklaver.com> <239dddd5-aa45-a7fe-b35a-085b978f8bd6@aklaver.com> From: Adrian Klaver Message-ID: Date: Sat, 26 May 2018 11:00:33 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/26/2018 06:23 AM, Olivier Gautherot wrote: > Hi Adrian! > > On Sat, May 26, 2018 at 12:11 AM, Adrian Klaver > > wrote: > > On 05/25/2018 06:35 PM, Olivier Gautherot wrote: > > Hi Adrian, thanks for your reply. Here is the clarification. > > 1) It is indeed a pg_upgrade from 9.2 to 10.4. Depending on the > test machine, it runs in between 15 and 20 minutes for just over > 100GB. I can negotiate this time with our customer. The vacuum > process took another 5 to 7 minutes. This this what I was > referring to with the 30 minutes (point 3 in your questions) > > 2) After pg_upgrade, I published the tables on the database (in > the sense "CREATE DATABASE") and subscribed to this publication > on the second server (logical replication). The data copy > processed started immediately and took around 1 hour. I then > loaded the indexes, what took > another 2h20m. At that point the > active-passive cluster was ready to go. > > > The index creation was done on the replicated machine I presume, > using what command? > > > The sequence on the replicated machine was (pseudo-code to simplify the > syntax): > - pg_dump --section=pre-data -h master_machine master_database | psql -h > replication_machine replication_database > # This took seconds, "pre-data" discards the indexes > > - psql -h replication_machine -c "CREATE SUBSCRIPTION mysub CONNECTION > "..." PUBLICATION mypub;" replication_database > # This took about 1 hour for the initial sync > > - pg_dump --section=post-data -h master_machine master_database | psql > -h replication_machine replication_database > # This took 2h20m to load the various indexes > > This sequence follows the recommendation of section 14.4.3 in > https://www.postgresql.org/docs/10/static/populate.html . If I stick to > streaming as we do today (e.g. pg_upgrade and then rsync to the > replication server), I can be ready in about 1 hour (more acceptable for > the customer). > Just realized that by setting up the streaming as above you are already doing basically the same thing as I suggested in my previous post. Streaming and logical replication can exist at the same time: https://www.postgresql.org/docs/10/static/logical-replication.html "Logical replication is a method of replicating data objects and their changes, based upon their replication identity (usually a primary key). We use the term logical in contrast to physical replication, which uses exact block addresses and byte-by-byte replication. PostgreSQL supports both mechanisms concurrently, see Chapter 26. Logical replication allows fine-grained control over both data replication and security." So you could set up the logical replication after the streaming is done using the copy_data=false clause and been done in a relatively short period of time. At that point you could decide whether to keep the streaming running or not. -- Adrian Klaver adrian.klaver@aklaver.com