升级失败,表现得非常精彩

I have updated my several times over the years and mostly without issue. I got a message that my discourse needed to be updated. Initially i tried to use the web update but it said I needed to login and run ./launcher app rebuild. Which I did.

Below is the failure which appears to be related to the postgres upgrade. I searched the forum and see that there seems to be special instructions to upgrade postgres but not knowing that this was part of this update I did not follow them,. After the failure I tried to follow the steps but those fail as well.

this is the ouotput of the failed update:

wordsmith@digitalwind-ubuntu-20:/var/discourse$ sudo ./launcher rebuild app
[sudo] password for wordsmith:
Sorry, try again.
[sudo] password for wordsmith:
Sorry, try again.
[sudo] password for wordsmith:
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
remote: Enumerating objects: 765, done.
remote: Counting objects: 100% (299/299), done.
remote: Compressing objects: 100% (67/67), done.
remote: Total 765 (delta 252), reused 244 (delta 226), pack-reused 466 (from 4)
Receiving objects: 100% (765/765), 292.42 KiB | 9.75 MiB/s, done.
Resolving deltas: 100% (430/430), completed with 44 local objects.
From https://github.com/discourse/discourse_docker
   ffa8264..efd6bc8  main                               -> origin/main
 * [new branch]      consolidate_layers                 -> origin/consolidate_layers
 * [new branch]      dev-nginx-conf                     -> origin/dev-nginx-conf
 * [new branch]      docker-compose-generate            -> origin/docker-compose-generate
 * [new branch]      gh-action-upload-to-release        -> origin/gh-action-upload-to-release
 * [new branch]      nginx-conf-updates                 -> origin/nginx-conf-updates
 * [new branch]      parameterize-config-filename       -> origin/parameterize-config-filename
 * [new branch]      pento/dev-test-pnpm-10             -> origin/pento/dev-test-pnpm-10
 * [new branch]      revert_only_shipping_en_us_locales -> origin/revert_only_shipping_en_us_locales
 * [new branch]      slim-image-3                       -> origin/slim-image-3
 * [new branch]      update-build-compile-steps         -> origin/update-build-compile-steps
 * [new branch]      update-launcher                    -> origin/update-launcher
 * [new branch]      update_tag                         -> origin/update_tag
Updating Launcher...
Updating ffa8264..efd6bc8
Fast-forward
 .github/workflows/build.yml                   | 257 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
 .gitignore                                    |   2 +
 discourse-setup                               |  23 ++++++----
 image/README.md                               |  12 +----
 image/auto_build.rb                           | 103 +++++++++++++++++++++++++++++++++---------
 image/base/Dockerfile                         | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 image/base/install-imagemagick                |  26 +++++------
 image/base/install-jemalloc                   |   6 +--
 image/base/install-nginx                      |  13 +++---
 image/base/install-oxipng                     |  35 ++++++++-------
 image/base/install-redis                      |   4 +-
 image/base/install-ruby                       |  16 -------
 image/base/install-rust                       |   2 +-
 image/base/nginx_public_keys.key              | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 image/base/release.Dockerfile                 |  16 -------
 image/base/slim.Dockerfile                    | 128 ----------------------------------------------------
 image/discourse_bench/Dockerfile              |  34 --------------
 image/discourse_bench/run_bench.sh            |  19 --------
 image/discourse_dev/Dockerfile                |  38 ++++++++++++++--
 image/discourse_dev/postgres_dev.template.yml |  41 +++--------------
 image/discourse_fast_switch/Dockerfile        |  23 ----------
 image/discourse_fast_switch/create_switch.rb  |  24 ----------
 image/discourse_test/Dockerfile               |  10 ++---
 image/discourse_test/install-chrome           |   2 +-
 image/monitor/Dockerfile                      |  13 ------
 image/monitor/src/monitor.rb                  |  98 ----------------------------------------
 launcher                                      |   6 +--
 scripts/launcher-completion.bash              |  44 ++++++++++++++++++
 templates/import/mbox.template.yml            |   2 +-
 templates/import/mssql-dep.template.yml       |   2 +-
 templates/import/mysql-dep.template.yml       |   2 +-
 templates/import/phpbb3.template.yml          |   2 +-
 templates/import/vanilla.template.yml         |  30 +++++++------
 templates/postgres.10.template.yml            |   3 +-
 templates/postgres.12.template.yml            |   3 +-
 templates/postgres.13.template.yml            | 175 +++++++++++++++++++++++++++--------------------------------------------
 templates/postgres.15.template.yml            |  62 ++++++++++++++------------
 templates/postgres.9.5.template.yml           |   3 +-
 templates/postgres.template.yml               | 105 ++++++++++++++++++++++++++-----------------
 templates/redis.template.yml                  |   6 ++-
 templates/web.china.template.yml              |   3 +-
 templates/web.socketed.template.yml           |   4 +-
 templates/web.ssl.template.yml                |  32 ++++++-------
 templates/web.template.yml                    |  23 +++++-----
 44 files changed, 1186 insertions(+), 818 deletions(-)
 create mode 100644 image/base/Dockerfile
 delete mode 100755 image/base/install-ruby
 create mode 100644 image/base/nginx_public_keys.key
 delete mode 100644 image/base/release.Dockerfile
 delete mode 100644 image/base/slim.Dockerfile
 delete mode 100644 image/discourse_bench/Dockerfile
 delete mode 100644 image/discourse_bench/run_bench.sh
 delete mode 100644 image/discourse_fast_switch/Dockerfile
 delete mode 100644 image/discourse_fast_switch/create_switch.rb
 delete mode 100644 image/monitor/Dockerfile
 delete mode 100644 image/monitor/src/monitor.rb
 create mode 100644 scripts/launcher-completion.bash
Launcher updated, restarting...
WARNING: Docker version 20.10.7 deprecated, recommend upgrade to 24.0.7 or newer.
x86_64 arch detected.

WARNING: We are about to start downloading the Discourse base image
This process may take anywhere between a few minutes to an hour, depending on your network speed

Please be patient

2.0.20250129-0720: Pulling from discourse/base
af302e5c37e9: Pull complete
ed49ab5c933d: Pull complete
7cb9e730d898: Pull complete
7c28a6b187b2: Pull complete
23222af7238f: Pull complete
59b87d9ed5c1: Pull complete
90d60b432298: Pull complete
d3b3135aa82b: Pull complete
94e7b594395d: Pull complete
cf15e2c89d00: Pull complete
2c0cccf9ec27: Pull complete
5d8ea2a8d564: Pull complete
020f04b42275: Pull complete
06e22604f387: Pull complete
8b0ecc579aad: Pull complete
4d577f7424c0: Pull complete
37ef4781925f: Pull complete
30d67d1af761: Pull complete
43eaf8c26af4: Pull complete
02f4cc50eabd: Pull complete
93896ee36e56: Pull complete
fadd5d615e0e: Pull complete
85f9459cb30e: Pull complete
eaddca2afacb: Pull complete
f54443d29a2d: Pull complete
ed6f0f133683: Pull complete
3d1894dc563f: Pull complete
51ca3f63c909: Pull complete
b87374db2274: Pull complete
Digest: sha256:01b8516e5504c0e9bc3707773015ff4407be03a89154194ff3b5b8699291bc26
Status: Downloaded newer image for discourse/base:2.0.20250129-0720
docker.io/discourse/base:2.0.20250129-0720
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-06T00:07:56.208669 #1]  INFO -- : Reading from stdin
I, [2025-02-06T00:07:56.232158 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown:
I, [2025-02-06T00:07:56.237056 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown:
I, [2025-02-06T00:07:56.242252 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown:
I, [2025-02-06T00:07:56.246861 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown:
I, [2025-02-06T00:07:56.251666 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown:
I, [2025-02-06T00:07:56.253133 #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-06T00:07:56.254477 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-06T00:07:56.255380 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-06T00:07:56.256084 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-06T00:07:56.256905 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-06T00:07:56.257717 #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-06T00:07:56.258521 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-06T00:07:56.259186 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-06T00:07:56.265147 #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-06T00:07:56.266734 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-06T00:07:56.267608 #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-06T00:07:56.268347 #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-06T00:07:56.268965 #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-06T00:07:59.495629 #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-06T00:07:59.496900 #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-06T00:07:59.500783 #1]  INFO -- : Terminating async processes
2025-02-06 00:07:59.629 UTC [51] FATAL:  database files are incompatible with server
2025-02-06 00:07:59.629 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).

Help!!!

4 个赞

此更新中有一个 PostgreSQL 数据库版本更新。
我的安装是新的(6 个月),但在过去几天观看此论坛后,我仍然感到紧张。有几份报告称升级不完美,但大多数是针对旧的或迁移的数据库。

您的安装历史是什么?以获取更多提示。

以下是有关数据库升级和故障排除的更多信息:

好消息是,我的升级进行得很完美,所以升级是有效的。

祝你好运,是的。

我真希望在开始之前给自己发了一个备份邮件!
并且测试了我的 linode 备份是否有效……我刚刚还原了一个,但里面并不包含我以为的内容。

请分享您的 app.yml 文件内容?发布前请删除任何敏感信息。@Neptune

另外,请确认您的 Docker 版本。请参阅下面的主题,其中一个类似问题通过更新 Docker 得到了解决。

1 个赞

Docker 版本 20.10.7,构建 f0df350

这是我的 app.yml

## 这是全合一、独立的 Discourse Docker 容器模板
##
## 修改此文件后,您必须重建
## /var/discourse/launcher rebuild app
##
## 编辑时请*非常小心*!
## YAML 文件对空格或对齐错误非常非常敏感!
## 如有需要,请访问 http://www.yamllint.com/ 来验证此文件
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
## 如果您希望添加 Lets Encrypt (https),请取消注释这两行
## - "templates/web.ssl.template.yml"
## - "templates/web.letsencrypt.ssl.template.yml"

## 此容器应暴露哪些 TCP/IP 端口?
## 如果您希望 Discourse 与 Apache 或 nginx 等其他 Web 服务器共享端口,
## 请参阅 https://meta.discourse.org/t/17247 获取详细信息
## expose:
##   - "8080:80"   # http
##   - "8443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## 将 db_shared_buffers 设置为总内存的最多 25%。
  ## 将由 bootstrap 根据检测到的 RAM 自动设置,或者您可以覆盖它
  db_shared_buffers: "256MB"

  ## 可以提高排序性能,但会增加每个连接的内存使用量
  #db_work_mem: "40MB"

  ## 此容器应使用哪个 Git 版本? (默认:tests-passed)
  #version: tests-passed

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## 支持多少并发 Web 请求?取决于内存和 CPU 核心。
  ## 将由 bootstrap 根据检测到的 CPU 自动设置,或者您可以覆盖它
  UNICORN_WORKERS: 4

  ## TODO:此 Discourse 实例将响应的域名
  ## 必需。Discourse 不能与裸 IP 地址一起使用。
  DISCOURSE_HOSTNAME: wordsmiths.digitalwind.net

  ## 如果您希望容器以与上面指定的相同的主机名 (-h 选项) 启动,请取消注释
  ## (默认值 "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO:将成为初始注册的管理员和开发人员的电子邮件列表,用逗号分隔
  ## 示例 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'xxx@dev.null'

  ## TODO:用于验证新帐户和发送通知的 SMTP 邮件服务器
  # 需要 SMTP 地址、用户名和密码
  # 注意 SMTP 密码中的字符 '#' 可能会导致问题!
  DISCOURSE_SMTP_ADDRESS: dev.null
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: xxx@dev.null
  DISCOURSE_SMTP_PASSWORD: "not-here"
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: nope
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (可选,默认 true)
  DISCOURSE_SMTP_DOMAIN: dev.null
  DISCOURSE_NOTIFICATION_EMAIL: xxx@dev.null

  ## 如果您添加了 Lets Encrypt 模板,请取消注释下方以获取免费 SSL 证书
  LETSENCRYPT_ACCOUNT_EMAIL: xxx@dev.null

  ## 此 Discourse 实例的 HTTP 或 HTTPS CDN 地址(配置为拉取)
  ## 请参阅 https://meta.discourse.org/t/14857 获取详细信息
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com
  
  ## 用于 IP 地址查找的 MaxMind 地理位置 IP 地址密钥
  ## 请参阅 https://meta.discourse.org/t/-/137387/23 获取详细信息
  #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456

## Docker 容器是无状态的;所有数据都存储在 /shared 中
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## 插件在此处
## 请参阅 https://meta.discourse.org/t/19157 获取详细信息
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/discourse/discourse-voting.git
          - git clone https://github.com/discourse/wp-discourse.git
          - git clone https://github.com/discourse/discourse-spoiler-alert.git
          - git clone https://github.com/discourse/discourse-bbcode-color.git 
          - git clone https://github.com/discourse/discourse-calendar
          - git clone https://github.com/discourse/discourse-checklist
          - git clone https://github.com/discourse/discourse-reactions
          - git clone https://github.com/discourse/discourse-policy

## 任何自定义命令将在构建后运行
run:
  - exec: echo "Beginning of custom commands"
  ## 如果您想为您的第一次注册设置“发件人”电子邮件地址,请取消注释并更改:
  ## 在收到第一次注册电子邮件后,重新注释该行。它只需要运行一次。
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

我升级了 Docker 并尝试重新运行:

wordsmith@digitalwind-ubuntu-20:/var/discourse/containers$ docker --version
Docker version 27.5.1, build 9f9e405
wordsmith@digitalwind-ubuntu-20:/var/discourse/containers$ cd ..
wordsmith@digitalwind-ubuntu-20:/var/discourse$ sudo ./launcher app rebuild
检测到 x86_64 架构。
错误:containers/rebuild.yml 不存在或不可读。

可用配置 ( app )
wordsmith@digitalwind-ubuntu-20:/var/discourse$

您必须在控制台中通过运行 ./launcher rebuild app 来完成升级。

已有新的稳定版本发布。

上面我就是这么做的?

1 个赞

有人能帮帮我吗?我的安装仍然无法使用,我束手无策。

我是新手,但我会尽力帮助你。我读到你之前发帖说:

你是在正确的目录吗?
这是最近一次尝试和当前错误消息吗?

您是否按照建议重启了容器?

我建议重启容器、进行备份,然后迁移到一个带有最新操作系统的新虚拟机上。

1 个赞

我认为应该是 sudo ./launcher rebuild app

4 个赞

图形用户界面更新不会升级你的数据库,或者换句话说:你必须在此次从命令行升级才能获取进一步的更新。

2 个赞

这不会发生。
我可能看错了或者记错了,但我很确定你的Docker和操作系统已经不再支持,所以就不要再升级一切了。

不要升级。我最近帮过一个六年没有升级的人。他们仍在运行Ubuntu 14.04。

1 个赞

然而,它仍然是一个升级。而且由于数据库升级,您无法通过 GUI 进行操作 :man_shrugging:

1 个赞

它将完全相同。你仍然需要升级 Docker。你仍然需要升级数据库。如果我没记错你的版本的话,现在有一个稳定的版本可用。

1 个赞

这也许是一个过于绝对的说法。凭借这里一些人的技能,很可能可以修复这个问题。不过,在升级时,请永远记住第一条诫命:务必备份。

它们会。在您的 App yml 中,您可以将 Discourse 设置为 Stable Branch。但是,您仍然需要偶尔登录服务器进行升级。

这就是付费托管计划的好处,因为您不必担心崩溃,因为托管计划提供商会负责处理。

自托管有好处,但您可能会遇到麻烦,并且如果您无法解决。可能需要付费请人来纠正问题。这就是进行备份很重要的原因。特别是对于重大更新。您的 VPs 提供商还有一个选项可以创建服务器快照,如果通过命令行之类的更新“壮观地”失败,您可以恢复该快照。

在我超过 7 年的旅程中,我学到了许多新东西。最近,我启动了一个新服务器,并使用 Rsync 将我的论坛迁移到一个完全更新的当前 Ubuntu 服务器。旧的据我记忆是 Ubuntu 20.x。现在运行的是最新的,据我记忆是 Ubuntu 24.x。如果我没有花时间学习和完成这个,U 最终会有一个“壮观”的升级失败。

1 个赞

你为什么这么认为?
测试版并不意味着“不适合在生产环境中使用”。稳定版意味着更少的更改,从而导致更少的错误。然而,这也意味着更少的错误修复和新功能,因为只有安全错误修复会被反向移植。

1 个赞

您已经幸运了好几年。正如杰伊所说,您的 Docker 已过时,需要进行硬更新而不是 GUI 软更新。

Discourse 的创建者甚至明确表示,您需要偶尔进行命令行更新。在我早期使用这 7 年多的时间里,我曾亲眼看到 Web GUI 明确告诉我需要进行命令行更新。您有时还需要执行操作系统升级(或创建新服务器来刷新操作系统并将 Discourse 迁移到新服务器)。

这是自托管的一个缺点,即您作为自托管者必须维护后端并在需要时进行修复,或者前往 Marketplace 支付技能人士的费用。

1 个赞