集群简介
redis集群结构设计
数据存储设计
集群内部通讯设计
最多找两次就能找到!
redis集群(cluster)结构搭建
集群结构
- 配置服务器(3主3从)
- 建立通信(Meet)
- 分槽(Slot)
- 搭建主从(master-slave)
Cluster配置
6个节点全配置
开启集群
redis-cli -a 1234 --cluster create 192.168.135.10:6371 192.168.135.10:6372 192.168.135.10:6373 192.168.135.11:6374 192.168.135.11:6375 192.168.135.11:6376 --cluster-replicas 1
- –cluster-replicas 1 :表示一个master连一个slave,如果改成–cluster-replicas 2表示一个master连2个slave
root@centos8:/usr/local/bin# redis-cli -a 1234 --cluster create 192.168.135.10:6371 192.168.135.10:6372 192.168.135.10:6373 192.168.135.11: Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Performing hash slots allocation on 6 nodes... Master[0] -> Slots 0 - 5460 Master[1] -> Slots 5461 - 10922 Master[2] -> Slots 10923 - 16383 Adding replica 192.168.135.11:6376 to 192.168.135.10:6371 Adding replica 192.168.135.10:6373 to 192.168.135.11:6374 Adding replica 192.168.135.11:6375 to 192.168.135.10:6372 M: 8fa990153bfb999537769c06ce7a65390e816294 192.168.135.10:6371 slots:[0-5460] (5461 slots) master M: 8996717269b57ca3656a594e615e1258f5ee7833 192.168.135.10:6372 slots:[10923-16383] (5461 slots) master S: 4435a05753efbf883e08e8019866f0e0534dcbc3 192.168.135.10:6373 replicates 31b753b0fe52e0196e8a33149d11a82fdfafdad0 M: 31b753b0fe52e0196e8a33149d11a82fdfafdad0 192.168.135.11:6374 slots:[5461-10922] (5462 slots) master S: b47f12ca63f08daedc5c97704811a7207992fd70 192.168.135.11:6375 replicates 8996717269b57ca3656a594e615e1258f5ee7833 S: 089b98bebcf054c39c6eadab31741529ead62268 192.168.135.11:6376 replicates 8fa990153bfb999537769c06ce7a65390e816294 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 192.168.135.10:6371) M: 8fa990153bfb999537769c06ce7a65390e816294 192.168.135.10:6371 slots:[0-5460] (5461 slots) master 1 additional replica(s) S: 089b98bebcf054c39c6eadab31741529ead62268 192.168.135.11:6376 slots: (0 slots) slave replicates 8fa990153bfb999537769c06ce7a65390e816294 S: b47f12ca63f08daedc5c97704811a7207992fd70 192.168.135.11:6375 slots: (0 slots) slave replicates 8996717269b57ca3656a594e615e1258f5ee7833 S: 4435a05753efbf883e08e8019866f0e0534dcbc3 192.168.135.10:6373 slots: (0 slots) slave replicates 31b753b0fe52e0196e8a33149d11a82fdfafdad0 M: 8996717269b57ca3656a594e615e1258f5ee7833 192.168.135.10:6372 slots:[10923-16383] (5461 slots) master 1 additional replica(s) M: 31b753b0fe52e0196e8a33149d11a82fdfafdad0 192.168.135.11:6374 slots:[5461-10922] (5462 slots) master 1 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
放与取数据
加一个-c的参数,这是专门用来操作cluster集群的
Cluster节点操作命令