编译make & make install
1.配置文件
2.主从模式配置
只需要配置从节点 : slaveof 主节点ip redis监听端口
若注册成功则展示一下信息
redsi主节点 info命令
redsi从节点 info命令
2.哨兵模式配置
主从模式下的1主2从
配置sentinel文件,每个节点一个
启动前配置为
protected-mode no
port 26379
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
启动后配置为
3.集群模式配置
主要配置
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 10000
启动截图
创建集群
[root@redis src]# redis-cli --cluster create --cluster-replicas 1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 127.0.0.1:6383 to 127.0.0.1:6379
Adding replica 127.0.0.1:6384 to 127.0.0.1:6380
Adding replica 127.0.0.1:6382 to 127.0.0.1:6381
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: acbe3ff209cabf79a449b6581242ac9c05127425 127.0.0.1:6379
slots:[0-5460] (5461 slots) master
M: 1704c3650e50e796c84b430f66ce58626fc13d8a 127.0.0.1:6380
slots:[5461-10922] (5462 slots) master
M: b2099367cfebbfaa87c1c3774e7a11d9dd67e156 127.0.0.1:6381
slots:[10923-16383] (5461 slots) master
S: 8536947b001fa6797d441c0f606c92c59910dfae 127.0.0.1:6382
replicates acbe3ff209cabf79a449b6581242ac9c05127425
S: ce044c1dc29f5390efecc7e4e432341582045efa 127.0.0.1:6383
replicates 1704c3650e50e796c84b430f66ce58626fc13d8a
S: 33569a66fce73d2d4dc1703854eaf78074886423 127.0.0.1:6384
replicates b2099367cfebbfaa87c1c3774e7a11d9dd67e156
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 127.0.0.1:6379)
M: acbe3ff209cabf79a449b6581242ac9c05127425 127.0.0.1:6379
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 33569a66fce73d2d4dc1703854eaf78074886423 127.0.0.1:6384
slots: (0 slots) slave
replicates b2099367cfebbfaa87c1c3774e7a11d9dd67e156
S: 8536947b001fa6797d441c0f606c92c59910dfae 127.0.0.1:6382
slots: (0 slots) slave
replicates acbe3ff209cabf79a449b6581242ac9c05127425
S: ce044c1dc29f5390efecc7e4e432341582045efa 127.0.0.1:6383
slots: (0 slots) slave
replicates 1704c3650e50e796c84b430f66ce58626fc13d8a
M: b2099367cfebbfaa87c1c3774e7a11d9dd67e156 127.0.0.1:6381
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
M: 1704c3650e50e796c84b430f66ce58626fc13d8a 127.0.0.1:6380
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.
集群信息
127.0.0.1:6384> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:3
cluster_stats_messages_ping_sent:4515
cluster_stats_messages_pong_sent:4350
cluster_stats_messages_meet_sent:1
cluster_stats_messages_sent:8866
cluster_stats_messages_ping_received:4350
cluster_stats_messages_pong_received:4516
cluster_stats_messages_received:8866
total_cluster_links_buffer_limit_exceeded:0
密码配置
集群模式下,每个节点都可能作为master或者slave
masterauth passwd 的作用为:当前节点作为slave时,访问master所需的密码配置
requirepass passwd 的作用为:当前节点作为master时,客户端访问server(master)所需的密码配置
========================================================================
如有侵权请联系删除