redis哨兵-5

#地址:
https://www.cnblogs.com/PatrickLiu/p/8444546.html


#常用架构
redis1主1从+3哨兵  实现redis高可用


#redis主从
###############################主######################################
daemonize yes
protected-mode no
pidfile "/var/run/redis_6379.pid"
port 6379
bind 0.0.0.0
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/opt/redis/logs/redis_6379.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
dir "/opt/redis/data/6379"
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
slave-read-only yes


################################从##########################################
daemonize yes
protected-mode no
pidfile "/var/run/redis_6379.pid"
port 6379
bind 0.0.0.0
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/opt/redis/logs/redis_6379.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
dir "/opt/redis/data/6379"
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
#主的连接
slaveof 172.16.0.22 6379



#####################################redis哨兵配置################################################
port 16379
dir /opt/redis/data/
daemonize yes
protected-mode no
logfile "/opt/redis/logs/redis_16379.log"
pidfile "/var/run/redis_16379.pid"
#Sentinel(哨兵)进程去监视一个名为 mymaster 的主服务器,这个主服务器的 IP 地址为 172.16.0.23 , 端口号为 6379,而将这个主服务器判断为失效至少需要 1 个 Sentinel(哨兵)进程的同意
#注意:
#1.如果2个哨兵,有1个哨兵挂了,那么主从是不会切换的,状态都会在odwon(客观下线状态),所以要哨兵高可用,至少要3个哨兵
#2.如果只有1个哨兵 最后面的1是无所谓的。状态会是sdown(主观下线状态)。
sentinel monitor mymaster  172.16.0.23 6379 1     
#(哨兵)进程判断服务器已经掉线所需的毫秒数
sentinel down-after-milliseconds mymaster 3000
#在执行故障转移时,最多可以有多少个从服务器同时对新的主服务器进行同步,这个数字越小,完成故障转移所需的时间就越长。(一般设置为1)
sentinel parallel-syncs mymaster 1
#实现主从切换,完成故障转移的所需要的最大时间值。若Sentinel(哨兵)进程在该配置值内未能完成故障转移的操作(即故障时master/slave自动切换),则认为本次故障转移操作失败
sentinel failover-timeout mymaster 60000


###############哨兵启动
/opt/redis/bin/redis-server /opt/redis/16379.conf --sentinel

猜你喜欢

转载自www.cnblogs.com/hanxiaohui/p/8997975.html