Merge pull request #10354 from adam-op/documentation/41326-update-postgresql-10-to-13-migration-documentation

[#41326] Update PostgreSQL 10 to 13 migration documentation
pull/10365/head
Markus Kahl 3 years ago committed by GitHub
commit bb8f814d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 105
      docs/installation-and-operations/misc/migration-to-postgresql13/README.md

@ -6,7 +6,6 @@ OpenProject version 12+ will default to PostgreSQL 13. If you have an existing O
<div class="alert alert-info" role="alert">
Please follow this section only if you have installed OpenProject using [this procedure][package-based-installation].
Before attempting the upgrade, please ensure you have performed a backup of your installation by following the [backup guide](../../operation/backing-up/).
</div>
@ -23,13 +22,30 @@ And verify that it outputs: postgres/autoinstall **install**.
If that is not the case, you are likely using a self-provisioned database or a remote database. In this case, please follow the instructions from your provider or use generic PostgreSQL upgrade guides. A guide we can recommend for Debian/Ubuntu based servers is this one: https://gorails.com/guides/upgrading-postgresql-version-on-ubuntu-server Please adapt that guide or the following steps to your distribution.
In the following, we assume that you initially let OpenProject setup your PostgreSQL installation, using a local database.
NOTE: RedHat and CentOS are slightly different, depending on which PostgreSQL pacakge/repository will be used.
For the documentation parts titled RedHat/CentOS RedHat Enterprise Linux 8 was used.
1. First, connect to your server and make sure your local version is PostgreSQL v10:
For Debian/Ubuntu:
```bash
sudo cat /var/lib/postgresql/10/main/PG_VERSION
10
```
For RedHat/CentOS:
```bash
sudo cat /var/lib/pgsql/10/data/PG_VERSION
10
```
2. Install the new version of PostgreSQL:
For Debian/Ubuntu:
@ -42,24 +58,34 @@ sudo apt-get install postgresql-13
For RedHat/CentOS:
```bash
sudo yum install postgresql-13
sudo yum install pgsql13
sudo /usr/bin/postgresql-13-setup initdb
```
For SLES:
```bash
sudo zypper install postgresql-13
```
3. Stop the PostgreSQL servers:
For Debian/Ubuntu:
```bash
sudo su - postgres -c "/usr/lib/postgresql/10/bin/pg_ctl stop --wait --pgdata=/var/lib/postgresql/10/main"
sudo su - postgres -c "/usr/lib/postgresql/13/bin/pg_ctl stop --wait --pgdata=/var/lib/postgresql/13/main"
```
For RedHat/CentOS:
```bash
sudo su - postgres -c "/usr/pgsql-10/bin/pg_ctl stop --wait --pgdata=/var/lib/pgsql/10/data"
sudo su - postgres -c "/usr/pgsql-13/bin/pg_ctl stop --wait --pgdata=/var/lib/pgsql/13/data"
```
4. Migrate your data to PostgreSQL 13:
For Debian/Ubuntu:
```bash
sudo su - postgres <<CMD
/usr/lib/postgresql/13/bin/pg_upgrade \
@ -72,28 +98,83 @@ sudo su - postgres <<CMD
CMD
```
For RedHat/CentOS:
```bash
sudo su - postgres <<CMD
/usr/pgsql-13/bin/pg_upgrade \
--old-bindir=/usr/pgsql-10/bin \
--new-bindir=/usr/pgsql-13/bin \
--old-datadir=/var/lib/pgsql/10/data \
--new-datadir=/var/lib/pgsql/13/data \
--old-options '-c config_file=/var/lib/pgsql/10/data/postgresql.conf' \
--new-options '-c config_file=/var/lib/pgsql/13/data/postgresql.conf'
CMD
```
5. Make PostgreSQL v13 the new default server to run on port 45432:
For Debian/Ubuntu:
```bash
sudo su - postgres -c "cp /etc/postgresql/{10,13}/main/conf.d/custom.conf"
sudo su - postgres -c "sed -i 's|45432|45433|' /etc/postgresql/10/main/conf.d/custom.conf"
sudo su - postgres -c "/usr/lib/postgresql/13/bin/pg_ctl start --wait --pgdata=/var/lib/postgresql/13/main -o '-c config_file=/etc/postgresql/13/main/postgresql.conf'"
```
6. Check your OpenProject installation. A version higher than `13` should be displayed for `PostgreSQL version` in the "Administration > Information" section.
For RedHat/CentOS:
```bash
sudo su - postgres -c "mkdir -p /var/lib/pgsql/13/data/conf.d"
sudo su - postgres -c "vi /var/lib/pgsql/13/data/postgresql.conf"
# at the section CONFIG FILE INCLUDES, please add the include directory conf.d
include_dir = 'conf.d'
sudo su - postgres -c "cp -p /var/lib/pgsql/10/data/conf.d/custom.conf /var/lib/pgsql/13/data/conf.d/custom.conf"
sudo su - postgres -c "sed -i 's|45432|45433|' /var/lib/pgsql/10/data/conf.d/custom.conf"
sudo su - postgres -c "/usr/pgsql-13/bin/pg_ctl start --wait --pgdata=/var/lib/pgsql/13/data -o '-c config_file=/usr/bin/postgresql-13-setup'"
# Getting the password for the PostgreSQL database from the configuration
sudo openproject config:get DATABASE_URL
postgres://openproject:[CRYPTICAL-PASSWORD-STRING]@127.0.0.1:45432/openproject
# Alter the password for user openproject in pgsql13
[root@openproject ~]# su - postgres
[postgres@openproject ~]$ psql --port 45432
psql (13.6)
Type "help" for help.
postgres=# ALTER USER openproject WITH PASSWORD '[CRYPTICAL-PASSWORD-STRING]';
ALTER ROLE
postgres=# \q
[postgres@openproject ~]$ logout
```
6. Check your OpenProject installation on the GUI. A version higher than `13.0` should be displayed for `PostgreSQL version` in the "Administration > Information" section.
7. If everything is fine, you can then remove your older PostgreSQL installation:
For Debian/Ubuntu:
```bash
sudo rm -rf /var/lib/postgresql/10/main
# you can optionally go further and purge postgresql-10 from your system if you wish
sudo apt-get purge postgresql-10 # debian/ubuntu
sudo yum remove postgresql-10 # rhel/centos
sudo zypper remove postgresql-10 # sles
sudo apt-get purge postgresql-10
```
[pg_upgrade]: https://www.postgresql.org/docs/10/pgupgrade.html
For RedHat/CentOS:
```bash
sudo rm -rf /var/lib/pgsql/10/data
sudo yum remove pgsql10
```
[pg_upgrade]: https://www.postgresql.org/docs/10/pgupgrade.html
[package-based-installation]: ../../installation/packaged/
## Compose-based docker installation

Loading…
Cancel
Save