启动redis实例2个,监听6379、6380端口。
配置主从:
1.127.0.0.1:6380> slaveof 127.0.0.1 6379
2.设置aemonize no=> yes (若有); redis.conf中的port后加入slaveof 127.0.0.1 6379
配置集群:
1.登陆6379客户端,
2.127.0.0.1:6379>cluster meet 127.0.0.1 6380
3.127.0.0.1:6379>cluster nodes
4.分配槽,共16384个,每个分配m=16384/n
5.cluster addslots {0...m}
6.查看状态 127.0.0.1:6379>cluster info
7.建议配置虚槽,每个节点配置主从
127.0.0.1:6382>cluster replicate cfb28ef1deee4e0fa78da86abe5d24566744411e (cluster nodes中主库标识)
OK
127.0.0.1:6383>cluster replicate 8e41673d59c9568aa9d29fb174ce733345b3e8f1
OK
127.0.0.1:6384>cluster replicate 40b8d09d44294d2e23c7c768efc8fcd153446746
OK
8.完成
参考资料:https://my.oschina.net/zhangxufeng/blog/905611