论坛无法使用

您好,我正在尝试启用 S3 备份到 Min.IO 服务器。当我将 app.yml 修改为我认为符合文档的内容,然后重建时,完成后在浏览器中看到的只是屏幕中间的 4 个彩色圆点。当我在控制台中查看时,我得到;

Uncaught ReferenceError: I18n is not defined
    at admin?v=103a67b2358b…86c5a58d96d4e91:1:1
wizard?v=ab2295f1774…85b733472935c34a0:1
Uncaught ReferenceError: I18n is not defined
    at wizard?v=ab2295f1774…b733472935c34a0:1:1

我对 app.yml 的修改如下;

  DISCOURSE_BACKUP_LOCATION: 's3'
  DISCOURSE_USE_S3: 'true'
  DISCOURSE_S3_REGION: 'off-cloud-backup'
  DISCOURSE_S3_ENDPOINT: 'http://borg....'
  DISCOURSE_S3_ACCESS_KEY_ID: '(my uid here)'
  DISCOURSE_S3_SECRET_ACCESS_KEY: '(my key here)'
  DISCOURSE_S3_CDN_URL: 'http://borg....'
  DISCOURSE_S3_BUCKET: 'assets'
  DISCOURSE_S3_BACKUP_BUCKET: 'discourse-data'
  DISCOURSE_S3_INSTALL_CORS_RULE: 'false'

在 Min 服务器上,我设置了区域,然后是一个名为“assets”的公共存储桶,然后是一个名为“discourse-data”的私有存储桶,以及匹配的凭据。我尝试过去掉变量周围的引号,以防万一,因为有些示例就是这样做的——没有变化。

如果我修改这些并重新启动,它们似乎不会生效。我需要重建才能激活它们,这使得测试周期非常痛苦。如果所有这些字段都可以在管理设置中找到,那会更容易一些,因为它们似乎在历史上一直存在,或者至少出现在某些人的屏幕截图中(?)

如果我注释掉 app.yml 中的所有 _S3 条目并重建,它就能正常工作。(我只是没有配置备份)(ENDPOINT 和 CDN URL 都解析到本地的正确 IP)

设置其他所有内容,包括订阅,都相对容易,但我在这上面遇到了瓶颈。有人知道我哪里做错了吗?

您只需要 S3 上的备份吗?如果是的话,您只需要密钥和备份存储桶。

您已将其配置为 S3 中的所有资产,但您可能遗漏了说明顶部用于预编译资产并将其推送到 S3 的 rake 任务部分。

您好,谢谢您的帮助,我将尝试以下两件事:

  • 使用 ACCESS、SECRET 和 BACKUP_BUCKET(以及端点?)重建
  • 尝试添加 rake 任务并重建

您说得对,我最初只想要数据,但一旦有什么东西能运行起来,我可能会转向处理资源。

话虽如此,但我(非常糟糕地)解读文档,导致网站几乎无法访问,这对于新手来说可能是一个潜在的问题。我不确定为什么控制台会报告 I18n 是一个问题,但它看起来像是在代码中进行一些小的修改,类似:

if (I18n && I18n.xxx) 

而不是:

if (I18n.xxx)

这或许可以保护新手免于破坏他们的网站……我应该去搜索并尝试提交一个 PR,还是应该由更有经验的人来处理?我很乐意尝试,但如果这没有用,我不想浪费时间……?

嗯,好的,取得了一些进展,精简后的设置现在允许页面呈现,但是我现在从服务器收到了“错误请求”。我正在使用 Min.io 的“mc”工具从 discourse 机器测试 S3 存储,它似乎运行正常,并且我可以列出存储桶……但是日志中我看到了;

Failed to list backups from S3: Aws::S3::Errors::BadRequest

