以上为理想的集群,以实际为准
一、前提
三台机器全部安装redis单机版,并且新建目录
https://blog.csdn.net/SHI940637335/article/details/129163881
二、搭建
1.文件新建
192.168.1.130机器
1)redisCluster6381.conf
vim redisCluster6381.conf
bind 0.0.0.0
daemonize yes
protected-mode no
port 6381
logfile "./cluster6381.log"
pidfile ./cluster6381.pid
dir ./
dbfilename dump6381.rdb
appendonly yes
appendfilename "appendonly6381.aof"
requirepass 111111
masterauth 111111
cluster-enabled yes
cluster-config-file nodes-6381.conf
cluster-node-timeout 5000
2)redisCluster6382.conf
vim redisCluster6382.conf
bind 0.0.0.0
daemonize yes
protected-mode no
port 6382
logfile "./cluster6382.log"
pidfile ./cluster6382.pid
dir ./
dbfilename dump6382.rdb
appendonly yes
appendfilename "appendonly6382.aof"
requirepass 111111
masterauth 111111
cluster-enabled yes
cluster-config-file nodes-6382.conf
cluster-node-timeout 5000
192.168.1.131机器
3)redisCluster6383.conf
vim redisCluster6383.conf
bind 0.0.0.0
daemonize yes
protected-mode no
port 6383
logfile "./cluster6383.log"
pidfile ./cluster6383.pid
dir ./
dbfilename dump6383.rdb
appendonly yes
appendfilename "appendonly6383.aof"
requirepass 111111
masterauth 111111
cluster-enabled yes
cluster-config-file nodes-6383.conf
cluster-node-timeout 5000
4)redisCluster6384.conf
vim redisCluster6384.conf
bind 0.0.0.0
daemonize yes
protected-mode no
port 6384
logfile "./cluster6384.log"
pidfile ./cluster6384.pid
dir ./
dbfilename dump6384.rdb
appendonly yes
appendfilename "appendonly6384.aof"
requirepass 111111
masterauth 111111
cluster-enabled yes
cluster-config-file nodes-6384.conf
cluster-node-timeout 5000
192.168.1.132机器
5)redisCluster6385.conf
vim redisCluster6385.conf
bind 0.0.0.0
daemonize yes
protected-mode no
port 6385
logfile "./cluster6385.log"
pidfile ./cluster6385.pid
dir ./
dbfilename dump6385.rdb
appendonly yes
appendfilename "appendonly6385.aof"
requirepass 111111
masterauth 111111
cluster-enabled yes
cluster-config-file nodes-6385.conf
cluster-node-timeout 5000
6)redisCluster6386.conf
vim redisCluster6386.conf
bind 0.0.0.0
daemonize yes
protected-mode no
port 6386
logfile "./cluster6386.log"
pidfile ./cluster6386.pid
dir ./
dbfilename dump6386.rdb
appendonly yes
appendfilename "appendonly6386.aof"
requirepass 111111
masterauth 111111
cluster-enabled yes
cluster-config-file nodes-6386.conf
cluster-node-timeout 5000
2.启动6台redis主机实例
192.168.1.130机器
192.138.1.131机器
192.168.1.132机器
三、构建关系
一台机器执行即可
redis-cli -a 111111 --cluster create --cluster-replicas 1 192.168.1.130:6381 192.168.1.130:6382 192.168.1.131:6383 192.168.1.131:6384 192.168.1.132:6385 192.168.1.132:6386
四、测试