大家好,
如何完全关闭 AWS S3 存储,并将 S3 存储中的所有文件和备份恢复到我的 EC2 服务器上?
大家好,
如何完全关闭 AWS S3 存储,并将 S3 存储中的所有文件和备份恢复到我的 EC2 服务器上?
我相信这会解决问题:
./launcher enter app
rake uploads:migrate_from_s3
rake posts:rebake
这将把上传文件从 S3 迁移到你的 Web 服务器。之后,你可以返回 app.yml 文件,将 DISCOURSE_USE_S3: false 进行修改。然后重新构建。
我也会进入 Discourse 的管理后台,取消勾选所有激活 S3 模式的复选框。
我按照 @AntiMetaman 的建议操作了,但出现了 rake aborted 错误。首先,它提示我关闭 S3 上传。我关闭了 S3 上传后再次尝试运行 rake,随后出现了这个错误。
root@ip-172-31-7-247-app:/var/www/discourse# rake uploads:migrate_from_s3 --trace
** Invoke uploads:migrate_from_s3 (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:migrate_from_s3
Migrating uploads from S3 to local storage for 'default'...
rake aborted!
NoMethodError: undefined method `downcase' for nil:NilClass
/var/www/discourse/app/models/global_setting.rb:107:in `s3_bucket_name'
/var/www/discourse/app/models/site_setting.rb:157:in `absolute_base_url'
/var/www/discourse/lib/tasks/uploads.rake:138:in `migrate_from_s3'
/var/www/discourse/lib/tasks/uploads.rake:118:in `block in migrate_all_from_s3'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.3.0/lib/rails_multisite/connection_management.rb:68:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.3.0/lib/rails_multisite/connection_management.rb:78:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:118:in `migrate_all_from_s3'
/var/www/discourse/lib/tasks/uploads.rake:93:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => uploads:migrate_from_s3
就是这个,对吧?

我今天看到了这个话题。如果可以的话,不妨再等等。
如果你仅在管理面板中关闭 S3,那只会禁用站点级别的 S3。你需要全局禁用它,因此必须在 app.yml 中将值从 true 改为 false,然后重新构建。
如果你已正确配置 S3,它应该可以正常工作。我刚刚尝试了 migrate_from_s3 和 migrate_to_s3,对我而言运行正常,没有遇到任何错误。我不清楚这个错误的具体含义,因此建议联系 Discourse 开发者寻求帮助:
NoMethodError: undefined method 'downcase' for nil:NilClass
奇怪,我下面的回复被删除了,所以我再次发布。
当对 nil 对象调用字符串方法时会出现该错误;在 Ruby 中,这通常发生在预期为字符串对象但实际为 nil 的情况下。
这就是该错误发生的原因。
已在 app.yml 中添加了 DISCOURSE_USE_S3: false,但错误依旧。请问您使用的是哪个版本的 Discourse?我使用的是最新版本。
我也是最新版本。你在重新构建时遇到任何错误了吗?如果有,能贴出来吗?
不,没有任何错误。
如果错误仅出现在执行 rake 命令之后,能否请你贴出你输入的确切命令?当初你配置好 S3 时,是不是还需要将文件迁移到 S3?
这是我的完整 app.yml 文件
templates:
expose:
params:
db_default_text_search_config: “pg_catalog.english”
db_shared_buffers: “128MB”
#db_work_mem: “40MB”
#version: tests-passed
env:
LANG: en_US.UTF-8
UNICORN_WORKERS: 2
DISCOURSE_HOSTNAME: engineersasylum.com
#DOCKER_USE_HOSTNAME: true
DISCOURSE_DEVELOPER_EMAILS: ‘praveen369gen@gmail.com’
DISCOURSE_SMTP_ADDRESS: email-smtp.us-east-1.amazonaws.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: AXXXXXXXXXXXXXXX
DISCOURSE_SMTP_PASSWORD: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (可选,默认为 true)
LETSENCRYPT_ACCOUNT_EMAIL: praxxxxxx@gmail.com
#DISCOURSE_CDN_URL: //discourse-cdn.example.com
DISCOURSE_USE_S3: false
volumes:
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone GitHub - discourse/docker_manager: Plugin for use with discourse docker image · GitHub
- git clone GitHub - discourse/discourse-solved: Allow accepted answers on topics · GitHub
- git clone GitHub - discourse/discourse-adplugin: Official Discourse Advertising Plugin. Install & Start Serving Ads on Your Discourse Forum · GitHub
- git clone https://github.com/communiteq/discourse-sitemap.git
- git clone GitHub - discourse/discourse-whos-online: A plugin for Discourse which uses the messagebus to display a live list of active users · GitHub
- git clone GitHub - discourse/discourse-push-notifications: Plugin for integrating Chrome and FireFox push notifications · GitHub
- git clone GitHub - discourse/discourse-chat-integration · GitHub
- git clone GitHub - davidtaylorhq/discourse-telegram-notifications: A plugin for Discourse which allows users to receive their notifications by telegram message · GitHub
- git clone GitHub - discourse/discourse-docs · GitHub
- git clone GitHub - discourse/discourse-math: Official MathJax support for Discourse · GitHub
run:
#- exec: rails r “SiteSetting.notification_email=‘info@unconfigured.discourse.org’”
我不太记得确切的情况了,但我想我使用 rake uploads:migrate_to_s3 迁移到了 S3。
我完全不清楚,但这里有一个与你遇到的错误完全相同的类似帖子:
建议你与团队成员确认一下。
你好 @Pravi
侧边栏问题:
在你发布的 yml 文件中,你“写道”:
DISCOURSE_SMTP_PASSWORD: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
这是正确的吗?你的 yml 文件中的密码是否使用了双引号?
是的,它使用了双引号。自两年前添加以来,我从未修改过它。
我已经移除了双引号,然后重新构建了应用。接着再次尝试运行 rake uploads:migrate_from_s3,但依然没有成功。错误依旧。
我对 Discourse 的内部脚本了解不多,有点不敢编辑脚本,担心会搞砸一切。
你能告诉我 discourse.config 文件的位置吗?我在服务器上到处都找不到。find 命令没有返回任何结果。
root@ip-172-31-7-247:/var/discourse# find . -name "*.config"
root@ip-172-31-7-247:/var/discourse# find . -name "*.conf"
./shared/standalone/letsencrypt/engineersasylum.com/engineersasylum.com.conf
./shared/standalone/letsencrypt/engineersasylum.com/engineersasylum.com.csr.conf
./shared/standalone/letsencrypt/engineersasylum.com_ecc/engineersasylum.com.conf
./shared/standalone/letsencrypt/engineersasylum.com_ecc/engineersasylum.com.csr.conf
./shared/standalone/letsencrypt/ca/acme-v01.api.letsencrypt.org/ca.conf
./shared/standalone/letsencrypt/ca/acme-v02.api.letsencrypt.org/ca.conf
./shared/standalone/letsencrypt/account.conf
./shared/standalone/postgres_data/pg_hba.conf
./shared/standalone/postgres_data/postgresql.auto.conf
./shared/standalone/postgres_data/pg_ident.conf
./shared/standalone/postgres_data/postgresql.conf
root@ip-172-31-7-247:/var/discourse#
你好 @Pravi
抱歉让你产生了误解。
我并没有要求你编辑那个文件或任何其他文件。
在我看来,“逆向工程”一个脚本意味着研究它、了解它是如何工作的,这与编辑文件毫无关系。它指的是阅读并理解它。
通常,如果我们阅读并理解任何报错的脚本或文件,我们就能明白如何解决问题。
你似乎并没有阅读那个文件,却仍在发布来自该文件的错误信息。
希望这能有所帮助。
我理解你的意思。我会尝试去做。
你能告诉我 ‘discourse.config’ 文件的位置吗?S3 的配置存储在哪里?