Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFViF-00DSgy-6T for pgsql-general@arkaria.postgresql.org; Mon, 25 Nov 2024 09:48:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tFViD-00Dvfi-K2 for pgsql-general@arkaria.postgresql.org; Mon, 25 Nov 2024 09:48:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFViD-00Dvdn-7L for pgsql-general@lists.postgresql.org; Mon, 25 Nov 2024 09:48:57 +0000 Received: from 78-107-237-199.static.corbina.ru ([78.107.237.199] helo=mail.mednm.com) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tFViA-003kWn-E0 for pgsql-general@postgresql.org; Mon, 25 Nov 2024 09:48:56 +0000 Received: from mail.tzirechnoy.ru (unknown [85.143.106.93]) by mail.mednm.com (Postfix) with ESMTPSA id 1DBDF100B37B; Mon, 25 Nov 2024 12:48:52 +0300 (MSK) Received: by mail.tzirechnoy.ru (Postfix, from userid 1000) id 8A5A7A41CC; Mon, 25 Nov 2024 12:48:51 +0300 (MSK) Date: Mon, 25 Nov 2024 12:48:51 +0300 From: Ilya Anfimov To: pgsql-general@lists.postgresql.org, pgsql-general@postgresql.org Subject: Re: Questions on Upgrading PostgreSQL from 15.0 to 15.9 and Setting Up Streaming Replication Message-ID: Mail-Followup-To: Ilya Anfimov , pgsql-general@lists.postgresql.org, pgsql-general@postgresql.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Nov 24, 2024 at 09:35:15PM +0530, Subhash Udata wrote: > Dear PostgreSQL Community, > > I have a production database setup with a primary server and a standby > server. The database is currently running on PostgreSQL 15.0, and I plan > to upgrade both servers to 15.9. > > I have the following questions regarding the upgrade and replication > process: > > 1. Upgrade and Replication Compatibility: > > * My plan is to perform a failover, promote the standby server > (currently 15.0) to primary, and then upgrade the old primary > server to version 15.9. 1) Why do you want to use a switchover first? You can upgrade the standby, then switchover to it. (You could even don't switchover back, when the old primary would be upgraded and synchonized). > * After upgrading the old primary server to version 15.9, I want to > configure it as a standby server and set up streaming replication > with the new primary server, which will still be running version > 15.0. > * Is it possible to establish streaming replication between these > two versions (15.0 as primary and 15.9 as standby)? > 2. Efficient Replication Setup: > > * The production database is around 1TB in size, and creating > replication using pg_basebackup is taking more than 2-3 hours to > complete. > * Is there an alternative method to set up replication without > taking a full backup of the entire cluster but instead using only > the WAL files that have changed on both servers? Well, there are some. pg_rewind is one of those (you should keep all the WAL files be- tween switchover point and now on both servers. Also, maximum one switchover/failover AFAIK. Also, it's a bit fragile nevertheless, bad things could happen if you mix timelines from the very straight scenario of one switchover+pg_rewind on the old prima- ry). Hoewever, I'd usually use rsync+low-level backup protocol https://www.postgresql.org/docs/15/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP This requires some manual commands, writing backup_label and so on -- but looks more straightforward to me. (And yes, rsync uses block-level comparision and transfers only change blocks. setting block-size to 8k in rsync could be beneficial). > > Your guidance and recommendations on these questions will be greatly > appreciated. > > Thank you for your time and support! > > Best regards, > > Subhash