/var/www/discourse/lib/backup_restore/s3_backup_store.rb:140:in `rescue in unsorted_files' 
/var/www/discourse/lib/backup_restore/s3_backup_store.rb:131:in `unsorted_files' 
/var/www/discourse/lib/backup_restore/backup_store.rb:23:in `files' 

我特意将 app.yml 中的设置复制粘贴到“mc”配置中,以确保没有拼写错误……所以我现在有点迷茫。明天可能再试一次……

它正试图列出存储桶的内容。
您不需要与资产相关的 rake 任务。

它正试图列出存储桶的内容。
你不需要与资产相关的 rake 任务。

好的,感谢您的帮助,我确实注意到了这一点,但它并没有真正起到作用。我尝试了 Min.io 和 SeaweedFS,都在本地配置好,以至于我能够使用 Discourse 机器上的命令行工具将文件写入 S3,但从 Discourse 内部来看,这两个选项似乎都不起作用。回顾花费的时间,我猜想如果备份是在线的并且是 S3,我可以看到直接备份到 S3 的选项很棒,但是如果你的备份是“云外”的,并且你只需要模拟 S3 存储来使用该选项,对我来说,这在时间上变得有点太昂贵了。

顺便说一句,我注意到有人说 CloudFlare S3 现在可以工作了,这对一些人来说可能不错。CloudFlare 似乎在其免费套餐中增加了 10G 的 S3,但对我来说,我的备份通常是在云外的 Borg 备份服务器上。

我所做的替代方法是,将 discourse 主机添加到我的备份 VPN,安装了 borgborgmatic,覆盖了主机上的 /var/discourse/shared/standalone/backups/var/discourse/shared/standalone/log,然后在本地备份计划的 30 分钟后将其添加到 cron 中。

问:您能否澄清一下本地备份是否涵盖了一切,或者我是否需要更多来覆盖上传?(额外的 rake 任务只是为了 S3 吗?)

我多疑的本性就是不信任云提供商同时提供实时系统和备份。每次我以为我可能想太多了,我都会提醒自己,有一次我接到客户的电话,说“我的服务器不工作了”,结果发现服务器被闪电击中了——就在服务器机房里。

您是否按照此处的 minio 特定说明进行操作? Configure an S3 compatible object storage provider for uploads

如果您只是更改那些 ENV 变量,那么您可以执行

  ./launcher destroy app;./launcher start app

如果您要将资产放在那里而不仅仅是备份,那么不要错过将资产推送到那里的 rake 任务。

1 个赞

您是否遵循了此处 minio 特定的说明?

是的,我遵循了。我很乐意承认我可能犯了错误,没有阅读/记住所有内容,但搜索相关文档并不是其中之一…… :wink:

./launcher destroy app;./launcher start app

好的,这对于将来参考很有用,我当时尝试的是停止/启动,对 docker 如何在启动时构建环境变量并不熟悉。

如果您要在那里放置资产而不仅仅是备份,那么不要错过将资产推送到那里的 rake 任务。

当然,这正是我有点困惑的地方,我会添加它们。我只是想知道为什么这些不包含在默认备份中,我知道有空间问题,但我的期望是人们通常想要备份所有内容?(而且由于大多数人似乎都不验证他们的内容,所以倾向于备份所有内容可能更安全?)

嗯,我先在我自己的测试实例上试了一下 (!) .. 我从文档中复制粘贴了两行 .. 是不是有什么东西过时了?

I, [2023-09-04T18:39:51.544973 #1]  INFO -- : cd /var/www/discourse/plugins & sudo -E -u discourse bundle exec rake s3:upload_assets
bundler: failed to load command: rake (/var/www/discourse/vendor/bundle/ruby/3.2.0/bin/rake)
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/definition.rb:524:in `materialize': Could not find css_parser-1.16.0, oj-3.16.1, rotp-6.3.0, globalid-1.2.0, google-protobuf-3.24.2-x86_64-linux in locally installed gems (Bundler::GemNotFound)
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/definition.rb:197:in `specs'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/definition.rb:254:in `specs_for'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/runtime.rb:18:in `setup'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler.rb:162:in `setup'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/setup.rb:23:in `block in <top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/ui/shell.rb:159:in `with_level'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/ui/shell.rb:111:in `silence'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/setup.rb:23:in `<top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:56:in `require_relative'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:56:in `kernel_load'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
        from /usr/local/bin/bundle:25:in `load'
        from /usr/local/bin/bundle:25:in `<main>'
I, [2023-09-04T18:39:52.163459 #1]  INFO -- : 
I, [2023-09-04T18:39:52.164462 #1]  INFO -- : Terminating async processes

我的 hooks 看起来是这样的;

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets
          - sudo -E -u discourse bundle exec rake s3:expire_missing_assets
          - sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-whos-online
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-reactions.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-subscriptions.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-topic-voting.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-calendar.git
          - sudo -E -u discourse git clone https://github.com/sylque/discourse-home-page.git
          - sudo -E -u discourse git clone https://github.com/sylque/discpage.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-onboarding-banner.git

那些 rake 任务不应该放在那里。

如果您的上传文件在 S3 上,那么您就依赖 S3 管理器来使其正常工作,因此您不需要备份。有一个隐藏的设置可以从 S3 下载资产并将其包含在备份中,但您几乎肯定不希望这样做。

Mmm, I’d noted previously that someone else had talked about putting stuff in the wrong section, then I went ahead and did the same thing anyway, eek (!)

So after reading more carefully, I still seem to have an issue, I have;

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-whos-online
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-reactions.git
          - git clone https://github.com/discourse/discourse-subscriptions.git
          - git clone https://github.com/discourse/discourse-topic-voting.git
          - git clone https://github.com/discourse/discourse-calendar.git
          - git clone https://github.com/sylque/discourse-home-page.git
          - git clone https://github.com/sylque/discpage.git
          - git clone https://github.com/discourse/discourse-onboarding-banner.git

  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets
          - sudo -E -u discourse bundle exec rake s3:expire_missing_assets

It says paste into app.yml in the hooks section .. does this look right or am I still in the wrong place? The error I’m getting now is;

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse &amp;&amp; sudo -E -u discourse bundle exec rake s3:upload_assets failed with return #&lt;Process::Status: pid 1845 exit 1&gt;
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "cmd"=>["sudo -E -u discourse bundle exec rake s3:upload_assets", "sudo -E -u discourse bundle exec rake s3:expire_missing_assets"]}
bootstrap failed with exit code 1

I’m looking back through the logs for more details but I’m not seeing anything. Unfortunately I’ve never coded in Ruby so I don’t really know what I’m looking at / for, any ideas?

Note; it advised running ./discourse-doctor, which I did, bit it didn’t seem to tell me anything different ..