> For the complete documentation index, see [llms.txt](https://docker.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docker.shujuwajue.com/redis-ji-qun/redis-ji-qun-an-zhuang.md).

# Redis 集群介绍

> 主从同步
>
> * Redis集群中的数据库复制是通过主从来实现的
> * 主节点（Master）把数据分发给从节点（Slave）
> * 主从同步的好处在于高可用，Redis节点有冗余设计
>
> ![](/files/-LfnTKeojA_67546Ql2M)

## Redis集群高可用性

采用官方的**RedisCluster方案**，注意redis3.x之后支持，要让 Redis 集群正常工作至少需要 3 个 Master 节点，要想实现高可用，每个 Master 节点要配备 至少 1 个 Slave 节点。根据以上特点和要求，进行如下的集群实施规划： 使用 6 台服务器（物理机或虚拟机）部署 3 个 Master + 3 个 Slave；

> 搭建redis集群时，Redis集群中应该包含奇数个Master，至少应该有3个Master节点，为什么？
>
> 因为redis集群包括PXC集群都有选举机制，当集群中超过一半数量的节点挂点，剩余的节点是无法进行选举组成一个新的集群的。
>
> 比如使用两个节点的Master集群，一个Master节点挂掉，剩余的节点没有超过一半，redis集群不可用。三个节点的Master集群，一个挂掉，剩余节点过半，还可以进行选举组成一个新的集群。

![](/files/-LfnTKeqAo0hG6XTIqIQ)

> 为什么不需要配置redis的负载均衡？ 因为比如java的spring框架，php的包，nodejs的包内部实现了集群的负载均衡


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docker.shujuwajue.com/redis-ji-qun/redis-ji-qun-an-zhuang.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
