-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: postgres v16 - pictrs latest * fix: compose v2 * feat: nginx cache * feat: nginx cache support * chore: add warning about the need to ensure a matching SHM * feat: parametise postgres shared memory * fix: parametise shm * feat: autoexplain * feat: dedicated lemmy_web_port * chore: example of lemmy_web_port * chore: show the newer uri for database connections * fix: quote it * chore: move all upgrading docs to a specific file as the readme should look c l e a n * fix: .md * Create UPGRADING.md * fix: prettier * chore: update picrts to latest * Update README.md * Update hosts * Update vars.yml * Update lemmy.yml * Update config.hjson * Fixing prettier. * Fixing prettier 2. * Cleaning up upgrade instructions. * Some typos. * fix: override cache key to ensure json is not returned * fix: docker pictrs defaults * feat: 0.19.4 * fix: also update almalinux playbook * fix: re-add tags --------- Co-authored-by: Dessalines <[email protected]> Co-authored-by: Dessalines <[email protected]>
- Loading branch information
1 parent
8c5337f
commit c872f2d
Showing
11 changed files
with
195 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# Upgrading | ||
|
||
This file shows all steps in how to upgrade between "versions" of the lemmy-ansible repository. | ||
|
||
While we specify a version of Lemmy, pict-rs, postgres, etc. at the point in time we make a release, it does not mean that you cannot mix-and-match versions. (ie; you can run pictrs 0.5.10 with Lemmy 0.19.3). | ||
|
||
While you are not forced into running the specific versions, we do not go through thorough testing on all version compatibility matrices, so please make your best judgement and always backup before performing updates. | ||
|
||
### Upgrading to 1.5.0 (Lemmy 0.19.4, Pict-rs 0.5, postgres 16) | ||
|
||
> **DO NOT RUN IT WITHOUT READING THIS WHOLE SECTION** | ||
This is a major release which requires you to update postgres to v16, and pictrs to v0.5. Once that is done proceed with your regular deployments. | ||
|
||
#### Postgres Upgrade from v15 to v16 | ||
|
||
You need to migrate from postgres v15 to v16. A helper script is provided, that dumps your database, swaps postgres container versions, starts them, and then imports the backup into the new container. | ||
|
||
There will be downtime, and it is a little scary as it will be deleting the `volumes/postgres` folder. The only backup you have during this time will be the `15_16_dump.sql`, created by the helper script. | ||
|
||
On my reference instance (4 CPU, 8GB Memory, 30GB volumes/postgres), it took 10 minutes to dump the backup, and another 20 minutes to import it again. The biggest time sink when importing is when it recreates the indexes. | ||
If you have a faster system and no noisy neighbours you could get the dump and import to be below 20 minutes, but I'd aim for a 60 minute maintenace window. | ||
|
||
- The script you need to download and push onto your server: [postgres_15_to_16_upgrade.sh](https://github.com/LemmyNet/lemmy/blob/main/scripts/postgres_15_to_16_upgrade.sh). | ||
|
||
``` | ||
# Go to your lemmy directory with the docker-compose.yml | ||
cd /srv/lemmy/{my_lemmy_domain}/ | ||
# Download the upgrade script | ||
sudo wget -O postgres_15_to_16_upgrade.sh "https://raw.githubusercontent.com/LemmyNet/lemmy/main/scripts/postgres_15_to_16_upgrade.sh" | ||
# Run the script. Be aware that it may take > 20 minutes | ||
sudo sh postgres_15_to_16_upgrade.sh | ||
``` | ||
|
||
- This also creates a backup file of your old database, called `15_16_dump.sql`. **Do not delete this file** until you are sure that everything is working correctly, for at least a few days. | ||
|
||
#### Pictrs 0.4 -> 0.5 Upgrade | ||
|
||
`0.19.4` also adds functionality only supported by pictrs version `0.5`. Follow the [v0.4 -> v0.5 migration guide](https://git.asonix.dog/asonix/pict-rs.git#0-4-to-0-5-migration-guide) to make sure that your pictrs env vars in `vars.yml` are correct. | ||
|
||
There are more detailed pictrs upgrade instructions below. | ||
|
||
#### Steps | ||
|
||
- `git checkout main && git pull && git checkout 1.5.0` | ||
- Check the diff between the two versions to see the changes our examples: | ||
- examples/customPostgresql.conf: We added a new autoexplain & stats feature, & enabled jit after v16 upgrade. \ | ||
- On low memory systems, you might want to disable jit still: `jit=0` | ||
- examples/hosts: Add `lemmy_web_port` to have a dedicated port | ||
- examples/vars.yml: Add `postgres_shm` to have the correct shared memory for postgres | ||
- Confirm you are already running Postgres v16 | ||
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become` | ||
|
||
### Upgrading to 1.4.0 (Lemmy 0.19.3 & Pict-rs 0.5.4) | ||
|
||
This is a semi-major release which upgrades pict-rs to 0.5 which has support for postgres as a backend. This configuration is **not supported** by lemmy-ansible for the moment. | ||
|
||
#### Steps | ||
|
||
- `git pull && git checkout 1.4.0` | ||
- Read [Pictrs' Configuration Changes](https://git.asonix.dog/asonix/pict-rs/#configuration-updates) | ||
- Amend your `vars.yml` file to respect the new changes | ||
- Optional: Add: `PICTRS__UPGRADE__CONCURRENCY` with a value between 32 and 512 depending on how much RAM/CPU you want to dedicate to the upgrade process. A value of 32 used about 2.5GB of RAM for the migration. | ||
- Optional: Curl `/internal/prepare_upgrade` to minimise downtime while upgrading. See [the instructions below](https://github.com/LemmyNet/lemmy-ansible#update-your-pict-rs-sled-database-optional) or the official documentation [here](https://git.asonix.dog/asonix/pict-rs/releases#user-content-upgrade-preparation-endpoint) | ||
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become` | ||
|
||
### Upgrading to 1.3.1 (Lemmy 0.19.1) | ||
|
||
This is a very minor release but fixes issues relating to federation as part of the Lemmy update. | ||
|
||
#### Steps | ||
|
||
- `git pull && git checkout 1.3.1` | ||
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become` | ||
|
||
### Upgrading to 1.3.0 (Lemmy 0.19.0 & Pict-rs 0.4.7) | ||
|
||
This is a major change and has required reading! tl;dr | ||
|
||
- Lemmy has been upgraded to 0.19.0 | ||
- pict-rs has been upgraded to 0.4.7 | ||
- pict-rs has not been integrated with postgres yet | ||
- "Optional Modules" are now available to be added to your lemmy install as provided by the community. | ||
- The first being pictrs-safety | ||
|
||
#### Steps | ||
|
||
- Prepare to have downtime as the database needs to perform migrations! | ||
- Run `git pull && git checkout 1.3.0` | ||
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become` | ||
- Lemmy will now be down! In testing this takes from 20 to 60 minutes. | ||
- If you are bored you can ssh into your server, and check the logs on postgres for updates | ||
- `docker compose logs -f postgres` while ssh'd and in your Lemmy directory | ||
|
||
#### Update your pict-rs sled-database (Optional) | ||
|
||
If you are happy for pict-rs to be down _for a while_ ~go straight to our `1.3.1` git tag which updates pictrs to 0.5.0~. Otherwise keep reading. | ||
Starting with 0.5.0 your database will automatically upgrade to the latest version, which will cause downtime for your users. | ||
As such there is an intermediary step where you can upgrade your database in the background to prepare for 0.5 (Reference documentation)[https://git.asonix.dog/asonix/pict-rs/releases#user-content-upgrade-preparation-endpoint]. This ensure no-one is caught out by unforseen downtime of multiple services. | ||
|
||
Once you have deployed lemmy-ansible `1.3.0` tag, please continue (if you want): | ||
|
||
- Take note of what your pict-rs API Key is under `vars.yml` | ||
- Take note of what your docker network name is. (It's normally the domain without any extra characters) | ||
- You should be able to find it via: `docker network ls | grep _default` if in doubt. | ||
- Run the following command replacing `api-key` with the pict-rs api key, & `youdomain` with the network name. | ||
- `docker run --network yourdomain_default --rm curlimages/curl:8.5.0 --silent -XPOST -H'X-Api-Token: api-key' 'http://pictrs:8080/internal/prepare_upgrade'` | ||
- This will start the background process updating your database from 0.4 to 0.5 compatible. | ||
|
||
This is only Optional, and takes a shorter amount of time than the Lemmy database upgrade, but on huge installations it may take a lot longer. | ||
|
||
#### Optional Module(s) | ||
|
||
Our first optional module is [pictrs-safety](https://github.com/db0/pictrs-safety). See the repo linked for more information, especially for integration with pictrs (which is what it is for) Thanks to @db0 for their contribution. | ||
See the `pictrs_safety_env_vars` under `examples/vars.yml` for relevant options (and the two password variables) | ||
To enable this module to be used you must ADD `pictrs_safety: true` to your `vars.yml`. | ||
|
||
### Upgrading to 1.2.1 (Lemmy 0.18.5) | ||
|
||
This is a minor change which fixes the issue with the Postgres container not using the `customPostgres.conf` file. | ||
|
||
#### Steps | ||
|
||
- Please regenerate your `customPostgres.conf` from `examples/customPostgres.conf` | ||
- **OR** | ||
- Add the following block to your current customPostgres file. | ||
|
||
``` | ||
# Listen beyond localhost | ||
listen_addresses = '\*' | ||
``` | ||
|
||
### Upgrading to 1.2.0 (Lemmy 0.18.5) | ||
|
||
Major changes: | ||
|
||
- All variables are not under a singular file so you will not need to modify anything: `inventory/host_vars/{{ domain }}/vars.yml` | ||
- `--become` is now optional instead of forced on | ||
|
||
#### Steps | ||
|
||
- Run `git pull && git checkout 1.2.0` | ||
- When upgrading from older versions of these playbooks, you will need to do the following: | ||
- Rename `inventory/host_vars/{{ domain }}/passwords/postgres` file to `inventory/host_vars/{{ domain }}/passwords/postgres.psk` | ||
- Copy the `examples/vars.yml` file to `inventory/host_vars/{{ domain }}/vars.yml` | ||
- Edit your variables as desired | ||
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become` | ||
|
||
### Upgrading to 1.1.0 (Lemmy 0.18.3) | ||
|
||
- No major changes should be required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.19.3 | ||
0.19.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,11 @@ | |
# if you are upgrading from a previous version, set this to `/lemmy` | ||
# - `lemmy_version`: <Optional> The back end version. | ||
# - `lemmy_ui_version`: <Optional> overrides the front end version. | ||
# - `pictrs_safety`: <Optional> If true, a docker container for pictrs-safety will be deployed and pict-rs will be configured to validate images through it. You will also need to set up a fedi-safety worker to validate the images. | ||
example.com ansible_user=root domain=example.com letsencrypt_contact_email[email protected] lemmy_base_dir=/srv/lemmy pictrs_safety=false | ||
# - `pictrs_safety`: <Optional> If true, a docker container for pictrs-safety will be deployed and pict-rs | ||
# will be configured to validate images through it. You will also need to set up a | ||
# fedi-safety worker to validate the images. | ||
# - `lemmy_web_port`: <Optional> Sets the host->docker nginx upstream port to allow a static host nginx configuration | ||
example.com ansible_user=root domain=example.com letsencrypt_contact_email[email protected] lemmy_base_dir=/srv/lemmy pictrs_safety=false lemmy_web_port=9633 | ||
|
||
[all:vars] | ||
ansible_connection=ssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.