-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bitnami/postgresql] Upgrade postgres 11 to 12 #8025
Comments
Hi @qdupuy I recommend to upgrade your release updating the image to the latest 12 version and also enabling the "diagnostic mode", find more info about this mode below: This way, you can entere into the PostgreSQL 12 container and upgrade the database schema. Once you complete the schema upgrade, you can upgrade your Helm release again but this time disabling the diagnostic mode. |
I've already tried this mode and it still doesn't work |
Could you please share (step by step) the exact command you're using? I'd like to reproduce your exact issue in my local environment. Thanks in advance. |
Create a postgres 12 instance, then I take the version 13 and I launch pg_upgrade by putting the pods with "sleep infinity" so that it does not crash |
Hi @qdupuy Please provide as many details as possible. I know it's a pain to describe all the environment you're using but the more information I have, the more helpful I can be:
|
Hello, The scheme I want to make: Migrate to version 12 and then to 13 starting from version 11 The last helm chart was used. Basically, there was no values.yaml file and I put one in to configure the postgres as I wanted Yes, the database is populated. This is the command I typed when I wanted to do the 'pg_upgrade' command :
|
Hi @qdupuy Here's what I did trying to reproduce the issue. I hope it's useful for you:
$ helm install postgresql bitnami/postgresql --set image.tag=11.13.0-debian-10-r89
(...)
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
postgresql-postgresql-0 1/1 Running 0 64s
$ kubectl exec -it postgresql-postgresql-0 -- bash
I have no name!@postgresql-postgresql-0:/$ postgres --version
postgres (PostgreSQL) 11.13
I have no name!@postgresql-postgresql-0:/$ PGPASSWORD=$POSTGRES_PASSWORD psql --host 127.0.0.1 -U postgres -d postgres -p 5432
postgres=# CREATE TABLE IF NOT EXISTS app_user (
postgres(# username varchar(45) NOT NULL,
postgres(# password varchar(450) NOT NULL,
postgres(# enabled integer NOT NULL DEFAULT '1',
postgres(# PRIMARY KEY (username)
postgres(# );
CREATE TABLE
postgres=# exit Upgrade to $ export POSTGRES_PASSWORD=$(kubectl get secret --namespace default postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
$ helm upgrade postgresql bitnami/postgresql \
--set image.tag=12.8.0-debian-10-r90 \
--set containerSecurityContext.runAsUser=0 \
--set diagnosticMode.enabled=true \
--set postgresqlPassword=$POSTGRESQL_PASSWORD
(...)
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
postgresql-postgresql-0 1/1 Running 0 38s
$ kubectl exec -it postgresql-postgresql-0 -- bash
root@postgresql-postgresql-0:/# postgres --version
postgres (PostgreSQL) 12.8
root@postgresql-postgresql-0:/# . /opt/bitnami/scripts/libos.sh
root@postgresql-postgresql-0:/# ensure_group_exists postgres -i 1001
root@postgresql-postgresql-0:/# ensure_user_exists postgres -i 1001 -g postgres
root@postgresql-postgresql-0:/tmp# mv /bitnami/postgresql/data /bitnami/postgresql/olddata
root@postgresql-postgresql-0:/tmp# mkdir -p /bitnami/postgresql/data mkdir -p /bitnami/postgresql/oldbin
root@postgresql-postgresql-0:/tmp# chown -R postgres:postgres /bitnami/postgresql/data /bitnami/postgresql/olddata
root@postgresql-postgresql-0:/# cd /tmp/
root@postgresql-postgresql-0:/# curl --remote-name --silent https://downloads.bitnami.com/files/stacksmith/postgresql-11.13.0-14-linux-amd64-debian-10.tar.gz
root@postgresql-postgresql-0:/# tar --extract --directory /bitnami/postgresql/oldbin/ --file postgresql-11.13.0-14-linux-amd64-debian-10.tar.gz --strip-components=4 postgresql-11.13.0-14-linux-amd64-debian-10/files/postgresql/bin
root@postgresql-postgresql-0:/tmp# gosu postgres initdb -E UTF8 -D /bitnami/postgresql/data -U postgres
(...)
root@postgresql-postgresql-0:/tmp# gosu postgres pg_upgrade -c -b /bitnami/postgresql/oldbin -B /opt/bitnami/postgresql/bin -d /bitnami/postgresql/olddata -D /bitnami/postgresql/data
(...) |
We are having the same issue but not using helm, how can we set "diagnosticMode" without helm as when I change the image to be 12 for example the pod just goes into a CrashLoop due to
|
Thank you, however, in the meantime I have mounted another instance instead of doing an upgrade. I think it's a pity that this kind of handling is not in the documentation. |
@qdupuy - do you mind listing the steps which you took? :) |
I'm in a Kubernetes environment. However, I couldn't do what he said due to time constraints, I had to deliver to my client quickly. So I created a postgres 13 instance next to it and did a pg_dumpall to integrate it with the new instance |
Hi everyone, Please note that you're trying to use In my previous response, I shared some steps about how to try to reproduce having an environment similar to the one expected by |
@juan131 - thanks for the reply, if this were a production k8s environment with TB of data would you have any recommendation for the upgrade aside from |
Hi @robbo10, I'd try to follow these steps:
Does it make sense? |
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback. |
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary. |
Hello, when I try to run the commands to do an upgrade I'm having an issue with passwords error? I really don't understand why this is coming up when my yaml file is using postgresqlPassword?
A little more contact, I'm currently working on upgrades from 10.16.1 of helm chart version to the latest helm chart version 11.8.1 in order to upgrade the postgres application to version 14.5.0. One of the applications I support requires the newest version of Postgres to be installed but running into all kinds of issues upgrading. I did try dumping the backup deploying the newer version and restoring the backup to the new instance but ran into an issue with my pods connecting to the new database now... trying this method to see if this works but already running into problems with this weird password error and makes no sense. |
I did not try, but this may help: https://github.com/tianon/docker-postgres-upgrade |
Hi @juan131 In your steps, where can I find the files for postgresql 14 and 15? I'm trying to upgrade from 14 to 15
Also there's no curl command in the pod. |
We removed curl for security reasons. You may need to import the tarball using |
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary. |
I managed it to migrate from postgres 11 to 15 with the bitnami container. Sharing my painful steps here! To operate in peace I found it quite helpful to run the postgres statefulset with a inifint sleep to have a running container.
Lets start with the operation, connect a shell to the container and pg_update
remove the command line from the statefulset and the postgres should start as usual, with your old data. |
I've managed to run migration as @quorak has described above with several small adjustments:
|
It would be so much simpler, and less error prone, if the Helm chart had a flag to do all this. |
Hi, I'm trying to upgrade from version 12.7 to version 13.12 using the method suggested by @quorak and @antonmatsiuk, but everytime I get this:
What I have done until now
Any suggestions? Thank you |
Hi, for future reference, I solved this problem with the instructions in this thread. I don't have a large database, so It was easy to migrate the data, and, as an advantage, is a non-destructive approach. The steps that I executed was:
kubectl exec -it <NEW_POSTGRES_POD_NAME> -n <NEW_POSTGRES_NAMESPACE> -- /opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash -c 'export PGPASSWORD="<OLD_POSTGRES_PASSWORD>"; echo "local all postgres trust" > /opt/bitnami/postgresql/conf/pg_hba.conf; pg_ctl reload; time pg_dumpall -h <OLD_POSTGRES_HOST> -U postgres | psql -U postgres’
Hope this helps. |
Hello,
I am upgrading a postgres server via helm charts but when I switch to postgres version 12, I get the following error :
And when I type the following command
pg_upgrade -U postgres
to update the schemas and the database I get this:I would like to avoid creating another instance for the postgres will be in version 12 if possible
The text was updated successfully, but these errors were encountered: