Redis5.x Cluster deployment practice
Experimental environment
Hostnam
IP address
Redis port partition
Remarks
Node171
172.20.20.171
16001,16002
Node172
172.20.20.172
16001,16002
Node173
172.20.20.173
16001,16002
Software version
Operating system: CentOS X64 7.3
Redis version: 5.0.5
Common basic configuration
All three are operated, there is no special description here, all are root operations.
1. Turn off the firewall
Systemctl stop firewalld.service
Setenforce 0
Sed-I's setting SELINUXFORCING'/ etc/selinux/config
two。 Configure Hostnam
Cat > > / etc/hosts > > Performing hash slots allocation on 6 nodes...
Master [0]-> Slots 0-5460
Master [1]-> Slots 5461-10922
Master [2]-> Slots 10923-16383
Adding replica 172.20.20.172:16002 to 172.20.20.171:16001
Adding replica 172.20.20.173:16002 to 172.20.20.172:16001
Adding replica 172.20.20.171:16002 to 172.20.20.173:16001
M: a9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171:16001
Slots: [0-5460] (5461 slots) master
S: 81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171:16002
Replicates 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2
M: 761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172:16001
Slots: [5461-10922] (5462 slots) master
S: 6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172:16002
Replicates a9ab7a12884d505efcf066fcc3aae74c2b3f101d
M: 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173:16001
Slots: [10923-16383] (5461 slots) master
S: 14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173:16002
Replicates 761348a0107f5b009cabc22c214e39578d0aa707
Can I set the above configuration? (type 'yes' to accept): yes # enter 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 172.20.20.171purl 16001)
M: a9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171:16001
Slots: [0-5460] (5461 slots) master
1 additional replica (s)
S: 81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171:16002
Slots: (0 slots) slave
Replicates 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2
M: 761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172:16001
Slots: [5461-10922] (5462 slots) master
1 additional replica (s)
S: 14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173:16002
Slots: (0 slots) slave
Replicates 761348a0107f5b009cabc22c214e39578d0aa707
S: 6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172:16002
Slots: (0 slots) slave
Replicates a9ab7a12884d505efcf066fcc3aae74c2b3f101d
M: 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173:16001
Slots: [10923-16383] (5461 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.
Verification test
[root@node172 conf] # / opt/redis/bin/redis-cli-h 172.20.20.172-p 16001
172.20.20.172purl 16001 > cluster nodes
04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173 connected 16001mm 26001 master-0 1563967987854 5 connected 10923-16383
A9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171 connected 16001mm 26001 master-0 1563967985839 1 connected 0-5460
81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171 connected 16002mm 26002 slave 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 0 1563967983822 5
6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172 connected 16002mm 26002 slave a9ab7a12884d505efcf066fcc3aae74c2b3f101d 0 1563967988858
14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173 connected 16002mm 26002 slave 761348a0107f5b009cabc22c214e39578d0aa707 0 1563967986847 6
761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172 761348a0107f5b009cabc22c214e39578d0aa707 16001mm 26001 myself,master-0 1563967986000 3 connected 5461-10922
172.20.20.172 16001 > set name "Mr.Zhang"
OK
172.20.20.172purl 16001 > get name
"Mr.Zhang"
Redis cluster startup script
All three sets are configured.
Cat > > / opt/redis/bin/start-all.sh