将上传和备份移到DigitalOcean块存储

So you want to move all uploads and backups to DigitalOcean Block Storage?

Before you do this, though, you might instead consider Configure an S3 compatible object storage provider for uploads. It is no more complicated to set up and provides some other advantages.

Setup a Discourse instance on DigitalOcean

Setup a Discourse instance on DigitalOcean using our official guide.

Add a Volume to your droplet

Add a block storage volume to your droplet. Note down the name of the volume. In my case the name of the volume was volume-nyc1-05.

Make sure the volume is formatted and mounted at /mnt/volume_nyc1_05.

Move /var/discourse/shared to the volume

For best performance we will keep postgres_data on our main drive and will move rest of the data to the newly attached volume.

Logged in as root, run these commands from your server:

mv /var/discourse/shared/standalone/postgres_data /var/postgres_data_discourse
mv /var/discourse/shared /mnt/volume_nyc1_05

Make sure to replace volume_nyc1_05 with the name of your volume.

Edit app.yml to reflect the changes

Open the /var/discourse/containers/app.yml file in your preferred editor and look for this block:

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

Replace the above block with:

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /mnt/volume_nyc1_05/shared/standalone
      guest: /shared
  - volume:
      host: /mnt/volume_nyc1_05/shared/standalone/log/var-log
      guest: /var/log
  - volume:
      host: /var/postgres_data_discourse
      guest: /shared/postgres_data

Make sure to replace volume_nyc1_05 with the name of your volume.

Save the app.yml file and rebuild the container.

/var/discourse/launcher rebuild app

:tada: Voila!

That’s it all your uploads and backups are now moved to DigitalOcean Block Storage.


Credits

This guide is inspired from @sam’s suggestion here.

37 个赞

我正在尝试遵循 Hetzner 的一种类似存储的方法,但我担心这会影响我们的整体性能。

我了解到它提供的 SSD 速度只有 1/3,但我想知道这在日常使用中上传文件和显示 Discourse 实例中的文件方面是否存在显著差异,因为我不确定这 1/3 的速度是否真的会产生影响,或者是否足以满足上传文件的需求。

当然,最终结果取决于我们的 CPU、RAM 以及使用的文件系统和块大小。

有人愿意分享他们的经验吗? :slight_smile:

感谢指南!

在执行此操作之前,您应该关闭液滴吗?我通常会假设是的,但既然它只是在改组上传?

不。只需创建空间并按照说明进行安装。

感谢您的指导。在我完成所有步骤并重新启动论坛后,我们不断发现图片未能加载。因为它有一个不正确的路径。

有什么方法可以诊断这个问题并进行一些自动修复吗?

你最终解决问题了吗?

1 个赞

没有 :frowning: 还没能修复它。

1 个赞