# Redis Sentinel 的支持

**URL:** <https://meta.discourse.org/t/support-for-redis-sentinel/163608>\
**Category:** Development\
**Created:** [2020年九月10日 12:09 UTC](https://meta.discourse.org/t/support-for-redis-sentinel/163608 "2020-09-10T12:09:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierreozoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pierreozoux/32/296611_2.png) [@pierreozoux](https://meta.discourse.org/u/pierreozoux)\
**Post date:** [2020年九月10日 12:09 UTC](https://meta.discourse.org/t/support-for-redis-sentinel/163608/1 "2020-09-10T12:09:13Z")

</div>

你好，

我注意到 [你几年前移除了 sentinel 选项](https://github.com/discourse/discourse/commit/5dc4b469be6524ba26448f8f4a56ab5a63dcd53c)。

具体原因是什么？

如果我提交一个 PR，你们会接受吗？

如果不接受，那我就打补丁。如果你有关于如何打补丁的建议就更好了，毕竟我很久没写 Ruby 了；)

谢谢！

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2020年九月10日 14:35 UTC](https://meta.discourse.org/t/support-for-redis-sentinel/163608/2 "2020-09-10T14:35:10Z")

</div>

我认为这从未奏效过。

只需将高可用 Redis 的关注点从 Discourse 中分离出来，并使用 HAProxy 将流量导向主节点或从节点。

示例配置（主节点在 6379，从节点在 6380）

```
listen redis_master
  bind 127.0.0.1:6379
  timeout client 30h
  timeout server 30h
  option tcp-check
  tcp-check connect
  tcp-check send AUTH\ *redis_password*\r\n
  tcp-check expect string +OK
  tcp-check send PING\r\n
  tcp-check expect string +PONG
  tcp-check send info\ replication\r\n
  tcp-check expect string role:master
  tcp-check send QUIT\r\n
  tcp-check expect string +OK
  server redis_data_0 10.10.10.10:6379 check inter 1s
  server redis_data_1 10.10.10.11:6379 check inter 1s

listen redis_slave
  bind 127.0.0.1:6380
  timeout client 30h
  timeout server 30h
  option tcp-check
  tcp-check connect
  tcp-check send AUTH\ *redis_password*\r\n
  tcp-check expect string +OK
  tcp-check send PING\r\n
  tcp-check expect string +PONG
  tcp-check send info\ replication\r\n
  tcp-check expect string role:slave
  tcp-check send QUIT\r\n
  tcp-check expect string +OK
  server redis_data_0 10.10.10.10:6379 check inter 1s
  server redis_data_1 10.10.10.11:6379 check inter 1s

```

---

<div class="post-metadata">

**Author:** ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)\
**Post date:** [2020年九月11日 00:37 UTC](https://meta.discourse.org/t/support-for-redis-sentinel/163608/3 "2020-09-11T00:37:01Z")

</div>

> [@pierreozoux](#):
>
> 是否有特定原因？

被移除的代码被视为实验性内容，我们近期没有支持它的计划。

---

<div class="post-metadata">

**Author:** ![pierreozoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pierreozoux/32/296611_2.png) [@pierreozoux](https://meta.discourse.org/u/pierreozoux)\
**Post date:** [2020年九月11日 10:27 UTC](https://meta.discourse.org/t/support-for-redis-sentinel/163608/4 "2020-09-11T10:27:38Z")

</div>

> [@pierreozoux](#):
>
> 如果我提交一个拉取请求（PR），你会接受吗？

听起来像是“不会”，但也不太明确 🙂

（不过，还是要感谢你目前的见解 🙂 ）

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2020年九月11日 10:52 UTC](https://meta.discourse.org/t/support-for-redis-sentinel/163608/5 "2020-09-11T10:52:04Z")

</div>

抱歉，是的，我认为插件是更好的选择。Sentinel 从未为我们很好地工作过，因此我们更倾向于不在核心产品中将其作为社区选项提供。
