I have a kubernetes cluster running an app. Part of the cluster is a postgresql pod, currently running version 12.4. Unfortunately, I discovered that I need to upgrade the postgresql version 13. Here i have delete my pod having version 12 then creating a new postgres pod with new image version 13. while pod create getting an error (The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.1 (Debian 13.1-1.pgdg100+1) can anyone help me to solve this issue.
1 Answers
With kubernetes I believe the storage is persistent external to the pod and so by deleting the version 12 pod and replacing with version 13 you have basically performed an upgrade but without considering your data.
PostgreSQL major versions are not compatible and you should not expect to open a version 12 cluster with version 13 binaries:
For major releases of PostgreSQL, the internal data storage format is subject to change, thus complicating upgrades. The traditional method for moving data to a new major version is to dump and reload the database, though this can be slow. A faster method is pg_upgrade. Replication methods are also available, as discussed below. (If you are using a pre-packaged version of PostgreSQL, it may provide scripts to assist with major version upgrades. Consult the package-level documentation for details.)
What would I do? I would put the version 12 pod back to restore service and read the upgrade docs here: https://www.postgresql.org/docs/13/upgrading.html
Either use pg_upgrade or take an export/import approach using pg_dump (export your data - upgrade pod - create a new data directory - reimport your data). However the best method for you will depend on your data, allowed outage time, extensions etc....

- 191
- 6
-
when i have run pd_dump command it give permission error.if it possible can you sharing these step with me..!! – Kube_Charm Feb 05 '21 at 05:32
-
OK - so you're taking the export from pg12/import to pg13 approach which is sound. But we would need more detail to help with the pg_dump issue - some context, the exact error message. As it looks like you've moved on from the original context of the question "Why won't pg13 start?", could you mark it complete and raise a new question for the subsequent issue - that will help other others searching the site for specific issues? We'll be happy to help more then. – smbennett1974 Feb 05 '21 at 07:27