Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1epbSi-0002Z6-6U for pgsql-general@arkaria.postgresql.org; Sat, 24 Feb 2018 15:10:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1epbSh-0005NR-0F for pgsql-general@arkaria.postgresql.org; Sat, 24 Feb 2018 15:10:07 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1epbSg-0005My-P1 for pgsql-general@lists.postgresql.org; Sat, 24 Feb 2018 15:10:06 +0000 Received: from eastrmfepo201.cox.net ([68.230.241.216]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1epbSc-00015g-Hx for pgsql-general@lists.postgresql.org; Sat, 24 Feb 2018 15:10:06 +0000 Received: from eastrmimpo109.cox.net ([68.230.241.222]) by eastrmfepo201.cox.net (InterMail vM.8.01.05.28 201-2260-151-171-20160122) with ESMTP id <20180224150957.PKYG4103.eastrmfepo201.cox.net@eastrmimpo109.cox.net> for ; Sat, 24 Feb 2018 10:09:57 -0500 Received: from [192.168.1.10] ([70.171.109.83]) by eastrmimpo109.cox.net with cox id Ef9w1x0101o04Vy01f9x44; Sat, 24 Feb 2018 10:09:57 -0500 X-Authority-Analysis: v=2.2 cv=dbrw5Tfe c=1 sm=1 tr=0 a=uCHdjGDeLqaieW9t8IbZ6A==:117 a=uCHdjGDeLqaieW9t8IbZ6A==:17 a=x7bEGLp0ZPQA:10 a=T11QR6bd6vIA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=kviXuzpPAAAA:8 a=k7dmRdHJF7S1yACKOjkA:9 a=QEXdDO2ut3YA:10 a=CtQ8Z5sHAAAA:8 a=ICJ2ya4u5gx9ZgBsBEsA:9 a=D10xK9fWjZ5xarmK:21 a=_W_S_7VecoQA:10 a=frz4AuCg-hUA:10 a=qrIFiuKZe2vaD64auk6j:22 a=kjLbjC78xK42ZYGrAcPY:22 X-CM-Score: 0.00 Authentication-Results: cox.net; auth=pass (PLAIN) smtp.auth=ron.l.johnson@cox.net Subject: Re: pg_update to a new machine? To: pgsql-general@lists.postgresql.org References: <09489f15-b756-9e6d-c081-a8cdf0f9b483@cox.net> From: Ron Johnson Message-ID: <74ef8c30-0db7-84ad-b04e-1975fe2977e4@cox.net> Date: Sat, 24 Feb 2018 09:09:56 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------D2AB0E74B34CC36A52761FD5" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------D2AB0E74B34CC36A52761FD5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 02/24/2018 08:18 AM, Stephen Frost wrote: > Greetings, > > * Ron Johnson (ron.l.johnson@cox.net) wrote: >> The 2.8TB database must be moved to a new server in a new Data Center, and >> upgraded from 8.4.17 to 9.6.6 >> >> Will this work? >> >> pg_upgrade >> --old-datadir "CURSERVER://var/lib/pgsql/data" >> --new-datadir "NEWSERVER://var/lib/pgsql/data" >> --old-bindir "CURSERVER://usr/bin" >> --new-bindir "NEWSERVER://usr/bin" > No, you can't specify hostnames to pg_upgrade. I didn't think it would work, but it was worth an ask... > You could possibly use > NFS or something else to be able to facilitate the above. > >> Or must I: >> 1. temporarily allocate 3TB of scratch space on the new server, > If you use --link mode during pg_upgrade, you don't actually need to > allocate that scratch space on the new server. I'll look into that. >> 2. install 8.4 on the new server, >> 3. install 9.6.6 on the new server, > For pg_upgrade, you do need both versions installed on the server you're > running pg_upgrade on, yes. Please be sure to use the latest minor > version of each major version if you go that route. > >> 2. rsync CURSERVER://var/lib/pgsql/data to >> NEWSERVER://var/lib/pgsql/8.4/data, and then > You can only perform this rsync with the database shut down, just to be > clear. If you wanted to pull the data across with the database online, > you'd need to set up an archive_command and use a tool which works with > 8.4 to perform an online backup (such as pgBackRest). To set up log shipping on 8.4, I do this, which works well: select pg_start_backup('some_meaningful_tag'); nohup rsync -avz /var/lib/pgsql/data/* postgres@${DESTIP}:/var/lib/pgsql/data/ & select pg_stop_backup(); Would I, essentially (or in fact), have to set up log shipping from old to new? >> 3. pg_upgrade? > If you perform an online backup and then capture all of the WAL using > archive_command, you could stand up a warm standby with 8.4 on the new > server which is replaying the WAL as it's generated on the primary by > specifying a restore_command on the new server. I guess that means "yes, set up log shipping"? > Doing this, combined > with using pg_upgrade in --link mode, you would be able to perform the > flip from the old-server-on-8.4 to the new-server-with-9.6 in a > relatively short period of time (on the order of minutes-to-an-hour, > potentially). >> Are there better ways?  (The pipe from current DC to new DC will be 10Gbps.) > The above approach would work, but you wouldn't be able to enable > checksums on the new server, which is something I'd certainly recommend > doing if you're able to. We'll benchmark it. > To get page-level checksums, you would need to > make sure you initdb the new server with them and then use the newer > pg_dump version to dump the 8.4 data out and then into the 9.6 server. > This could possibly be done as a pipe, but I'd probably find 1TB of > space somewhere and use parallel pg_dump Is parallel pg_dump available on 8.4, or am I misinterpreting you? > to extract the data out and > into a compressed logical dump and then parallel pg_restore to pull it > into the new server. This would also re-check all constraints in the > system and rebuild all indexes, but would naturally require more > downtime. > > Thanks! > > Stephen -- Angular momentum makes the world go 'round. --------------D2AB0E74B34CC36A52761FD5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 02/24/2018 08:18 AM, Stephen Frost wrote:
Greetings,

* Ron Johnson (ron.l.johnson@cox.net) wrote:
The 2.8TB database must be moved to a new server in a new Data Center, and
upgraded from 8.4.17 to 9.6.6

Will this work?

pg_upgrade
        --old-datadir "CURSERVER://var/lib/pgsql/data"
        --new-datadir "NEWSERVER://var/lib/pgsql/data"
        --old-bindir "CURSERVER://usr/bin"
        --new-bindir "NEWSERVER://usr/bin"
No, you can't specify hostnames to pg_upgrade.  

I didn't think it would work, but it was worth an ask...

You could possibly use
NFS or something else to be able to facilitate the above.

Or must I:
1. temporarily allocate 3TB of scratch space on the new server,
If you use --link mode during pg_upgrade, you don't actually need to
allocate that scratch space on the new server.

I'll look into that.

2. install 8.4 on the new server,
3. install 9.6.6 on the new server,
For pg_upgrade, you do need both versions installed on the server you're
running pg_upgrade on, yes.  Please be sure to use the latest minor
version of each major version if you go that route.

2. rsync CURSERVER://var/lib/pgsql/data to
NEWSERVER://var/lib/pgsql/8.4/data, and then
You can only perform this rsync with the database shut down, just to be
clear.  If you wanted to pull the data across with the database online,
you'd need to set up an archive_command and use a tool which works with
8.4 to perform an online backup (such as pgBackRest).

To set up log shipping on 8.4, I do this, which works well:

select pg_start_backup('some_meaningful_tag');
nohup rsync -avz /var/lib/pgsql/data/* postgres@${DESTIP}:/var/lib/pgsql/data/ &
select pg_stop_backup();

Would I, essentially (or in fact), have to set up log shipping from old to new?

3. pg_upgrade?
If you perform an online backup and then capture all of the WAL using
archive_command, you could stand up a warm standby with 8.4 on the new
server which is replaying the WAL as it's generated on the primary by
specifying a restore_command on the new server.

I guess that means "yes, set up log shipping"?

  Doing this, combined
with using pg_upgrade in --link mode, you would be able to perform the
flip from the old-server-on-8.4 to the new-server-with-9.6 in a
relatively short period of time (on the order of minutes-to-an-hour,
potentially).


Are there better ways?  (The pipe from current DC to new DC will be 10Gbps.)
The above approach would work, but you wouldn't be able to enable
checksums on the new server, which is something I'd certainly recommend
doing if you're able to.

We'll benchmark it.

  To get page-level checksums, you would need to
make sure you initdb the new server with them and then use the newer
pg_dump version to dump the 8.4 data out and then into the 9.6 server.
This could possibly be done as a pipe, but I'd probably find 1TB of
space somewhere and use parallel pg_dump

Is parallel pg_dump available on 8.4, or am I misinterpreting you?

 to extract the data out and
into a compressed logical dump and then parallel pg_restore to pull it
into the new server.  This would also re-check all constraints in the
system and rebuild all indexes, but would naturally require more
downtime.

Thanks!

Stephen


--
Angular momentum makes the world go 'round.
--------------D2AB0E74B34CC36A52761FD5--