数量大致均等的将哈希槽映射到不同的节点。
接下来我们将redis安装到 redis01中,然后make编译一下,会发现在src文件中出现:
redis-trib.rb拷贝到redis-cluster目录下。
>>>> Creating cluster
>Connecting to node .:: OK
>Connecting to node .:: OK
>Connecting to node .:: OK
>Connecting to node .:: OK
>Connecting to node .:: OK
>Connecting to node .:: OK
>>>> Performing hash slotsallocation on nodes...
>Using masters:
>.:
>.:
>.:
>Adding replica .: to .:
>Adding replica .: to .:
>Adding replica .: to .:
>M: 5a8523db7e12ca600dc82901ced06741b3010076127..:
> slots:- ( slots) master
>M: bf6f0929044db485dea9b565bb51e0c917d20a53127..:
> slots:- ( slots) master
>M: c5e334dc4a53f655cb98fa3c3bdef8a808a693ca127..:
> slots:- ( slots) master
>S: 2a61b87b49e5b1c84092918fa2467dd70fec115f127..:
> replicates 5a8523db7e12ca600dc82901ced06741b3010076
>S: 14848b8c813766387cfd77229bd2d1ffd6ac8d65127..:
> replicates bf6f0929044db485dea9b565bb51e0c917d20a53
>S: 3192cbe437fe67bbde9062f59d5a77dabcd0d632127..:
> replicates c5e334dc4a53f655cb98fa3c3bdef8a808a693ca
>Can I the above configuration? (type to accept): >yes
>>>> Nodes configuration updated
>>>> Assign a different configepoch to each node
>>>> Sending CLUSTER MEET messagesto join the cluster
>Waiting the cluster to join.....
>>>> Performing Cluster Check( node .:)
>M: 5a8523db7e12ca600dc82901ced06741b3010076127..:
> slots:- ( slots) master
>M: bf6f0929044db485dea9b565bb51e0c917d20a53127..:
> slots:- ( slots) master
>M: c5e334dc4a53f655cb98fa3c3bdef8a808a693ca127..:
> slots:- ( slots) master
>M: 2a61b87b49e5b1c84092918fa2467dd70fec115f127..:
> slots: ( slots) master
> replicates 5a8523db7e12ca600dc82901ced06741b3010076
>M: 14848b8c813766387cfd77229bd2d1ffd6ac8d65127..:
> slots: ( slots) master
> replicates bf6f0929044db485dea9b565bb51e0c917d20a53
>M: 3192cbe437fe67bbde9062f59d5a77dabcd0d632127..:
> slots: ( slots) master
> replicates c5e334dc4a53f655cb98fa3c3bdef8a808a693ca
>[OK] All nodes agree about slotsconfiguration.
>>>> Check open slots...
>>>> Check slots coverage...
>[OK] All slots covered.
跳转,这就是因为他经过计算以后,要存储100的hash槽在7003 实例上。这样就表示我们的集群成功了!
关闭redis集群不能直接kill掉进程,或者关机,我们要通过命令redis01/redis-cli -p 7001 shutdown进行关闭,这样在关闭之前,数据才能够进行保存。