document upgrade process
This commit is contained in:
parent
8e535d4f1c
commit
217a778a8f
1 changed files with 61 additions and 0 deletions
61
README.md
61
README.md
|
|
@ -1,3 +1,64 @@
|
||||||
|
# Operational notes
|
||||||
|
|
||||||
|
## Postgres upgrade
|
||||||
|
|
||||||
|
1. Stop services that use postgres
|
||||||
|
```bash
|
||||||
|
systemctl stop matrix-synapse grafana
|
||||||
|
```
|
||||||
|
2. Login as postgres user
|
||||||
|
```bash
|
||||||
|
sudo -su postgres
|
||||||
|
old=16
|
||||||
|
cd /var/lib/postgresql/
|
||||||
|
pg_old=$(nix-build --no-out-link -A postgresql_${old:?} '<nixpkgs>')
|
||||||
|
pg_new=$(nix-build --no-out-link -A postgresql_$((old+1)) '<nixpkgs>')
|
||||||
|
```
|
||||||
|
3. Initialize new data directory
|
||||||
|
```bash
|
||||||
|
$pg_new/bin/initdb --encoding=UTF8 --no-locale $((old+1))
|
||||||
|
```
|
||||||
|
4. Run check
|
||||||
|
```bash
|
||||||
|
$pg_new/bin/pg_upgrade \
|
||||||
|
--old-bindir=$pg_old/bin \
|
||||||
|
--new-bindir=$pg_new/bin \
|
||||||
|
--old-datadir=/var/lib/postgresql/${old:?} \
|
||||||
|
--new-datadir=/var/lib/postgresql/$((old+1)) \
|
||||||
|
-j16 \
|
||||||
|
--clone \
|
||||||
|
--check
|
||||||
|
```
|
||||||
|
5. Stop the old Postgres
|
||||||
|
```bash
|
||||||
|
systemctl stop postgresql
|
||||||
|
```
|
||||||
|
6. Run the migration
|
||||||
|
```bash
|
||||||
|
$pg_new/bin/pg_upgrade \
|
||||||
|
--old-bindir=$pg_old/bin \
|
||||||
|
--new-bindir=$pg_new/bin \
|
||||||
|
--old-datadir=/var/lib/postgresql/${old:?} \
|
||||||
|
--new-datadir=/var/lib/postgresql/$((old+1)) \
|
||||||
|
-j16 \
|
||||||
|
--clone
|
||||||
|
```
|
||||||
|
7. Start the new Postgres
|
||||||
|
```bash
|
||||||
|
services.postgres.packages = pkgs.postgresql_17;
|
||||||
|
nixos-rebuild switch
|
||||||
|
```
|
||||||
|
|
||||||
|
Cleanup (after a few days):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo -su postgres
|
||||||
|
vacuumdb --all --analyze-in-stages
|
||||||
|
cd /var/lib/postgresql/
|
||||||
|
./delete_old_cluster.sh
|
||||||
|
rm -v delete_old_cluster.sh
|
||||||
|
```
|
||||||
|
|
||||||
# Tarball
|
# Tarball
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue