Discourse升级通过Web UI失败和SSH升级导致Discourse实例崩溃

注意:原始帖子已于 11/25/21 EST 更新,包含新信息

在收到 Discourse 安装的关键安全更新通知后,我尝试使用 Web UI (/admin/upgrade) 更新我的安装,就像我过去所做的那样。有两个软件需要升级——Docker Manager 和 Discourse。

Docker Manager 必须先升级(Discourse 升级按钮被禁用)。我使用 Web UI 启动了 Docker Manager 升级,并成功完成。然后我启动了 Discourse 升级,但它在中途失败了。当我刷新 Web UI 时,我看到了以下消息:

因此,我按照屏幕上的说明,通过 SSH 登录到服务器,执行 git pull,然后从命令行运行 sudo ./launcher rebuild app。该过程完成,但以 FAILED TO BOOTSTRAP 错误消息失败。

以下是两次运行 sudo ./launcher rebuild app 的输出:

每个文件后面的行号是唯一 ERROR 出现的地方。两者似乎都与数据库和角色有关(这两个范围之间的差异是因为第二个尝试从 discourse/base 存储库执行 git pull)。

2021-11-25 21:21:38.451 UTC [64] postgres@postgres ERROR:  database "discourse" already exists
2021-11-25 21:21:38.451 UTC [64] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database "discourse" already exists
I, [2021-11-25T21:21:38.454429 #1]  INFO -- :
I, [2021-11-25T21:21:38.454908 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2021-11-25 21:21:38.531 UTC [68] postgres@discourse ERROR:  role "discourse" already exists
2021-11-25 21:21:38.531 UTC [68] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists

这似乎与每次 Launcher Rebuild 尝试底部显示的 FAILED 错误消息相吻合。

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 436 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
13bbdd52e0835ba9dfddc5c367d63b6087a16553c3a77d27ca307734d6e16907
** 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.

注意:这些 ERRORs 不是根本原因。请参阅下面的“解决方案”。

下面有些人说 redis 有问题,导致无法成功重建。

我在一天中的不同时间运行了 sudo ./discourse-doctor。这是两次运行的输出:

我通过运行 sudo docker run -it --rm hello-world 验证了我的 Docker 安装是否正常运行。

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

我运行了 sudo ./launcher cleanup 以确保我有足够的磁盘空间。

WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
<DETAILS REMOVED>

Total reclaimed space: 3.836GB

$ df -hT /dev/xvda1
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/xvda1     ext4   30G  9.1G   20G  32% /

我还检查了我的内存设置。

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           1.9G        304M        633M         20M        1.0G        1.5G
Swap:          2.0G          0B        2.0G

重启服务器并未解决问题,但在重启服务器后我确实注意到了一些有趣的事情。

Docker app 容器在重启后正在运行。

$ sudo docker ps
CONTAINER ID   IMAGE                 COMMAND        CREATED       STATUS          PORTS                                                                      NAMES
6449ec0061a0   local_discourse/app   "\"/sbin/boot\""   7 weeks ago   Up 25 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   app

但是当我访问网站时,我收到“502 Bad Gateway”错误。

当我停止 app 容器并访问网站时,我收到“无法连接”错误(这似乎是正确的,因为容器未运行)。

但这让我感到困惑,因为我的服务器上没有安装 Nginx

我可以在 Rebuild 输出中看到该过程正在将 Nginx 文件从一个位置复制到另一个位置,但我找不到相应的目录或文件,特别是服务器上的 nginx.conf。Ubuntu、Docker 和 Discourse 不是我的主要技能,但我假设这些文件正在“在”Docker app 容器内复制。

提前感谢;感谢您对此问题的任何额外帮助或指导,这个问题似乎在 Discourse 升级期间不时出现。

更新:事实证明,我的关于 Docker app 容器拥有自己的内部文件系统的假设是正确的。您可以创建容器文件系统的快照并使用 bash 探索该文件系统。

# create image (snapshot) from container filesystem
$ sudo docker commit <container_id> mysnapshot
$ sudo docker run -t -i mysnapshot /bin/bash

app 文件系统中有一个 nginx 目录,其中包含一个 Discourse 配置文件。

root@f91826d986eb:/etc/nginx/conf.d# ls -l
total 12
-rw-r--r-- 1 root root 10568 Oct  3 21:33 discourse.conf

如何重启? 从这里开始

此次更新需要重启 Docker。

因此,在命令行运行 ./launcher rebuild app 时,您的 Discourse 将会离线。

重建完成后将 100% 恢复正常。

@IAmGav Docker 似乎正在运行。

@rmccown ZSm8WzJ7gLigPd08D4tiwt.png)

我将尝试其他一些启动器命令,看看是否能让一切正常运行。

@IAmGav Ran ./discourse-doctor,它也确认了 Docker 容器正在运行。

==================== DOCKER INFO ====================
DOCKER VERSION: Docker version 20.10.11, build dea9396

DOCKER PROCESSES (docker ps -a)

CONTAINER ID   IMAGE                 COMMAND        CREATED       STATUS             PORTS                                                                      NAMES
6449ec0061a0   local_discourse/app   “/sbin/boot”   7 weeks ago   Up About an hour   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   app


Discourse 容器 app 正在运行


@rmccown 尝试了 startrestart,但都没有成功。

在 URL 仍然出现这个。

再次运行 sudo ./launcher rebuild app 以这些消息失败(目前正在查看文件以查找更早的错误消息)。

如果其他方法都失败了——你有没有试过拔掉电源再插上? ;-)\n\n重启实例:reboot now\n\n将实例更新到最新:apt-get updateapt-get dist-upgrade\n\n然后运行 Discourse 升级。

