设置独立的Redis时出错

有一个半闲置的数据库服务器在本地网络中运行 PostgreSQL,我也想将其用于 Discourse。这样做的原因是,Web 服务器的压力远大于前面提到的数据库服务器,后者仍有大量未使用的资源/潜力。按照论坛上的一些帖子(示例)进行操作,将 Discourse 的 PostgreSQL 重定向相当容易。但是,当我尝试为 Redis 做同样的事情时:

  • 注释掉 - "templates/redis.template.yml"
  • 改为设置 DISCOURSE_REDIS_HOST

当我尝试使用 launcher rebuild app 重新构建时,我总是会收到以下错误:

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 582 exit 1>
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", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1

这是一个已知问题吗?有人成功地将 Discourse 与非容器化的 Redis 结合使用吗?

这确实是你所需要的。你能粘贴完整的重建错误吗?你可能需要密码、强制 TLS 或一个无法访问的域。哪一个应该在重建日志中清楚地显示。

1 个赞

基本上就是这样了。日志中还有一些更靠上的警告:

warning " > @mixer/parallel-prettier@2.0.3" has unmet peer dependency "prettier@^2.0.0".
warning "eslint-config-discourse > eslint-plugin-lodash@7.1.0" has unmet peer dependency "lodash@>=4".
warning " > babel-plugin-debug-macros@0.4.0-pre1" has unmet peer dependency "@babel/core@^7.0.0".
warning "workspace-aggregator-3fff36d0-9fd8-4d1a-ac4c-d10694a59627 > discourse > @uppy/aws-s3@3.0.6" has incorrect peer dependency "@uppy/core@^3.1.2".
warning "workspace-aggregator-3fff36d0-9fd8-4d1a-ac4c-d10694a59627 > discourse > @uppy/aws-s3-multipart@3.1.3" has incorrect peer dependency "@uppy/core@^3.1.2".
warning "workspace-aggregator-3fff36d0-9fd8-4d1a-ac4c-d10694a59627 > discourse > @uppy/xhr-upload@3.1.1" has incorrect peer dependency "@uppy/core@^3.1.2".

但即使在使用容器化 Redis 重建时,这些警告也一直存在。

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 581 exit 1>
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", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
2533af220cc44d8c77bc12c17ed7635dee49ba7f280[...]

更新:

找到了标记为 INFO 而不是 error 的行,这可能就是原因,我猜:

I, [2023-04-06T18:44:02.460059 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'LOAD_PLUGINS=0 bundle exec rake plugin:pull_compatible_all'
I, [2023-04-06T18:44:04.581741 #1]  INFO -- : docker_manager is already at latest compatible version

I, [2023-04-06T18:44:04.581929 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
Discourse requires Redis 6.2.0 or up
I, [2023-04-06T18:44:05.937604 #1]  INFO -- :

而相当新的 Ubuntu 22.04.2 LTS 提供了:

Package: redis-server
Architecture: amd64
Version: 5:6.0.16-1ubuntu1

哎呀……这个版本没法用了,对吧?

我认为 Discourse 使用了一些仅在 6.2 版本中引入的 Redis 命令。

您也可以通过 Redis 的官方 APT 存储库进行安装:

https://redis.io/docs/getting-started/installation/install-redis-on-linux/

3 个赞

是的,这正是我所做的,谢谢。我只希望这条消息被标记为 ERROR 而不是 INFO(在许多其他 INFO 消息中),并能立即停止。我花了大量时间调试各种东西,却没有注意到这一行。

Redis 不会占用太多资源,而且您无法与多个服务器共享它。我只会使用已经正常工作的 Discourse 的那个。