신규 설치에서도 BOOTSTRAP 실패

안녕하세요,

수년간 Discourse를 사용해 왔는데, 다른 서버로 이사를 가고자 합니다.
이미 백업은 완료했고, 이제 복원을 위해 새 서버에 새 인스턴스를 설치하려고 시도하고 있습니다.

하지만 새 설치를 시도할 때마다 계속 오류가 발생합니다.
여러 번 시도해 보았지만 여전히 동일한 문제가 발생하며, 서버를 여러 번 재빌드해 보았지만 결과는 같습니다.

Debian 11
RAM 1GB
SWAP 4GB
2 Core

설치 로그:

x86_64 arch detected.
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 60 app
app
2.0.20230222-0048: Pulling from discourse/base
Digest: sha256:6a7dd0755c6832e1ecfc8cc980f27836b69b4162d6ff1b6a3e4e382a3b854803
Status: Image is up to date for discourse/base:2.0.20230222-0048
docker.io/discourse/base:2.0.20230222-0048
/usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2023-03-13T11:25:13.229925 #1]  INFO -- : Reading from stdin
I, [2023-03-13T11:25:13.237120 #1]  INFO -- : > locale-gen $LANG && update-locale
I, [2023-03-13T11:25:15.133566 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2023-03-13T11:25:15.134390 #1]  INFO -- : > mkdir -p /shared/postgres_run
I, [2023-03-13T11:25:15.164309 #1]  INFO -- : 
I, [2023-03-13T11:25:15.165444 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2023-03-13T11:25:15.182370 #1]  INFO -- : 
I, [2023-03-13T11:25:15.183423 #1]  INFO -- : > chmod 775 /shared/postgres_run
I, [2023-03-13T11:25:15.248940 #1]  INFO -- : 
I, [2023-03-13T11:25:15.249966 #1]  INFO -- : > rm -fr /var/run/postgresql
I, [2023-03-13T11:25:15.269133 #1]  INFO -- : 
I, [2023-03-13T11:25:15.270288 #1]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2023-03-13T11:25:15.314538 #1]  INFO -- : 
I, [2023-03-13T11:25:15.315922 #1]  INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2023/03/13 11:25:16 socat[18] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2023-03-13T11:25:16.264579 #1]  INFO -- : 
I, [2023-03-13T11:25:16.265205 #1]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2023-03-13T11:25:16.330415 #1]  INFO -- : 
I, [2023-03-13T11:25:16.331258 #1]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2023-03-13T11:25:16.334530 #1]  INFO -- : 
I, [2023-03-13T11:25:16.335427 #1]  INFO -- : > mkdir -p /shared/postgres_run/13-main.pg_stat_tmp
I, [2023-03-13T11:25:16.339258 #1]  INFO -- : 
I, [2023-03-13T11:25:16.340137 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run/13-main.pg_stat_tmp
I, [2023-03-13T11:25:16.342468 #1]  INFO -- : 
I, [2023-03-13T11:25:16.410983 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2023-03-13T11:25:16.416328 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2023-03-13T11:25:16.421556 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2023-03-13T11:25:16.428238 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2023-03-13T11:25:16.429045 #1]  INFO -- : > chown -R root /var/lib/postgresql/13/main
I, [2023-03-13T11:26:07.923757 #1]  INFO -- : 
I, [2023-03-13T11:26:08.425452 #1]  INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/13/bin/initdb -D /shared/postgres_data || exit 0
I, [2023-03-13T11:26:08.612014 #1]  INFO -- : 
I, [2023-03-13T11:26:08.612768 #1]  INFO -- : > chown -R postgres:postgres /shared/postgres_data
I, [2023-03-13T11:26:09.223581 #1]  INFO -- : 
I, [2023-03-13T11:26:09.224698 #1]  INFO -- : > chown -R postgres:postgres /var/run/postgresql
I, [2023-03-13T11:26:09.227553 #1]  INFO -- : 
I, [2023-03-13T11:26:09.228389 #1]  INFO -- : > /root/upgrade_postgres
I, [2023-03-13T11:26:09.285168 #1]  INFO -- : 
I, [2023-03-13T11:26:09.285919 #1]  INFO -- : > rm /root/upgrade_postgres
I, [2023-03-13T11:26:09.288235 #1]  INFO -- : 
I, [2023-03-13T11:26:09.464138 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/13/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.465421 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.466207 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.466702 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.467257 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.467687 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.468143 #1]  INFO -- : > install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
I, [2023-03-13T11:26:09.761975 #1]  INFO -- : 
I, [2023-03-13T11:26:09.763351 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.764536 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.765473 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.791036 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/13/main/pg_hba.conf
I, [2023-03-13T11:26:09.792174 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2023-03-13T11:26:09.792950 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2023-03-13T11:26:09.793444 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
I, [2023-03-13T11:26:09.795665 #1]  INFO -- : > sleep 5
I, [2023-03-13T11:26:14.820284 #1]  INFO -- : 
I, [2023-03-13T11:26:14.821311 #1]  INFO -- : > su postgres -c 'createdb discourse' || true
createdb: error: could not connect to database template1: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
I, [2023-03-13T11:26:21.603565 #1]  INFO -- : 
I, [2023-03-13T11:26:21.604284 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2023-03-13 11:26:22.014 UTC [41] LOG:  starting PostgreSQL 13.10 (Debian 13.10-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-03-13 11:26:22.020 UTC [41] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-03-13 11:26:22.021 UTC [41] LOG:  listening on IPv6 address "::", port 5432
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
I, [2023-03-13T11:26:22.036057 #1]  INFO -- : 
I, [2023-03-13T11:26:22.039351 #1]  INFO -- : > su postgres -c 'psql discourse -c "grant all privileges on database discourse to discourse;"' || true
2023-03-13 11:26:22.047 UTC [41] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-03-13 11:26:22.723 UTC [53] LOG:  database system was shut down at 2023-03-13 10:30:34 UTC
2023-03-13 11:26:22.754 UTC [54] postgres@discourse FATAL:  the database system is starting up
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  the database system is starting up
I, [2023-03-13T11:26:22.757656 #1]  INFO -- : 
I, [2023-03-13T11:26:22.758335 #1]  INFO -- : > su postgres -c 'psql discourse -c "alter schema public owner to discourse;"'
2023-03-13 11:26:22.811 UTC [58] postgres@discourse FATAL:  the database system is starting up
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  the database system is starting up
I, [2023-03-13T11:26:22.814281 #1]  INFO -- : 
I, [2023-03-13T11:26:22.815016 #1]  INFO -- : Terminating async processes
I, [2023-03-13T11:26:22.815325 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41
2023-03-13 11:26:22.815 UTC [41] LOG:  received fast shutdown request
2023-03-13 11:26:22.928 UTC [61] LOG:  shutting down
2023-03-13 11:26:22.971 UTC [41] LOG:  database system is shut down


FAILED
--------------------
Pups::ExecError: su postgres -c 'psql discourse -c "alter schema public owner to discourse;"' failed with return #<Process::Status: pid 55 exit 2>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params "su postgres -c 'psql $db_name -c \"alter schema public owner to $db_user;\"'"
bootstrap failed with exit code 2
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
0eed82a57ac12afa9bd1f7fe56c9d876fd06661813daa26f568dfc4bf3bd13e7

이건 표준 설치인가요?

postgres가 아직 시작 중인 것 같습니다. CPU가 매우 느린 건가요?

Postgres가 비표준 포트 사용하도록 구성되어 있는 것으로 보입니다.

다음과 같이 시도해 보세요.

ls -al /var/discourse/shared/standalone/postgres_run

제 설치 환경에서는 다음과 같은 결과가 표시됩니다.

total 28
drwxrwxr-x  5 systemd-resolve input   4096 Jan 26 15:43 .
drwxr-xr-x 13 root            root    4096 Jan 27  2021 ..
drwxr-x---  2 lxd             mlocate 4096 Jun  8  2020 10-main.pg_stat_tmp
drwxr-x---  2 lxd             mlocate 4096 Jan 27  2021 12-main.pg_stat_tmp
drwxr-xr-x  2 systemd-resolve input   4096 Mar 14 15:06 13-main.pg_stat_tmp
-rw-r--r--  1 systemd-resolve input      4 Jan 26 15:43 13-main.pid
srwxrwxrwx  1 systemd-resolve input      0 Mar 14 15:06 .s.PGSQL.5432
-rw-------  1 systemd-resolve input     62 Mar 14 15:06 .s.PGSQL.5432.lock

@Ed_S
표준 설치 방식입니다. 설정 파일을 수정하지 않았습니다.

@pfaffman
네, discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub 문서를 따르는 표준 설치 방식입니다.

작동하지 않는 원인을 이미 찾아냈는데, Let’s Encrypt와 관련된 문제였습니다.

아마도 요청 제한(rate limit)이 걸려서 SSL 인증서가 발급되지 않았던 것 같습니다.

app.yaml 파일에서 Let’s Encrypt를 비활성화하고, 제 SSL 인증서/키 조합을 사용하도록 설정한 뒤 다시 빌드했습니다.

이제 완벽하게 잘 작동합니다. 데이터를 복원하고 서버 마이그레이션을 완료했습니다.