# 高重建内存需求：2025年4月版

**URL:** <https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419>\
**Category:** Self-hosting\
**Tags:** hosting\
**Created:** [2025年三月31日 00:37 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419 "2025-03-31T00:37:29Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![schneeland](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schneeland/32/275391_2.png) [@schneeland](https://meta.discourse.org/u/schneeland)\
**Post date:** [2025年四月13日 11:58 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/21 "2025-04-13T11:58:00Z")

</div>

好的，下一个测试已完成。

我使用以下插件构建：

```plaintext
https://github.com/discourse/docker_manager.git
https://github.com/discourse/discourse-data-explorer
https://github.com/communiteq/discourse-legal-compliance
https://github.com/pfaffman/discourse-allow-pm-to-staff
https://github.com/singerscreations/discourse-stopforumspam
https://github.com/discourse/discourse-cakeday

```

交换空间被禁用，因此只有 4GiB/3.8GB RAM。

构建期间的最大内存使用量为 3.4GB。构建时间为 6m 48s。

---

<div class="post-metadata">

**Author:** ![Milenski](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/milenski/32/493345_2.png) [@Milenski](https://meta.discourse.org/u/Milenski)\
**Post date:** [2025年七月2日 20:27 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/22 "2025-07-02T20:27:46Z")

</div>

我遇到的问题是交换文件，在将其从0增加到2GB后，目前一切正常。

```bash
sudo fallocate -l 2G /swapfile        
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

```

在你的服务器终端中执行。之后，重新构建。

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月14日 20:50 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/23 "2026-02-14T20:50:08Z")

</div>

我发现在重建时内存需求大幅增加。我有 8GB 内存，即使添加了 8GB 交换文件，在执行此步骤时仍然空间不足：`cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate`

这是一个包含四个论坛的多站点安装。我以前从未需要添加交换文件。

_编辑_ 现在尝试使用 16G 交换文件，但仍然内存不足。

这是在 Linux 下进行的，启用了最少的插件。

---

<div class="post-metadata">

**Author:** ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)\
**Post date:** [2026年二月15日 04:48 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/24 "2026-02-15T04:48:13Z")

</div>

嗯……我想，文档是否应该更新以反映更高的内存要求？[Introducing pre-compiled JS assets for self-hosters](https://meta.discourse.org/t/introducing-pre-compiled-js-assets-for-self-hosters/376700/1) 有助于减少加载吗？我本以为有了这个更改，需要的内存会更少 🤔 。

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月15日 07:42 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/25 "2026-02-15T07:42:13Z")

</div>

自从我进行重建以来可能已经有几个月了，但在 8GB 内存且没有交换空间的情况下，它之前运行良好。我仍然没有解决这个问题，所以所有四个站点都已关闭。

我不知道这是否相关，但直到我设置了环境变量 `HOME: /var/www/discourse` 它才构建成功——否则它会尝试写入 /root 并被拒绝访问权限。

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月15日 08:02 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/26 "2026-02-15T08:02:51Z")

</div>

嗯，我看到了上百个这样的进程：

```plaintext
node /usr/bin/pnpm add pnpm@10.28.0 --loglevel=error --allow-build=@pnpm/exe --no-dangerously-allow-all-builds --config.node-linker=hoisted --config.bin=bin

```

这是某种 fork 炸弹吗？

---

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2026年二月15日 08:20 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/27 "2026-02-15T08:20:30Z")

</div>

请务必增加大量的交换空间，即使只是为了让您恢复运行。在这里使用交换空间的优势在于构建是一个临时峰值。

我使用两个容器的设置，在引导期间内存压力更大，因为您还有两个正在运行的容器。😅

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月15日 08:29 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/28 "2026-02-15T08:29:04Z")

</div>

我现在添加了 40GB 的交换空间，但仍然不够。

我看到了数百个这样的 node 进程，这似乎是问题所在？

我开始认为根本原因与我早些时候遇到的问题相同，当时我必须设置 `HOME: /var/www/discourse`，否则它会尝试写入 /root 下的文件。但我不知道该怎么做。

---

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2026年二月15日 08:31 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/29 "2026-02-15T08:31:49Z")

</div>

好的，出了点大问题。我也会考虑备份并从头开始重建。

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月15日 08:32 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/30 "2026-02-15T08:32:31Z")

</div>

我该如何着手处理？

---

<div class="post-metadata">

**Author:** ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)\
**Post date:** [2026年二月15日 08:35 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/31 "2026-02-15T08:35:01Z")

</div>

参见：

> [@Backup discourse from the command line](https://meta.discourse.org/t/backup-discourse-from-the-command-line/64364):
>
> bookmark This guide covers how to back up and restore your Discourse site using command line tools, specifically designed for self-hosted environments. person_raising_hand Required user level: Administrator information_source You can use the below placeholders to automatically fill out the command line prompts in this guide: Backing up To create a backup of your Discourse site, follow these steps: Enter the container: ./launcher enter app Run the backup: discourse backup…

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月15日 08:47 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/32 "2026-02-15T08:47:26Z")

</div>

谢谢，我想我先将整个服务器恢复到上一个已知良好的状态，然后从一个可工作的系统进行备份。  
有人知道可能出了什么问题吗？

---

<div class="post-metadata">

**Author:** ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)\
**Post date:** [2026年二月15日 15:16 UTC](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419/33 "2026-02-15T15:16:51Z")

</div>

问题确实与 `HOME` 未正确设置有关，向 `sudo` 命令添加 `-H` 以进行多站点迁移解决了问题，详情请参见：

> [@Multisite configuration with Docker](https://meta.discourse.org/t/multisite-configuration-with-docker/14084/184?u=yaxu):
>
> I followed this tutorial to set up with success a multisite install with Docker. I recently [ran into an error when trying to upgrade](https://meta.discourse.org/t/mutlisite-installation-pnpm-permission-error-during-rebuild/393702/2) and I believe the line: - exec: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate Should be edited to: - exec: cd /var/www/discourse && sudo -H -E -u discourse bundle exec rake multisite:migrate Could anyone confirm/edit the tutorial?

[上一頁](https://meta.discourse.org/t/high-rebuild-memory-requirements-april-2025-edition/360419.md?page=1)
