How to set redis DB ID in Docker container?

I have one data container and I would like to use several web_only containers (several forums on separate servers). How to I pass a DB ID to web_only container so that multiple forums use their own cache?

Without this the stats reported in Admin -> Reports are mixed up between different forums.

I’ve got the same issue. I have an existing redis cluster (with replication and failover) that I want Discourse to use, but I can’t find a way to tell Discourse which database index to use.

I’ve found the corresponding setting via this answer. It’s hidden in discourse_defaults.conf:

It’s called redis_db, so the corresponding setting in the container yaml should be DISCOURSE_REDIS_DB.

Definitely do not do anything like this :fire: . Message Bus which is responsible for long polling relies on pub/sub, pub/sub is always on “db 0” not configurable.

If you try to co-host multiple Discourses on one Redis DB expect some very major amount of breakage.

Thank you for the warning! :bowing_man:

@sam,你 2018 年关于消息总线仅链接到 Redis db 0 的警告:fire: 是否仍然准确?或者我们现在能否使用不同的 Redis 实例数据库 ID 来托管不同的 Discourse 实例?

我注意到在 multisite-configuration-with-docker 的教程中,定义了 db_id: 2。我原以为这可能指的是 Redis 数据库 ID,因此提出此疑问:face_with_monocle:

         secondsite:
           adapter: postgresql
           database: b_discourse
           pool: 25
           timeout: 5000
           db_id: 2
           host_names:
             - b.discourse.example.com

[quote=“TomekB, post:1, topic:56267”]
如果没有这个设置,管理员面板中“报告”部分统计的数据会在不同论坛之间混淆。[/quote]

[quote=“rluba, post:3, topic:56267”]
该设置名为 redis_db,因此容器 YAML 中的对应设置应为 DISCOURSE_REDIS_DB。[/quote]

[quote=“sam, post:4, topic:56267, full:true”]
绝对不要这样做:fire:。负责长轮询的消息总线依赖于发布/订阅(pub/sub)功能,而 pub/sub 始终在“db 0”上运行,无法配置。

如果你尝试在同一个 Redis 数据库中托管多个 Discourse 实例,预计会出现非常严重的故障。[/quote]

是的,据我所知,这仍然是 100% 正确的。Redis 的 PUB/SUB 功能绑定在 DB 0。Discourse 的多站点设计旨在让多个实例能够与使用 db 0 的单个 Redis 正常通信。

Pub/Sub 与键空间无关。其设计目的是在任何层面(包括数据库编号)都不对其造成干扰。

在 db 10 上发布,db 1 上的订阅者也能收到。