로컬 서버에서 Discourse 설치: PostgreSQL 및 설치 스크립트 문제

Discourse 커뮤니티 여러분 안녕하세요,

저는 docker와 일반적인 리눅스 시스템 관리 작업에 있어 초보입니다. 회사에 Discourse 도입을 설득하고 있는데, 먼저 데모를 보여달라고 해서 지금 서버에 설치하려고 하고 있습니다.

로컬 서버에 Discourse를 설정하는 도중 몇 가지 문제를 겪고 있어 도움을 받고 싶습니다. 아래는 제 환경 설정과 지금까지 진행한 단계에 대한 요약입니다:

시스템 설정:

  • 운영체제: Ubuntu 20.04.6 LTS
  • Docker 버전: 24.0.5, build 24.0.5-0ubuntu1~20.04.1
  • Discourse 버전: 3.2

문제:
클라우드 서버에 Discourse를 설치하는 공식 가이드(discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub)를 따랐지만, PostgreSQL과 관련된 discourse-setup 스크립트에서 오류가 발생하고 있습니다.

진행한 단계:

  1. 프로세스 목록을 확인하여 PostgreSQL이 실행 중임을 확인했습니다.
  2. PostgreSQL이 올바른 포트(5432)로 수신 중인지, 그리고 유닉스 소켓 파일이 존재하는지 확인했습니다.
  3. “discourse” 데이터베이스와 사용자가 이미 존재한다는 오류가 발생했지만, psql 명령어로 확인해 보니 데이터베이스도 사용자도 목록에 나타나지 않았습니다.

사용한 명령어는 다음과 같습니다:

  • PostgreSQL 프로세스 확인: ps aux | grep postgres
  • PostgreSQL 수신 포트 확인: sudo netstat -plunt | grep postgres
  • 유닉스 소켓 파일 확인: ls -l /var/run/postgresql/.s.PGSQL.5432
  • “discourse” 데이터베이스 및 사용자 삭제 시도: su postgres -c 'psql -c "DROP DATABASE IF EXISTS discourse;"' 및 su postgres -c 'psql -c "DROP USER IF EXISTS discourse;"'
  • 데이터베이스 및 사용자 목록 조회: psql -c "\l" 및 psql -c "\du"

발생한 오류:

  • ERROR: database "discourse" already exists
  • ERROR: role "discourse" already exists
  • psql: error: FATAL: role "root" does not exist

이러한 오류에도 불구하고, PostgreSQL에서 직접 확인해 보면 “discourse” 데이터베이스와 사용자는 존재하지 않는 것으로 보입니다.
로그에는 다른 오류들도 있지만, 적어도 지금은 이 오류들이 관련이 있다고 생각합니다.

이 문제를 해결하는 방법에 대한 조언이나 제안을 주시면 감사하겠습니다. 비슷한 문제를 겪어 보신 분이 계시거나, 무엇이 잘못되었을지 통찰이 있으신 분이 계신가요?

미리 도움을 주셔서 감사합니다,
안드레아

Postgres를 설치할 필요가 없습니다. 표준 설치 환경에서는 Discourse 컨테이너에 자체 Postgres가 포함되어 있습니다. 기존에 설치된 Postgres를 제거하거나 삭제하는 것을 권장합니다. 기존 Postgres를 사용해야 할 이유가 있나요? 이 머신에서 다른 작업이 수행되고 있나요?

그것들은 오류가 아니라 디버깅 메시지일 뿐이라고 생각합니다.

스크립트 마지막에 어떤 내용이 표시되었나요?

Hi @pfaffman,
답변 주셔서 감사합니다.

아니요, 이 머신은 디스코드(Discord) 전용으로 사용되고 있습니다. 해당 오류를 확인한 후에 PostgreSQL을 설치했습니다.

로그를 첨부하고 싶은데 아직 방법을 찾지 못했습니다.

마지막 부분을 공유합니다:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -H -E -u discourse bash -c '
  set -o errexit
  if [ $(git rev-parse --is-shallow-repository) == "true" ]; then
      git remote set-branches --add origin main
      git remote set-branches origin tests-passed
      git fetch --depth 1 origin tests-passed
  else
      git fetch --tags --prune-tags --prune --force origin
  fi
