注意:原始帖子已于 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 的输出:
- launcher-rebuild-app-output-0.txt - 第 88-95 行
- launcher-rebuild-app-output-1.txt - 第 100-107 行
每个文件后面的行号是唯一 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。这是两次运行的输出:
- discourse-doctor-output-0.txt - 找不到正在运行的 ‘app’ 容器;尝试重建但未能重新启动容器
- discourse-doctor-output-1.txt - 在运行
discourse-doctor之前,使用sudo usr/bin/docker start app手动启动了 ‘app’
我通过运行 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








