➜ yaml $ docker exec -it redis-cluster-1 bash root@a7875167255d:/data# redis-cli --cluster create 10.1.62.101:6371 10.1.62.101:6372 10.1.62.101:6373 >>> Performing hash slots allocation on 3 nodes... Master[0] -> Slots 0 - 5460 Master[1] -> Slots 5461 - 10922 Master[2] -> Slots 10923 - 16383 M: 827efbbd222514e9310690c6d0c8013ca473935b 10.1.62.101:6371 slots:[0-5460] (5461 slots) master M: edd79c53980d8f56581a156d54db0ffad5f69bdb 10.1.62.101:6372 slots:[5461-10922] (5462 slots) master M: 70e470e76a1fb102a37da6507358cca6f276924a 10.1.62.101:6373 slots:[10923-16383] (5461 slots) master Can I set the above configuration? (type'yes' to accept): yes >>> Nodes configuration updated >>> Assign a different config epoch to each node >>> Sending CLUSTER MEET messages to join the cluster Waiting for the cluster to join . >>> Performing Cluster Check (using node 10.1.62.101:6371) M: 827efbbd222514e9310690c6d0c8013ca473935b 10.1.62.101:6371 slots:[0-5460] (5461 slots) master M: edd79c53980d8f56581a156d54db0ffad5f69bdb 10.1.62.101:6372 slots:[5461-10922] (5462 slots) master M: 70e470e76a1fb102a37da6507358cca6f276924a 10.1.62.101:6373 slots:[10923-16383] (5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
当你看到 [OK] All 16384 slots covered. 的时候,就说明咱们的集群创建成功了。
试一试
1 2 3 4 5 6 7 8 9
root@a7875167255d:/data# redis-cli -c -p 6371 127.0.0.1:6371> set name nic -> Redirected to slot [5798] located at 10.1.62.101:6372 OK 10.1.62.101:6372> set age 18 -> Redirected to slot [741] located at 10.1.62.101:6371 OK 10.1.62.101:6371> keys * 1) "age"