PostgreSQL 12 업데이트

:warning: 주의! 데이터베이스가 매우 큰 경우, 추가 디스크 공간(데이터베이스 크기의 2배)이 많이 필요하며 이 업그레이드를 수행할 때 매우 주의해야 합니다!

오래 기다렸던 PostgreSQL 주요 버전 업그레이드가 마침내 적용되었습니다. 커맨드 라인에서 Discourse를 다시 빌드하는 사이트 관리자는 이제 구버전 PostgreSQL 10에서 PostgreSQL 12로 업그레이드됩니다.

Meta에서는 이 새 버전을 이미 상당 기간 동안 사용해 왔으며, 모든 기능이 정상적으로 작동하고 있습니다. PostgreSQL 12는 Discourse가 자동으로 활용할 수 있는 많은 개선 사항을 제공합니다.

업데이트

공식 설치 가이드 (단일 컨테이너)

다음 재빌드 시, 끝에 다음과 같은 메시지가 표시됩니다:

Upgrade Complete
----------------

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------

이것은 업그레이드가 성공적으로 완료되었음을 의미합니다! 사이트를 다시 실행하려면 새 재빌드를 수행하기만 하면 됩니다.

데이터 컨테이너 설치

discourse_docker 저장소에서 제공된 샘플을 기반으로 전용 데이터 컨테이너를 사용하는 설정을 실행 중이라면, PostgreSQL을 안전하고 깔끔하게 종료하는 것이 중요합니다.

요즘에는 몇 분간 지속되는 쿼리를 실행하는 백그라운드 작업이 존재하므로, 웹 컨테이너를 종료하면 데이터 컨테이너가 안전하게 종료되는 데 도움이 됩니다.

./launcher stop web_only
./launcher stop data
./launcher rebuild data
./launcher rebuild data
./launcher rebuild web_only

데이터 컨테이너에 대한 첫 번째 재빌드를 수행하기 전에, PostgreSQL 로그를 추적(tail)하여 올바르게 종료되었는지 확인할 수 있습니다.

tail -f shared/data/log/var-log/postgres/current을 실행하면, 종료 과정이 깔끔했다면 다음과 같은 로그가 표시됩니다:

2020-05-13 18:33:33.457 UTC [36] LOG:  received smart shutdown request
2020-05-13 18:33:33.464 UTC [36] LOG:  worker process: logical replication launcher (PID 52) exited with exit code 1
2020-05-13 18:33:33.465 UTC [47] LOG:  shutting down
2020-05-13 18:33:33.479 UTC [36] LOG:  database system is shut down

수동 업데이트 / 공간이 제한된 환경

:warning::warning::warning:
이 작업을 시도하기 전에 반드시 POSTGRES_DATA를 백업해야 합니다.
:warning::warning::warning:

더 많은 공간을 확보할 수 없는 공간이 제한된 환경에 있는 경우, 다음을 시도해 볼 수 있습니다:

./launcher stop app #(또는 해당 설정에 따라 web_only와 data 둘 다)
mkdir -p /var/discourse/shared/standalone/postgres_data_new
docker run --rm \
	-v /var/discourse/shared/standalone/postgres_data:/var/lib/postgresql/10/data \
	-v /var/discourse/shared/standalone/postgres_data_new:/var/lib/postgresql/12/data \
	tianon/postgres-upgrade:10-to-12
mv /var/discourse/shared/standalone/postgres_data /var/discourse/shared/standalone/postgres_data_old
mv /var/discourse/shared/standalone/postgres_data_new /var/discourse/shared/standalone/postgres_data
./launcher rebuild app #(또는 해당 설정에 따라 먼저 data를 빌드하고 그 다음 web_only)

제 테스트 결과, 이 절차는 현재 데이터베이스 크기의 1배 미만인 자유 공간만 필요합니다.

업데이트 지연

다음 재빌드 시 업데이트를 지연해야 하는 경우, app.yml 파일에서 "templates/postgres.template.yml"을 "templates/postgres.10.template.yml"로 변경하여 PostgreSQL 템플릿을 교체할 수 있습니다.

일부 사이트 관리자가 나중에 이 변경 사항을 되돌리는 것을 잊을 수 있으므로 이 방법은 권장되지 않습니다.

업데이트 후 선택적 작업

PostgreSQL 통계 최적화

업데이트 후, 새 PostgreSQL에는 테이블 통계가 없습니다. 다음을 사용하여 생성할 수 있습니다:

cd /var/discourse
./launcher enter app
su postgres
psql
\connect discourse
VACUUM VERBOSE ANALYZE;
\q
exit
exit

또는 위의 한 줄 버전:

/var/discourse/launcher run app "echo 'vacuum verbose analyze;' | su postgres -c 'psql discourse'"

구버전 데이터 정리

표준 설치인 경우, 다음 명령을 사용하여 PG10 형식의 구버전 데이터를 삭제할 수 있습니다:

cd /var/discourse
./launcher cleanup

