diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 56647a7a5..e38d0ca1d 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -86,10 +86,36 @@ services: restart: always postgres: - image: postgres:14-alpine + image: postgres:15-alpine # this needs to match the database host in lemmy.hson + # Tune your settings via + # https://pgtune.leopard.in.ua/#/ + # You can use this technique to add them here + # https://stackoverflow.com/a/30850095/1655478 hostname: postgres - command: ["postgres", "-c", "session_preload_libraries=auto_explain", "-c", "auto_explain.log_min_duration=5ms", "-c", "auto_explain.log_analyze=true"] + command: [ + "postgres", + "-c", "session_preload_libraries=auto_explain", + "-c", "auto_explain.log_min_duration=5ms", + "-c", "auto_explain.log_analyze=true" + # Tuning config + # "-c", "max_connections=200", + # "-c", "shared_buffers=3GB", + # "-c", "effective_cache_size=9GB", + # "-c", "maintenance_work_mem=768MB", + # "-c", "checkpoint_completion_target=0.9", + # "-c", "wal_buffers=16MB", + # "-c", "default_statistics_target=100", + # "-c", "random_page_cost=4", + # "-c", "effective_io_concurrency=2", + # "-c", "work_mem=7864kB", + # "-c", "min_wal_size=1GB", + # "-c", "max_wal_size=4GB", + # "-c", "max_worker_processes=4", + # "-c", "max_parallel_workers_per_gather=2", + # "-c", "max_parallel_workers=4", + # "-c", "max_parallel_maintenance_workers=2", + ] networks: - lemmyinternal # adding the external facing network to allow direct db access for devs diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index f362f0197..13e73fb98 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -47,7 +47,7 @@ services: ports: - "8541:8541" postgres_alpha: - image: postgres:14-alpine + image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password @@ -75,7 +75,7 @@ services: ports: - "8551:8551" postgres_beta: - image: postgres:14-alpine + image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password @@ -103,7 +103,7 @@ services: ports: - "8561:8561" postgres_gamma: - image: postgres:14-alpine + image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password @@ -132,7 +132,7 @@ services: ports: - "8571:8571" postgres_delta: - image: postgres:14-alpine + image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password @@ -161,7 +161,7 @@ services: ports: - "8581:8581" postgres_epsilon: - image: postgres:14-alpine + image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index a0fe5cfeb..a1efd03f1 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -72,7 +72,7 @@ services: restart: always postgres: - image: postgres:14-alpine + image: postgres:15-alpine # this needs to match the database host in lemmy.hson hostname: postgres networks: diff --git a/scripts/postgres_12_to_14_upgrade.sh b/scripts/postgres_12_to_15_upgrade.sh similarity index 69% rename from scripts/postgres_12_to_14_upgrade.sh rename to scripts/postgres_12_to_15_upgrade.sh index 6f1f6d461..0850e8fca 100755 --- a/scripts/postgres_12_to_14_upgrade.sh +++ b/scripts/postgres_12_to_15_upgrade.sh @@ -3,12 +3,15 @@ set -e echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete." +echo "Stopping lemmy and all services..." +sudo docker-compose stop + echo "Make sure postgres is started..." sudo docker-compose up -d postgres sleep 20s -echo "Exporting the Database to 12_14.dump.sql ..." -sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_14_dump.sql +echo "Exporting the Database to 12_15.dump.sql ..." +sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_15_dump.sql echo "Done." echo "Stopping postgres..." @@ -18,20 +21,20 @@ sleep 20s echo "Removing the old postgres folder" sudo rm -rf volumes/postgres -echo "Updating docker-compose to use postgres version 14." -sed -i "s/postgres:12-alpine/postgres:14-alpine/" ./docker-compose.yml +echo "Updating docker-compose to use postgres version 15." +sed -i "s/image: postgres:.*/image: postgres:15-alpine/" ./docker-compose.yml echo "Starting up new postgres..." sudo docker-compose up -d postgres sleep 20s echo "Importing the database...." -cat 12_14_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy +cat 12_15_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy echo "Done." POSTGRES_PASSWORD=$(grep "POSTGRES_PASSWORD" ./docker-compose.yml | cut -d"=" -f2) -echo "Fixing a weird password issue with postgres 14" +echo "Fixing a weird password issue with postgres 15" sudo docker-compose exec -T postgres psql -U lemmy -c "alter user lemmy with password '$POSTGRES_PASSWORD'" sudo docker-compose restart postgres @@ -41,5 +44,5 @@ sudo chown -R 991:991 volumes/pictrs echo "Starting up lemmy..." sudo docker-compose up -d -echo "A copy of your old database is at 12_14.dump.sql . You can delete this file if the upgrade went smoothly." +echo "A copy of your old database is at 12_15.dump.sql . You can delete this file if the upgrade went smoothly." echo "Upgrade complete."