1 个赞

@omarfilip 我第一个就试了那个 :wink:

我刚刚又重启了一下(没有可以从早期升级中升级的 Ubuntu 18.04.6 组件)。

结果一样——URL 出现 502 网关错误。

不过还是谢谢你的建议。

1 个赞

我还发现了这个来自 2020 年 11 月的内容 - Upgrade ends with FAILED TO BOOTSTRAP

但我必须承认,我不知道“遵循我们的默认发布渠道”到底意味着什么。我猜想通过 Web UI 进行升级是“默认发布渠道”。

那将是“tests-passed”。如果您尚未修改 app.yaml 文件中的此行,那么您使用的是默认发布频道:

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

你能分享整个日志吗?这不足以看到实际的错误。

我正在使用默认的发布频道。

并且我的 db_shared_buffers 值不是 0MB(我在这里发现了这个问题)。

@IAmGav 这是包含 ./launcher rebuild app 输出的 gist - link

唯一的 ERROR 指示在以下几行中(见下文)。

它们似乎与数据库和角色的创建有关。有什么方法可以绕过这些操作吗?(我认为在升级过程中您会想要这样做,因为您正在处理一个预先存在的实例)

第 88-95 行

2021-11-25 21:21:38.451 UTC [64] postgres@postgres ERROR:  database "discourse" already exists
2021-11-25 21:21:38.451 UTC [64] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database "discourse" already exists
I, [2021-11-25T21:21:38.454429 #1]  INFO -- :
I, [2021-11-25T21:21:38.454908 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2021-11-25 21:21:38.531 UTC [68] postgres@discourse ERROR:  role "discourse" already exists
2021-11-25 21:21:38.531 UTC [68] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists

不久前,我遇到了完全相同的情况,一次 Web UI 更新过程中更新失败;即使在尝试重建后出现的错误消息也几乎相同,而且仍然没有解决;唯一不同的是,我可以在 Web UI 中更新一段时间,直到一两天前,在两周左右没有更新后,它现在出现了“您正在运行旧版本的 Discourse 镜像”的通知,而且我现在根本无法更新了。:upside_down_face:

显然,这是 redis 的一个问题。

各位 - 已根据当天收集到的信息更新了我的原始帖子。感谢到目前为止所有发帖的人。

不。还有另一个错误。尝试删除该插件。

Gem::ConflictError: 无法激活 omniauth-vkontakte-1.7.0,因为 omniauth-oauth2-1.7.2 与 omniauth-oauth2(>= 1.5, <= 1.7.1)冲突

3 个赞

遵循 Michael 在上面帖子中的建议,我在 app.yml 文件中注释掉了最初尝试使用 VK 插件进行 SSO 身份验证时添加的一个插件(我们从未采用此实现,但显然忘记从 app.yml 文件中删除该插件)。

## 插件在此处
## 详情请参阅 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-vk-auth.git

注释掉上面的行后,我再次运行了 sudo ./launcher rebuild app。重建后,论坛网站似乎已启动并运行(正在测试中)。

再次感谢所有花时间审阅我的帖子并发表评论的人。你们的帮助非常宝贵(在美国度过感恩节假期的更好方式 :wink:)。

注意安全。

4 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.