PostgreSQL 15/ 업그레이드가 불가능합니다

안녕하세요, 이 게시글을 읽었습니다: PostgreSQL 15 update - 그리고 버전 15로 업그레이드를 시도해 보았으나, 재구축 명령을 실행할 때 낯선 오류가 발생하고 있으며, 제 조사로는 문제를 해결하지 못했습니다. 여기서 도움을 주실 수 있다면 감사하겠습니다.

Locale과 postgres가 버전 13에서 초기화되어 15와 호환되지 않는다고 경고하고 있습니다.

WARNING: Docker version 20.10.7 deprecated, recommend upgrade to 24.0.7 or newer.
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 600 app
app
2.0.20250129-0720: Pulling from discourse/base
Digest: sha256:01b8516e5504c0e9bc3707773015ff4407be03a89154194ff3b5b8699291bc26
Status: Image is up to date for discourse/base:2.0.20250129-0720
docker.io/discourse/base:2.0.20250129-0720
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-02-25T12:02:47.588312 #1]  INFO -- : Reading from stdin
I, [2025-02-25T12:02:47.603317 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown:
I, [2025-02-25T12:02:47.608602 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown:
I, [2025-02-25T12:02:47.614271 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown:
I, [2025-02-25T12:02:47.619607 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown:
I, [2025-02-25T12:02:47.623993 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown:
I, [2025-02-25T12:02:47.624696 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/15/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.628520 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.629701 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.635680 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.636635 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.637658 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.638584 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.639215 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.639833 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-25T12:02:47.640892 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-25T12:02:47.641570 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-25T12:02:47.642114 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-25T12:02:47.642818 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory
failed to set locale!
[error] default character map file `ANSI_X3.4-1968' not found: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US.UTF-8",
        LC_ALL = "en_US.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"
I, [2025-02-25T12:02:49.979779 #1]  INFO -- : Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
Upgrading PostgreSQL from version 13 to 15

I, [2025-02-25T12:02:49.980481 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main
I, [2025-02-25T12:02:49.983148 #1]  INFO -- : Terminating async processes
2025-02-25 12:02:50.007 UTC [51] FATAL:  database files are incompatible with server
2025-02-25 12:02:50.007 UTC [51] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 15.10 (Debian 15.10-1.pgdg120+1).

미리 감사드립니다!

이것이 아마도 가장 심각한 문제일 것입니다. RAM을 더 추가하거나 스왑(swap)을 추가해야 합니다.

다음과 같은 간단한 진단 명령어의 출력을 게시해 주세요:

시간 내어 주셔서 감사합니다. 메모리 관련 사항을 완전히 놓치고 있었네요. 요청하신 결과를 첨부합니다:

root@glorious-discourse-forum:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
root@glorious-discourse-forum:~# uptime
 13:27:58 up 1341 days, 22:37,  2 users,  load average: 0.07, 0.03, 0.00
root@glorious-discourse-forum:~# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        49G   41G  7.7G  85% /
root@glorious-discourse-forum:~# free
              total        used        free      shared  buff/cache   available
Mem:        2040976      416492      436628       20940     1187856     1433788
Swap:       2097148       85248     2011900
root@glorious-discourse-forum:~# swapon
NAME      TYPE SIZE  USED PRIO
/swapfile file   2G 83.3M   -2
root@glorious-discourse-forum:~# vmstat 5 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0  85248 436692 444416 743440    8    8   268    88    0    0  3  1 96  0  0
 0  0  85248 436684 444416 743440    0    0     0     0   50   87  0  0 100  0  0
 0  0  85248 436716 444416 743440    0    0     0     8   48   78  0  0 100  0  0
 0  0  85248 436716 444416 743440    0    0     0     6   39   63  0  0 100  0  0
 0  0  85248 436716 444416 743440    0    0     0     0   54   91  0  0 100  0  0
root@glorious-discourse-forum:~# dmesg|egrep -i "memory|oom|kill"
root@glorious-discourse-forum:~# ps auxrc
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      5781  0.0  0.1  40100  3332 pts/6    R+   13:28   0:00 ps

고맙습니다. 2GB 또는 4GB의 스왑 공간을 추가하는 것만으로도 해결될 수 있을 것 같습니다. 하지만 Docker가 최신 버전이 아니라는 경고와 18.04LTS를 사용하고 있다는 점을 고려하면, 24.04(가능하다면)를 새로 설치한 새로운 인스턴스로 마이그레이션하는 것이 훨씬 나은 선택이 될 것입니다. 저는 현재 24.04와 22.04를 모두 사용 중입니다.

새로운 인스턴스로 마이그레이션하는 것이 제자리 업그레이드를 시도하는 것보다 전반적으로 더 적은 노력을 요할 가능성이 높습니다. 또한 더 적은 중단 시간을 가져올 수도 있습니다. 어떤 조치를 취하든 약간의 다운타임은 발생할 가능성이 큽니다.

1단계는 백업(다운로드 포함)을 수행하고 이를 안전하게 보관하기 위해 다운로드하는 것입니다. 또한 app.yml 파일의 사본도 확보해 두세요.

저는 어제 유사한 이유로 마이그레이션을 수행했습니다. 또한 호스팅 제공업체의 새로운 요금제로 전환하면 동일한 비용으로 더 나은 머신을 확보할 수 있었습니다.

아래의 마이그레이션 레시피와 팁을 따랐습니다.
Steps involved to downgrade from 2GB to 1GB on DO? - #3 by merefield

최상의 결과를 얻으려면 아래 글도 읽어보시기 바랍니다.
MKJ’s Opinionated Discourse Deployment Configuration

특히 스왑을 추가할 경우 디스크 공간이 다소 부족한 상태입니다. 저는 보통 du -kx / | sort -n | tail -55 또는 유사한 명령어를 사용하여 존재할 필요가 없는 큰 파일이 있는지 확인합니다.

오, 백업과 복원 대신 마이그레이션을 위한 또 다른 방법으로는 rsync를 사용하는 것이 있습니다. 저는 직접 해본 적은 없지만, 여기 레시피를 하나 공유합니다:
Move a Discourse site to another VPS with rsync

다른 문제는 Docker 버전과 OS를 업그레이드해야 한다는 것입니다.

Docker 버전 24.0.7 이상은 18보다 높은 Ubuntu LTS를 요구합니다. 해당 LTS의 장기 서비스 지원은 종료되었습니다.

18.04로 업그레이드된 사이트를 몇 개 봤지만, 대부분은 그렇지 않았습니다.

dist-upgrade를 성공적으로 수행한 사람들을 본 적은 있지만, 성공 여부는 불확실합니다. 또한 24.04가 지원되는 향후 5년 동안 6년 전 OS의 잔재가 문제를 일으킬 수 있는 상황을 정말로 원하시나요? 게다가 18.04를 업그레이드해도 20.04까지만 도달할 수 있으며, 이는 약 60일 정도 더 지원되는 수준입니다. 따라서 최신 OS로 가기 위해서는 3번의 dist-upgrade를 실행해야 합니다.

저도 정확히 같은 오류를 겪었는데, ./launcher rebuild를 실행했습니다. 포럼과 경고 메시지를 제대로 확인하지 않고 그냥 무턱대고 업데이트를 실행했거든요. 이 실행을 어떻게 중단하거나 되돌릴 수 있을까요? 그냥 실행 중일 때 Ctrl+C를 누르면 되는 건가요?

무슨 일이 있었나요? 오류가 발생했나요? 다시 재구성을 실행하라고 표시되었나요?

docker를 업그레이드했나요?

다음 명령어를 시도해 보셨나요?

 ./launcher start app

PostgreSQL 15 업데이트를 확인해 보셨나요?

DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 15.10 (Debian 15.10-1.pgdg120+1). 이후 아무 반응도 없었습니다.
서버를 강제 재부팅했는데, 그 후에 서버가 다시 돌아왔습니다.
Docker가 20번으로 멈춰 있는 이유와 다른 의존성 문제로 인해 몇 가지 업데이트를 더 실행하고 있습니다. 금요일 밤을 보내는 좋은 방법인 것 같네요 하하

아쉽네요.

월요일까지 기다렸다가 새 VM으로 옮기는 걸 추천해요. 이 VM은 수명(지원 기간)이 끝난 것 같거든요.

호스트 OS와 Docker 버전을 업데이트한 뒤 DB 업데이트가 정상적으로 작동했어요. RAM도 좀 더 늘려줬죠 ㅋㅋ 앞으로 5년은 더 괜찮을 거 아니에요? ㅎㅎ

OS 업그레이드(특히 Docker)를 한다면, 아마도 그렇습니다!