手动更新 Discourse 和 Docker 镜像至最新版

:bookmark: 本指南提供了在自托管环境中手动更新 Discourse、Docker 容器和 Ubuntu 操作系统的一步一步的说明。

:person_raising_hand: 所需用户级别:系统管理员

:warning: 需要 SSH 访问服务器。

如果您自托管 Discourse,您需要不时地通过命令行运行手动更新,以获取最新的安全补丁和最新的库。

这些更新不会在 admin/upgrade 中被检测到,这就是您偶尔需要执行这些额外步骤的原因:

更新 Discourse

  1. Discourse 本身应该大约每半个月更新一次,方法是点击您的管理仪表板(admin/upgrade)中的“更新到最新版本”按钮。

  2. 我们建议每两个月通过 SSH 连接到您的 Web 服务器(使用 putty 或您最喜欢的 SSH 客户端)并运行以下命令,特别是当升级页面未显示或您在尝试升级时遇到任何问题时。

cd /var/discourse
./launcher rebuild app

更新 Docker 镜像和 Ubuntu 操作系统

对于 Ubuntu 更新,请_务必_为您的 Ubuntu 启用自动安全更新!命令是:

dpkg-reconfigure -plow unattended-upgrades

然而,这只涵盖了关键安全更新。您应该时不时地像这样获取所有操作系统更新:

apt-get update
apt-get dist-upgrade

这也将通过标准的 docker-ce 包保持 Docker 的最新状态。

总结一下:

  • 每半个月通过 Web 更新器更新 Discourse
  • 每两个月更新容器
  • 每六个月更新操作系统

您可以将这些数字加倍,仍然相当安全,例如,每月更新一次 Discourse,每 4 个月更新一次容器,每年更新一次操作系统,依此类推。

但您真的、_真的_需要启用 Ubuntu 中的自动安全更新,如上所述。

常见问题解答

什么时候是正确的更新时间?

这完全取决于您可用的时间和您想保持在最新技术前沿的程度。如果您有非官方插件,强烈建议使用测试/暂存站点。如果您没有任何非官方插件,您可能会立即升级,但即使如此,一些插件可能也会在团队修复它们期间出现几天的中断(插件数量很多)。

安装了许多插件时,常见的做法是什么?

如果您安装了许多插件,强烈建议在本地或测试服务器上进行测试。特别是如果您有非官方插件,因为某些东西可能会损坏。如果您发现任何东西确实损坏了,那么问题在于,您是否有时间修复它?原始插件作者是否有时间修复它?这两者都可能需要数周时间。所以至少以这种方式,您只有一个损坏的测试站点,而不是一个损坏的生产站点。

我的磁盘空间不足

如果您的磁盘空间不足(使用 df 检查),请尝试使用以下命令清理旧映像:

./launcher cleanup
apt-get autoclean
apt-get autoremove

更新实际的 Ubuntu 服务器版本重要吗,因为 Discourse 始终在 Docker 中运行?

它的重要性要小得多。但您至少应该使用目前受支持的 Ubuntu 服务器 LTS 版本。需要 64 位 Linux 操作系统和现代内核版本。

178 个赞
"Upgrade all" button is awesome!
Ubuntu 16.04 LTS - upgrade or migrate?
Cannot upgrade due to old version of docker
Daily performance reports keep asking to rebuild container
No longer getting notifications for out of date containers
Discourse stopping working - CPU/RAM load?
Manual upgrade fails
Upgrade container - keeping config and data
Installed OK. Working fine for one day. Suddenly stopped working
Issues upgrading from 1.6.0.Beta10+9 to 2.3.0.beta6
Upgrade link no longer works
Update error, website unavailable, possibly plugin related?
How to optimize storage?
Why do I need a block storage?
Digital Ocean hosting: Do I need a system admin?
Will not load, no access to installation, aufs not installed - my fix
Upgrade V2.1 Beta 2 to Beta 4 Require ./launcher rebuild app Twice
Some trouble updating (many bugs)
What makes a successful volunteer Discourse sysadmin?
Searching locks up the server for a while
Link-image not shown
Oops - Error 500 After Update From Admin Dashboard
Crash After Recent Update
Edit CSS/HTML editor cursor offset makes it unusable due to CSS font override
Oops The software powering this discussion forum encountered an unexpected problem
Upgrades via UI disabled - and not being re-enabled after SSH upgrade
Error upgrading, failed to bootstrap
Help after updating from ssh site goes down
My Discourse is Down. Certificate Issue?
Unable to update Discourse...help?
Reset password link error
Empty update page?
My website is always down
Upgrade container - keeping config and data
Failed to update Discourse new version
Unable to upgrade docker_manager
Undefined method `timeout=' for Regexp:Class
How often should I update Discourse?
Migration failed: relation "user_required_fields_versions" already exists
Kernel version upgrade required when manually updating discourse
Cannot rebuild following site failure: "postgres already running"
Visiting /admin/upgrade may lead to a server error
Updating I get a "Configuring openssh-server" message about the "sshd_config" file
Update Not Completing
Problem with api version when updating docker manager
Problem with Upgrade [error 137]
Problem updating my installation
Update in browser vs Terminal
Docker update to latest version
How often should I update Discourse?
Self hosted Reply by Email stopped working after latest update
Error 500 how to fix?
Site down after UI update
Docker update to latest version
Selectable avatars upload broken (Missing required UppyUpload config: id)
Discourse broken after failed upgrade
How to tell whether to upgrade via web or console?
Oops The software powering this discussion forum encountered an unexpected problem
Determining whether my VPS needs any upgrades (generally)
Kernel version upgrade required when manually updating discourse
Upgrade button is 500-ing for me
1.4.3 Upgrade Oddity?
Add path to cookie
Your Docker installation is not working correctly - no space left on device - safe to use ./launcher cleanup?
PNG's a no show
Upgrade from v2.0.0.beta10 +37 to 2.1.0.beta1 does fail
Kernel Panic after droplet reboot... What now?
Failed to bootstrap 1.6.0.beta 8 with out of date docker
Problem with category style = box under firefox
Site fails to load with js errors
ERROR: You are running an old version of the Discourse image
Service not available | Update Error due to broken plugin
What do you want to do about modified configuration file grub?
Failed Upgrade Discourse and Plugins
Insert Date Timezone is always UTC ; my Timezone is ignored
Admin upgrade page does not exist
Upgrading from 2.9.0.beta8 broke the site, unrecoverable
Error when upgrading and would like to solve or reset
Update failed - Not starting
Failed to rebuild: no such file /usr/local/etc/ImageMagick-6/policy.xml
Upgrade ends with FAILED TO BOOTSTRAP
"400 Bad Request" error after upgrading
Hello, after clicking login, it takes 20 seconds to load before you can enter my page. why?

指南的审查和更新相当频繁(这一个似乎在二月份进行了一些小调整)。:+1:

其中我个人不熟悉的是 Docker 的指南:

但我可以保证其余内容的准确性。:slight_smile:

3 个赞

我在测试站点上运行了所有这些命令,包括 Docker 更新,它们运行正常。

5 个赞

我收到报告称运行此命令时出现问题。我认为在我拥有 DO 测试站点的几年里,我从未亲自使用过它。

有人最近有过使用经验,可以说明这是否仍然是相关的建议吗?


我刚浏览了已删除的帖子,发现有几个帖子之前也提到了指南中的那部分 [1],并且似乎 @MarkDoerr 在没有问题的情况下运行了它。

但我仍然不确定您何时/在何种情况下需要运行它?我对 Docker Manager 的信任是否过多?


  1. 我已经取消删除它们 ↩︎

2 个赞

2 篇帖子被拆分到一个新主题:何时更新双容器设置的数据容器?

帖子已拆分为新主题:升级 v2.2.0.beta4 论坛(包含未知本地更改)

已尝试运行该命令(wget -qO- https://get.docker.com/ | sh),但报告了以下错误:

无法连接到 Docker 守护进程(位于 unix:///var/run/docker.sock)。Docker 守护进程是否正在运行?

看起来这并没有成功更新 Docker。

似乎这也导致了整个站点崩溃,并且在重建应用程序时报告:

无法连接到 Docker 守护进程 - 请验证它是否正在运行并且您有权访问

重启服务器后,站点已恢复联机。

所以也许它确实完成了升级,但未能重启 Docker。你可以用以下命令检查:

docker --version

事实证明我的笔记本电脑有一个旧的 Docker,我运行了推荐的命令,并且无需重启即可使其正常工作。这是我得到的版本:

$ docker --version
Docker version 26.1.4, build 5650f9b
1 个赞

具有相同的 Docker 版本:

Docker version 26.1.4, build 5650f9b
1 个赞

那么您就已更新,一切正常!

3 个赞

我记得我见过这份涵盖 Discourse 更新节奏的文档,但由于它在“使用 Docker”下的 Documentation 中,并且标题为“手动更新 Docker”,因此很难再次找到它。

既然它涵盖了 Discourse 和 Ubuntu 的更新,是否可以在其他地方也列出呢?

1 个赞

当 Discourse 建议您更新图像时(因此无法从 UI 进行升级),它会告诉您这样做:

    cd /var/discourse
    git pull
    ./launcher rebuild app

这个额外的 git pull 是做什么用的?为什么您不在手册中推荐它?

3 个赞

它是一个旧的遗迹,不再需要了。Rebuild 可以做到。

2 个赞

我创建一个PR?

3 个赞
6 个赞

已合并,感谢 @tvavrda

6 个赞