redis集群配置要点

1、需要修改的配置文件项 redis.conf(1、端口prot:6380 2、pid:pidfile /var/run/redis_6380.pid 3、logfile "6380.log" 4、dbfilename dump6380.rdb)

2、启动 redis-server  配置文件  info replication

3、命令 人老大 从机中配置 slaveof host port  然后info replication  查看 -----可以在配置文件中配置 replication 选项 replicaof <masterip> <masterport> 如果有密码  需要配置masterauth <master-password>

4、shutdown 主机断开后丛机还是有数据保存 需要手动修改丛机变为主机。slaveof no one 把自己变为主机master;

5、开启哨兵模式:配置 sentinel.conf (sentinel monitor 被监控的主机名:myredis  地址:192.168.1.7  端口:6379  投票的数量1)   配置:sentinel monitor myredis 192.168.1.7 6379 1

https://blog.csdn.net/a1282379904/article/details/52335051

https://blog.csdn.net/open1024/article/details/121828253?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&utm_relevant_index=1

http://www.wangdb.com/archives/1031.html

哨兵1

port 26379
bind 0.0.0.0
daemonize yes
pidfile "/var/run/redis-sentinel-1.pid"
logfile "/var/log/redis/sentinel_26379.log"
dir "/tmp"
sentinel monitor mymaster 8.129.113.233 6379
2
sentinel down-after-milliseconds mymaster
5000
sentinel auth-pass mymaster 123456
sentinel failover-timeout mymaster 30000

哨兵2

port 26380
bind 0.0.0.0
daemonize yes
pidfile "/var/run/redis-sentinel-2.pid"
logfile "/var/log/redis/sentinel_26380.log"
dir "/tmp"
sentinel monitor mymaster 8.129.113.233 6379
2
sentinel down-after-milliseconds mymaster
5000
sentinel auth-pass mymaster 123456
sentinel failover-timeout mymaster 30000
哨兵 3

port 26381
bind 0.0.0.0
daemonize yes
pidfile "/var/run/redis-sentinel-3.pid"
logfile "/var/log/redis/sentinel_26381.log"
dir "/tmp"
sentinel monitor mymaster 8.129.113.233 6379
2
sentinel down-after-milliseconds mymaster
5000
sentinel auth-pass mymaster 123456
sentinel failover-timeout mymaster 30000

-----------------------------------------------------------------------------哨兵1----------------

# Generated by CONFIG REWRITE
protected-mode no
port 26380
sentinel down-after-milliseconds myredis 10000
sentinel failover-timeout myredis 900000
#inel can-failover myredis yes

sentinel monitor myredis 192.168.1.7 6379 2
sentinel config-epoch myredis 1
sentinel leader-epoch myredis 1
sentinel known-replica myredis 192.168.1.7 6381
sentinel current-epoch 1
sentinel known-replica myredis 192.168.1.7 6380
user default on nopass ~* &* +@all
dir "/home/redis-6.2.6/bin"
sentinel myid 07a74164783022be91207a63fbfbbf72f1da53d3
sentinel known-sentinel myredis 192.168.1.7 26381 712a1bc39477a6cfb9b3db3645c12eaba4814091
sentinel known-sentinel myredis 192.168.1.7 26379 f204cd796ee11ef820c8372a5256818d0146f087
~-----------------------------------------------------------------------哨兵2------------------------------------------------------

# Generated by CONFIG REWRITE
protected-mode no
port 26379
dir "/home/redis-6.2.6/bin"
sentinel down-after-milliseconds myredis 10000
sentinel failover-timeout myredis 900000
sentinel config-epoch myredis 1
sentinel leader-epoch myredis 1
sentinel known-replica myredis 192.168.1.7 6380
sentinel monitor myredis 192.168.1.7 6379 2

sentinel known-replica myredis 192.168.1.7 6381
user default on nopass ~* &* +@all
sentinel myid f204cd796ee11ef820c8372a5256818d0146f087
sentinel current-epoch 1
sentinel known-sentinel myredis 192.168.1.7 26381 712a1bc39477a6cfb9b3db3645c12eaba4814091
sentinel known-sentinel myredis 192.168.1.7 26380 07a74164783022be91207a63fbfbbf72f1da53d3
~ ----------------------------------------------------------哨兵3-------------------------------------------------

# Generated by CONFIG REWRITE
protected-mode no
port 26381
sentinel down-after-milliseconds myredis 10000
sentinel failover-timeout myredis 900000
#seninel can-failover myredis yes

sentinel monitor myredis 192.168.1.7 6379 2
sentinel config-epoch myredis 1
sentinel leader-epoch myredis 1
sentinel known-replica myredis 192.168.1.7 6380
sentinel current-epoch 1
sentinel known-replica myredis 192.168.1.7 6381
user default on nopass ~* &* +@all
dir "/home/redis-6.2.6/bin"
sentinel myid 712a1bc39477a6cfb9b3db3645c12eaba4814091
sentinel known-sentinel myredis 192.168.1.7 26379 f204cd796ee11ef820c8372a5256818d0146f087
sentinel known-sentinel myredis 192.168.1.7 26380 07a74164783022be91207a63fbfbbf72f1da53d3
~
~

posted @ 2022-03-23 19:37  donghongchao  阅读(74)  评论(0编辑  收藏  举报