配置redis 4.0.11 集群

配置redis 4.0.11 集群

准备redis 软件和redis配置文件

启动Redis服务

/data/soft/redis/src/redis-check-aof --fix /log/redis/dump/appendonly-7001.aof
/data/soft/redis/src/redis-check-aof --fix /log/redis/dump/appendonly-7002.aof
/data/soft/redis/src/redis-check-aof --fix /log/redis/dump/appendonly-7003.aof
/data/bin/redis-server /data/soft/redis/conf/redis-7001.conf >/dev/null 2>&1 &
/data/bin/redis-server /data/soft/redis/conf/redis-7002.conf >/dev/null 2>&1 &
/data/bin/redis-server /data/soft/redis/conf/redis-7003.conf >/dev/null 2>&1 &

/data/soft/redis/src/redis-check-aof --fix /log/redis/dump/appendonly-7004.aof
/data/soft/redis/src/redis-check-aof --fix /log/redis/dump/appendonly-7005.aof
/data/soft/redis/src/redis-check-aof --fix /log/redis/dump/appendonly-7006.aof
/data/bin/redis-server /data/soft/redis/conf/redis-7004.conf >/dev/null 2>&1 &
/data/bin/redis-server /data/soft/redis/conf/redis-7005.conf >/dev/null 2>&1 &
/data/bin/redis-server /data/soft/redis/conf/redis-7006.conf >/dev/null 2>&1 &

利用redis-trib.rb 创建集群和密码

/data/soft/redis/src/redis-trib.rb create --replicas 1 172.16.14.3:7001 172.16.14.3:7002 172.16.14.3:7003 172.16.14.4:7004 172.16.14.4:7005 172.16.14.4:7006

启动完成之后,查询集群节点

[www@buyusrv1012 ~]$ /data/soft/redis/src/redis-trib.rb check 172.16.14.3:7001

Performing Cluster Check (using node 172.16.14.3:7001)
M: dba2ac9f884fe0555d9b78718b8600c17c6ba023 172.16.14.3:7001
slots:0-5460 (5461 slots) master
1 additional replica(s)
M: af36693e5a8360dc981e0210a27ab17e1fe42d11 172.16.14.3:7002
slots:10923-16383 (5461 slots) master
1 additional replica(s)
M: ba4d9563b9b9f4b41e3ad3304443643f54a20e45 172.16.14.4:7004
slots:5461-10922 (5462 slots) master
1 additional replica(s)
S: 698a1511b4dd37932bf8911a05b9833efa7c085b 172.16.14.4:7005
slots: (0 slots) slave
replicates af36693e5a8360dc981e0210a27ab17e1fe42d11
S: ee1d3bebef7a2e305ae7266b1466f462ff308bb4 172.16.14.3:7003
slots: (0 slots) slave
replicates ba4d9563b9b9f4b41e3ad3304443643f54a20e45
S: 01da8a5e39d03e1004920a07232526f707b99fc4 172.16.14.4:7006
slots: (0 slots) slave
replicates dba2ac9f884fe0555d9b78718b8600c17c6ba023
[OK] All nodes agree about slots configuration.

Check for open slots...
Check slots coverage...
[OK] All 16384 slots covered.

配置test测试

/data/bin/redis-cli -h 172.16.14.3 -p 7001 -c -a "nfJNhCDwv0hOlyFdbT9XvlkdZq"

测试命令
set name test
get name

你可能感兴趣的:(配置redis 4.0.11 集群)