' failed with return #<Process::Status: pid 146 exit 128>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"code", "cmd"=>["sudo -H -E -u discourse git reset --hard", "sudo -H -E -u discourse git clean -f", "sudo -H -E -u discourse bash -c '\n  set -o errexit\n  if [ $(git rev-parse --is-shallow-repository) == \"true\" 
]; then\n      git remote set-branches --add origin main\n      git remote set-branches origin $version\n      git fetch --depth 1 origin $version\n  else\n      git fetch --tags --prune-tags --prune --force origin\n  fi\n'", "sudo -H -E -u discourse bash -c '\n  set -o errexit\n  if [[ $(git symbolic-ref --short HEAD) == $version ]] ; then\n      git pull\n  else\n      git -c advice.detachedHead=false checkout $version\n  fi\n'", "sudo -H -E -u discourse git config user.discourse-version $version", "mkdir -p tmp", "chown discourse:www-data tmp", "mkdir -p tmp/pids", "mkdir -p tmp/sockets", "touch tmp/.gitkeep", "mkdir -p                    /shared/log/rails", "bash -c \"touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log\"", "bash -c \"ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log $home/log\"", "bash -c \"mkdir -p           /shared/{uploads,backups}\"", "bash -c \"ln    -s           /shared/{uploads,backups} $home/public\"", "bash -c \"mkdir -p           /shared/tmp/{backups,restores}\"", "bash -c \"ln    -s           /shared/tmp/{backups,restores} $home/tmp\"", "chown -R discourse:www-data /shared/log/rails /shared/uploads /shared/backups /shared/tmp", "[ ! -d public/plugins ] || find public/plugins/ -maxdepth 1 -xtype l -delete"]}
bootstrap failed with exit code 128
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

이제 PostgreSQL을 제거해 보겠습니다.

감사합니다,
Andrea

메모리가 부족합니다. 스왑 공간과/또는 RAM을 추가해야 합니다.

free -h
명령을 실행하면 어떤 결과가 나오나요?

대략 7GB가 사용 가능합니다.

              total        used        free      shared  buff/cache   available
Mem:          7.8Gi       319Mi       599Mi        13Mi       6.9Gi       7.1Gi
Swap:         975Mi       2.0Mi       973Mi

가이드에서는 약 2GB를 권장하고 있습니다.

The default of 1 GB RAM works fine for small Discourse communities. We recommend 2 GB RAM for larger communities.

무엇을 놓치고 있는 걸까요?

음. 이상하군. 최근 램 요구 사항과 관련하여 몇 가지 이상한 문제가 보고되었습니다. 몇 번 다시 시도해 보세요. 간헐적으로 실패한다는 보고도 있습니다.

수정: 죄송합니다. 127은 램(RAM)을 의미합니다. 128은 미확인 상태입니다.

OP에서 말씀하신 대로 처음부터 표준 설치를 실행하는 중이시죠? (discourse-setup 실행)

서버가 GitHub 및 기타 저장소에 액세스하지 못하게 막을 수 있는 방화벽 뒤에 계신 건 아닌가요?

네, 맞습니다. GitHub 가이드를 따르고 있습니다.
문제가 Postgres가 아니라 마지막 메시지라면, 로그에서 실패하는 지점이 여기입니다.

  set -o errexit
  if [ $(git rev-parse --is-shallow-repository) == "true" ]; then
      git remote set-branches --add origin main
      git remote set-branches origin tests-passed
      git fetch --depth 1 origin tests-passed
  else
      git fetch --tags --prune-tags --prune --force origin
  fi
'
fatal: unable to access 'https://github.com/discourse/discourse.git/': server certificate verification failed. CAfile: none CRLfile: 
none

그 머신에서 리포지토리를 클론할 수 있음에도 불구하고, GitHub에 제대로 연결할 수 없는 것 같습니다.

도커 네트워크 문제입니다. 도커를 어떻게 설치하셨나요? 설치를 해제하고 다른 방식으로 설치해 보시는 것을 고려해 보세요.

OS나 네트워크에 방화벽이 있나요? DNS 문제일 수도 있습니다. 흔히들 말하듯, 항상 DNS 문제인 법이죠.

현재 OS에 방화벽이 설치되어 있지 않다는 것은 알고 있습니다. 하지만 Docker 설치 관련 세부 사항은 IT 부서와 상의해야 합니다.
어떤 DNS 문제를 겪고 있을지 혹시 짐작이 가시나요? 도움이 될 수 있는 로그 섹션이나 디버그 메시지가 있을까요? (아직도 파일을 첨부할 수 없습니다)

@pfaffman이 제 셸 히스토리에 해당 세부 사항이 남아 있다는 것을 알아차렸습니다.

   63  sudo apt install docker.io
   64  sudo apt remove containerd runc
   65  sudo apt remove containerd
   66  curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
   67  echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   68  sudo apt update
   69  sudo apt install docker-ce
   70  sudo apt upgrade
   71  sudo apt install docker.io

docker-ce와 docker.io를 모두 설치할 수 없다고 생각합니다. 두 패키지를 모두 제거한 후 그중 하나만 설치하는 것이 좋습니다.

저는 보통 https://get.docker.com/를 사용합니다. 제 방법은 새 VM을 만들고 해당 스크립트만 사용하는 것입니다.