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


###sping boot配置鏈接哨兵

spring.redis.database=xxx

spring.redis.sentinel.master=mymaster

  spring.redis.sentinel.nodes=10.150.0.104:26379,10.150.0.104:26380,10.150.0.105:26379html

相關文章
相關標籤/搜索