mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-25 10:27:20 +00:00
Upgrade to postgres 15. (#2659)
This commit is contained in:
parent
b5d45fa826
commit
ac56504291
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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."
|
Loading…
Reference in a new issue