Redis学习笔记#12 Redis Cluster 集群

Redis Cluster的模型

 Redis Cluster 以hash slot的方式分片

There are 16384 hash slots in Redis Cluster, and to compute what is the hash slot of a given key, we simply take the CRC16 of the key modulo 16384.

开始创建3主3从的redis集群 

创建配置文件redis.conf

port 7000
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-node-timeout 5000
appendonly yes

分别使用7000-7005这六个端口,注意port和cluster-config-file修改为对应端口

分别启动这六个redis服务

./redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1

 

集群配置成功

进入集群控制台

 ./redis-cli -c -p 7000

 重定向到7002上的slot

验证完成!

------------------------------------------------

参考资料:

https://www.jianshu.com/p/c869feb5581d

猜你喜欢

转载自www.cnblogs.com/sunang/p/12791984.html