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.89) (envelope-from ) id 1htr51-0004Jg-Ia for pgsql-general@arkaria.postgresql.org; Sat, 03 Aug 2019 10:16:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1htr4z-0007Yx-R9 for pgsql-general@arkaria.postgresql.org; Sat, 03 Aug 2019 10:16:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htr4z-0007Yj-HB for pgsql-general@lists.postgresql.org; Sat, 03 Aug 2019 10:16:01 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htr4x-00033C-H4 for pgsql-general@lists.postgresql.org; Sat, 03 Aug 2019 10:16:01 +0000 Received: by mail-ed1-x531.google.com with SMTP id i11so11050381edq.0 for ; Sat, 03 Aug 2019 03:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=olUOh+NT2nAurjMsiH1JZjPNsTvAukjV4BrcPVG3v0c=; b=fzNUSvmd5J1keFsGf5fZdM4LQeX0EO35tze1LEdTeg3A8Y3ysG1LRllf/TUcaeWab6 MTAMO54s6Iuy7Uym452Wup/BvLshSyOk3Cdj0ieSgkBl7XNTCzguItkmAQeGAxQUod5W FTeC1VkW8bMnHZ366Hwt4kXzkSoP38F5eGb37dIjLlDLzkaGFvWtghjbPuCbtJaQ27Y/ eLfd3WJlTa2rLC3xVNSEWm2LXW+k2at90qaW+wXjOeIaIAItiMkcdL97HrDft/t71L/c XWms6FkGRdrM7F9kL2Cb5uvrK2xFn8JXAdLFfdcOkqzP1mtNHT/ZeTByyrSwnKwdrTdZ 4HWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=olUOh+NT2nAurjMsiH1JZjPNsTvAukjV4BrcPVG3v0c=; b=qvOe2OkCkFQpHgIVdx7umv14Ep1Kdg2OEP8krFyAIsuf1u6xtgtlTHl4c2uxiCrj/s p5AB0hGKaiDLdJ1clf1A+DcoXoLyXL0OemI/3LZ8AEZoWuopzEe0reV8ptYsUipAcdW3 fy5Cy4Py9rQs4hfUpesUn0g8UMV9865PU6bt4e+k8yyOTLpdnrCx6Y8Dax7OdBDfVNOe t5RYfL5m6pQdmlGQCJD6gEV8hpPkz/9/1WTMCddRxvMRGbR3zvKdeRYJfTfwX39xB465 CNV8beIvOXn3MZuE+zzmWf+Rg5ZhD2jeXJn9mKv395NjQdBLHR46vHTAF5hn2lr9lDbE 2TqQ== X-Gm-Message-State: APjAAAVrfozC0dPFFH4BLJGaNvdR5kRjr+2GlHKIfsgXaDR0tozrpvZb mBgZ6JK1IdJtNDiSdaNWDoY= X-Google-Smtp-Source: APXvYqx5afOOFfJWW1bgwZjpotA4JJfQw/QQ/8Sm0Qg1GwMVCOf3LcyscGZM+1uYM+kVd+6wUm4TSw== X-Received: by 2002:a17:906:1e04:: with SMTP id g4mr14602188ejj.48.1564827358386; Sat, 03 Aug 2019 03:15:58 -0700 (PDT) Received: from hollewijn.internal (217-19-30-105.dsl.cambrium.nl. [217.19.30.105]) by smtp.gmail.com with ESMTPSA id c24sm13572085ejb.33.2019.08.03.03.15.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 03:15:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: adding more space to the existing server From: Alban Hertroys In-Reply-To: Date: Sat, 3 Aug 2019 12:15:56 +0200 Cc: Adrian Klaver , "pgsql-general@lists.postgresql.org" , pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: <13358DF7-5700-44A2-A86B-2A3721AA9650@gmail.com> References: To: Julie Nishimura X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On 2 Aug 2019, at 21:45, Julie Nishimura = wrote: > 1) We use streaming replication, and due to hardware limitation, we = cannot add more drives to the existing host. That is why we thought by = breaking the existing streaming replication (from a->b), instead of = currently identical standby (b), we can introduce twice larger host, = then start the replication to the newly larger host, and when it is = caught up, break it again. Then break rep again, make modification to = 'a" host, making it larger, then replicate b->a. After it is caught up, = break the rep again, switch master->standby (if necessary). Let=E2=80=99s be clear, I=E2=80=99m in no way an expert on replication. = In fact, I=E2=80=99ve only done (streaming) replication once and I = managed to mess that up in a minor way (disabled the wrong service = during failover, so data still went to the database I was attempting to = replace for, like, 15 minutes). > 2) I am not sure about the time, but it is understood it is required 2 = full replication cycles, and might be up to 2 weeks with no standby = situation No standby situation? Murphy is probably just waiting for that to = strike=E2=80=A6 I recall a fairly recent story on the FreeBSD ML about someone on Malta = doing a migration of a couple dozen terabytes from her main server = (because of some failing disks in her RAID set) using her backup server = to move data around (with backups removed to make room), when, due to an = accident outside the building, an aerial 10KV power line hit another = power line in the ground, causing a fire in one UPS and frying the other = one. Losing power at that point meant that the file systems (ZFS) on = both servers ended up in an unrecoverable state with no backups. It = didn=E2=80=99t help that the UPS=E2=80=99s were at the bottom of the = rack, with the heat and smoke going up into the servers. What are the = chances, right? (And then it turned out that it is really hard to try to = recover data from a ZFS file system in such a state, which is what her = actual inquiry was about) I would definitely prefer to add a 3rd machine into the mix, even if it = were just a temporary machine - a rental perhaps? =46rom there, I=E2=80=99m certain Adrian knows more about replication = than I do. I=E2=80=99d go with the approach he suggested. > 4) by pg_basebackup and restore >=20 > As of now, we are thinking about possibly other solutions, as of = splitting existing 37 databases on the cluster into 2 hosts with their = own standbys. This solution requires breaking up existing replication as = well. Can you please point me to some document which lists all steps = describing breaking up the existing replication properly? we are using = 9.6 postgres I=E2=80=99m going to assume that you will have data coming in while this = split is taking place and that you therefore cannot offline the entire = set of databases for as long as this takes. If not, that would probably = allow for a simpler (faster) scenario. I think the easiest for this scenario would be to add two more machines = (c and d) and replicate them off the current setup. You want that to = happen as parallel as possible, so perhaps replicate c off a and d off = b. If you aren=E2=80=99t already using =E2=80=9Creplication slots=E2=80=9D, = I found that to make things both easier to understand and more reliable. = You can query their status, for one thing. Those replicas will take extra time of course (about double) because = you=E2=80=99re replicating twice what you need, but I don=E2=80=99t = think you can replicate parts of a cluster with your setup unless you go = for a different replication approach (I think per database replication = requires statement level replication?). After that, decouple both sets into: a =E2=80=94> b (your current machine) c =E2=80=94> d (the new ones) (Although any order should be fine, really, as long as they have caught = up.) At that point I would probably (temporarily) pause replication in at = least one set and create a backup of that. This is the point to start removing superfluous databases from a and c = (so that a+c make up the complete set again). After verifying that no databases are missing, unpause replication. If instead you find that you accidentally removed a database from both a = and c, you still have replicas to recover it from. And the backups, of = course, but that will not contain the data that came in after = replication was paused. I do hope the remaining 3% disk space is enough to cover all that, = though... Regards, Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest.