# 将节流重新烘焙以防止内存耗尽？

**URL:** https://meta.discourse.org/t/throttle-rebake-to-keep-from-running-out-of-memory/392914
**Category:** Support
**Created:** [2026年一月7日 20:10 UTC](https://meta.discourse.org/t/throttle-rebake-to-keep-from-running-out-of-memory/392914 "2026-01-07T20:10:27Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![DavidO](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@DavidO](https://meta.discourse.org/u/DavidO)
#### Post date: [2026年一月7日 20:10 UTC](https://meta.discourse.org/t/throttle-rebake-to-keep-from-running-out-of-memory/392914/1 "2026-01-07T20:10:28Z")

</div>

我正尝试重新烘焙 45k 帖子，因为我更改了 S3 CDN URL，但它一直耗尽内存并被终止。

我阅读了这篇关于设置交换文件（swapfile）的文章……

> [@Create a swapfile for your Linux server](https://meta.discourse.org/t/create-a-swapfile-for-your-linux-server/13880):
>
> bulb For servers with \<= 2GB of RAM, running ./discourse-setup will prompt for and automatically create a 2GB swapfile. Most cloud virtual machine providers do not set up swapfiles as part of their server provisioning. In particular, upgrading Discourse produces a lot of memory pressure. With a swap file, rather than randomly terminating processes with an out of memory error, things will slow down instead. Having a swap file is a cheap insurance policy that protects you from many other lo…

前两个命令运行正常……

1. 创建一个空的交换文件  
`install -o root -g root -m 0600 /dev/null /swapfile`

2. 写入一个名为 ‘swapfile’ 的 2GB 文件  
`dd if=/dev/zero of=/swapfile bs=1k count=2048k`

但在 `mkswap /swapfile` 时出现错误……

**mkswap 错误 swapfile 已挂载，无法创建交换空间**

我尝试了以下方法……

> [@Installation Error](https://meta.discourse.org/t/installation-error/274937/2):
>
> What you get from free df -h The install script has detected you have less than 2G of RAM and less than 2G of swap, and is trying to create a swapfile. According to [the source](https://github.com/discourse/discourse_docker/blob/main/discourse-setup#L193C1-L225C5), it doesn’t deal with the case where there is an existing swapfile. Probably you should remove the existing swapfile and try again. This might be enough: swapoff /swapfile && rm /swapfile free

`swapoff /swapfile && rm /swapfile`

并收到此错误……

**swapoff: 不是超级用户**

我在 Digital Ocean Droplet 上，所以我想我没有必要的权限？

遇到这些障碍后，我尝试运行以下命令来重新烘焙未烘焙的帖子……

`rake posts:rebake_uncooked_posts`

它会运行几百个，如果幸运的话，可能会有几千个，然后又被终止。在昨天一直看着它之后，我只完成了大约一半。😉

是否有办法运行一个有节流的重新烘焙命令？我不在乎它需要多长时间，过夜或任何时间，我只是希望它不要再失败了。

非常感谢任何帮助。

---

_[View the full topic](https://meta.discourse.org/t/throttle-rebake-to-keep-from-running-out-of-memory/392914)._