별도의 데이터 컨테이너를 사용하는 경우, 백업 카피를 다음과 같이 제거해야 합니다:

rm -fr /var/discourse/shared/data/postgres_data_old/

FAQ

소스 클러스터가 깔끔하게 종료되지 않았습니다

위 메시지와 함께 업그레이드 실패가 발생하는 경우, 더 간단한 접근 방식을 사용하여 상태를 더 좋게 되돌릴 수 있습니다.

./launcher start app으로 구버전 컨테이너를 다시 시작합니다. 다시 실행될 때까지 몇 분 정도 기다립니다.

이제 ./launcher stop app으로 다시 종료합니다. 그런 다음 로그를 추적하여 깔끔하게 종료되었는지 확인합니다:

tail -f shared/data/log/var-log/postgres/current
2020-05-13 18:33:33.457 UTC [36] LOG:  received smart shutdown request
2020-05-13 18:33:33.464 UTC [36] LOG:  worker process: logical replication launcher (PID 52) exited with exit code 1
2020-05-13 18:33:33.465 UTC [47] LOG:  shutting down
2020-05-13 18:33:33.479 UTC [36] LOG:  database system is shut down

로그가 위와 같다면, 이제 ./launcher rebuild app을 사용하여 다시 업그레이드를 시도할 수 있습니다.

데이터베이스 "postgres"의 lc_collate 값이 일치하지 않습니다

이 오류는 데이터베이스에 기본 로케일이 아닌 로케일을 사용하는 경우 발생합니다. 성공하려면 3개의 변수가 필요하다고 보고되었습니다. app.yml 파일의 env: 섹션에 다음 3줄이 있는지 확인하십시오:

  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8

en_US.UTF-8을 사용 중인 로케일로 변경하십시오.

모든 재빌드 시 업그레이드가 다시 수행되는 경우 (즉, 업그레이드 루프)

이러한 일이 발생하면 업그레이드 로그에 다음 내용이 포함됩니다.

mv: cannot move '/shared/postgres_data' to '/shared/postgres_data_old/postgres_data': Directory not empty
mv: cannot move '/shared/postgres_data_new' to '/shared/postgres_data/postgres_data_new': Directory not empty

이는 이전 업그레이드에서 남은 파일이 여전히 존재한다는 것을 의미합니다. 계속하기 전에 해당 파일을 다른 곳으로 이동하십시오.

68개의 좋아요
Update failed (postgresql)
Trouble with latest update
Cant backup because of version mismatch on aws
Discourse Update Probs. Help please
User profile page and other features page not available
Error after Upgrading
UPGRADE OF POSTGRES FAILED - I've tried everything
Discourse 2.5.0.beta5 Release Notes
Problem with upgrading the latest version
Updated to latest version: ./analyze_new_cluster.sh message
SAML error after upgrade
Trouble with postgre(maybe)
Failed upgrade from 2.5.0beta4 to 2.5.0beta5
Corrupt indexes in PG12, how do I fix?
PostgreSQL 13 update
Slow Sidekiq + Postmaster using 95%+ CPU (32 cores) after Postgresql Version Upgrade
Upgrade of postgres failed
LDAP Auth Missing from Plugins
Today error when upgrade from 2.5.1 to 2.5.2, discourse-assign
Issue Rebuilding App Failing on Postgres Upgrade
Primary Postgres database process (postmaster) eating all CPU
Search 502 errors in 2.5.0.beta6
How to backup and restore a whole /var/discourse app folder?
How hard is it to handle Discourse after installation
Discourse failing to connect to port 3000
Fixing discourse after disk full
2.6.0 beta 3 update failed on disk and/or memory space
Trouble with latest update
Help! Problem with firewall/permissions and postgre?
Old Postgres on Docker Image with two containers: web and data
Slow Sidekiq + Postmaster using 95%+ CPU (32 cores) after Postgresql Version Upgrade
Slow Sidekiq + Postmaster using 95%+ CPU (32 cores) after Postgresql Version Upgrade
Slow Sidekiq + Postmaster using 95%+ CPU (32 cores) after Postgresql Version Upgrade
Should I also rebuild my data container when upgrading
Problem with upgrading the latest version
UPGRADE OF POSTGRES FAILED - I've tried everything
Restore failed at "EXCEPTION: x of y uploads are not migrated to S3. S3 migration failed for db 'default'."
Can't upgrade due to old docker version
Database migration chokes on huge value of a "calendar-details" item in table "post_custom_fields"
PostgreSQL update wrecked my forum. Please help!
Instead of auto-deleting old replies, make them auto-hide?
Add print CSS for front page and category page?
Site down after failed update: permission denied to create extension "unaccent"
Migrate quickly to separate web and data containers
Rebuild failed - FAILED TO BOOTSTRAP
Old Postgres on Docker Image with two containers: web and data
Can't rebuild due to failed postgres 12 upgrade
PostgreSQL 15 update
Postgres upgrade success loop due to prior postgres 8 to 10 migration
Discourse for Teams (Alpha Testing summer 2020)