diff --git a/中间件/redis/redis.md b/中间件/redis/redis.md index 5e43cda..bb95576 100644 --- a/中间件/redis/redis.md +++ b/中间件/redis/redis.md @@ -191,6 +191,11 @@ - [Configuration](#configuration) - [Timing of expired events](#timing-of-expired-events) - [Events in cluster](#events-in-cluster) + - [Redis Cluster Speification](#redis-cluster-speification) + - [Main properties and rationales of the design](#main-properties-and-rationales-of-the-design) + - [Redis Cluster Goals](#redis-cluster-goals) + - [Implemented subset](#implemented-subset) + - [Client and Server roles in the Redis cluster protocol](#client-and-server-roles-in-the-redis-cluster-protocol) # redis @@ -3174,4 +3179,25 @@ A Alias for "g$lshztdxe", so that the "AKE" string means all the events exce `Expired events`将会在redis server删除key时被生成,并非`ttl`减为0的时间。 ##### Events in cluster -redis cluster中的每个node都会生成其自己的keyspace相关事件。但是,和集群环境下`Pub/Sub`机制不同的是,`events notifications`并不会被广播到cluster中的其他节点。keyspace events是`node-specific`的,从cluster接收到所有的keyspace events时,clients需要为每个node都进行订阅。 \ No newline at end of file +redis cluster中的每个node都会生成其自己的keyspace相关事件。但是,和集群环境下`Pub/Sub`机制不同的是,`events notifications`并不会被广播到cluster中的其他节点。keyspace events是`node-specific`的,从cluster接收到所有的keyspace events时,clients需要为每个node都进行订阅。 + +## Redis Cluster Speification +### Main properties and rationales of the design +#### Redis Cluster Goals +Redis Cluster为redis的分布式实现,其目标按照重要性排序如下: +- 高性能,并且支持线性拓展到1000 nodes,并不会使用代理,并且不会对values执行merge operations +- `Acceptable degree of write safty`: 系统会尝试保留所有来源clients的写操作 +- `Availability`: redis cluster在`绝大多数master nodes可达,并且对每个master node都至少有一个replica可达`的场景下维持生存。此外,在使用`replicas migration`时,如果master不再拥有任何replica,那么其会从其他`拥有多个replicas的master`处接收一个replica。 + +#### Implemented subset +redis cluster实现了`所有非分布式版本redis支持的single key commands`。对于`performing complex multi-key operations`的命令,例如`set unions and intersections`,仅针对`所有keys都被hash到相同slot`的场景提供了实现。 + +redis cluster实现了`hash tags`的概念,用于强制让部分keys被存储到相同的slot。但是,在manual resharding的期间,multi-ey operations可能并不可用,而single-key operations则是永远可用的。 + +Redis Cluster并不像standalone版本的redis一样支持multiple databases,其只支持database 0。并且,`SELECT`命令在集群环境下不允许被执行。 + +### Client and Server roles in the Redis cluster protocol +在redis集群中,nodes负责对数据进行存储,并维护集群的状态,以及将keys映射到对应的nodes。cluster nodes可以自动发现其他的ndoes,并探知`non-working nodes`,在错误发生时将replica nodes提升为master。 + +cluster中所有的nodes都会通过TCP bus和名为`Redis Cluster Bus`的二进制协议来连结。其中,`TCP bus`是一种逻辑上的结构,代表cluster nodes中任两个nodes之间都会相互连接。 +