From: Paul Förster <paul.foerster@gmail.com>
To: Lu, Dan <Dan.Lu@sig.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: pg_upgrade question
Date: Tue, 22 Dec 2020 09:20:15 +0100
Message-ID: <DCAE7589-724F-46BD-9225-B80C7F1CA99E@gmail.com> (raw)
In-Reply-To: <MN2PR19MB3613CC6B528CC555B46FDD9894C00@MN2PR19MB3613.namprd19.prod.outlook.com>
References: <MN2PR19MB3613CC6B528CC555B46FDD9894C00@MN2PR19MB3613.namprd19.prod.outlook.com>
Hi Dan,
> I am trying to find out if there is any step by step instruction to reconcile old data dir and upgraded data dir after using “—link” option to do an upgrade.
>
> I ran this to do an upgrade from 11.5 to 12.1: pg_upgrade -d /hostname/pg/dev115/data -D /hostname/pg/dev121upg/data --link -b /pgdbadevbal800/pg/PostgreSQL-11.5/bin -B /pgdbadevbal800/pg/PostgreSQL-12.1/bin -p 1432 -P 2432 –v
>
> postgresdbad:dev115:pgdbadevbal800:> pwd
> /hostname/pg
>
> postgresdbad:dev115:pgdbadevbal800:> du -sh dev121upg
> 2.3G dev121upg
>
> postgresdbad:dev115:pgdbadevbal800:> du -sh dev115
> 22G dev115
>
> My goal is to be able to do an in place upgrade from 11.5 to 12.1 using the same data dir “/hostname/pg/dev115/data”. Without the “—link” option I need to double up the space usage for the instance. What is the easiest way to accomplish this task?
>
> Thanks so much for your help.
after a successful upgrade, you may delete the dev115 directory and move the dev121upg directory in its place. That's how I usually do it. Something like this example:
(DB = cluster name)
/data/pg/DB/db <= PGDATA old
/data/pg/DB/dbnew <= PGDATA new, do the initdb here!
initdb -k -D /data/pg/DB/dbnew ...
pg_upgrade -d /data/pg/DB/db -D /data/pg/DB/dbnew ...
pg_ctl -D /data/pg/DB/dbnew stop
rm -rf /data/pg/DB/db
mv /data/pg/DB/dbnew /data/pg/DB/db
pg_ctl -D /data/pg/DB/db start
Your milage may vary. Use at your own risk. ;-)
If you shut down a PostgreSQL cluster properly, you can then easily move PGDATA to virtually any place you want and start it there because PostgreSQL doesn't keep references to absolute paths anywhere.
Cheers,
Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: paul.foerster@gmail.com, Dan.Lu@sig.com
Subject: Re: pg_upgrade question
In-Reply-To: <DCAE7589-724F-46BD-9225-B80C7F1CA99E@gmail.com>
References: <MN2PR19MB3613CC6B528CC555B46FDD9894C00@MN2PR19MB3613.namprd19.prod.outlook.com> <DCAE7589-724F-46BD-9225-B80C7F1CA99E@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox