redis 哨兵模式配置与spring集成

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

最低安装 redis 2.8以上版本 以下流程 为redis3.2.11版本上建立

1、编译redis源码

make make PREFIX=/usr/local/redis install
mkdir conf
mkdir data
mkdir log

2、将redis 源码下的 redis.conf和sentinel.conf 复制到 redis/conf/ 下,修改 redis.conf

bind 172.16.5.58
protected-mode no
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile "/var/run/redis_16382.pid"
loglevel notice
logfile "/usr/local/redis-16382/log/redis-16382.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "redis-16382.rdb"
dir "/usr/local/redis-16382/data"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass "ucpaas.com"
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
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
aof-rewrite-incremental-fsync yes
slaveof 172.16.5.58 16384


如果该redis 为主,则以上配置文件按需修改
如果该redis 为从, 则需要redis.conf中加入 slaveof 172.16.5.58 16382

修改 sentinel.conf

bind 172.16.5.58
protected-mode no
port 6382
dir "/var/lib/sentinel-6382"
sentinel myid 1e83bb84814cb8493682d5078ef922cbfeeaed61
sentinel monitor master-16382 172.16.5.58 16382 2
sentinel auth-pass master-16382 ucpaas.com
sentinel config-epoch master-16382 1
sentinel leader-epoch master-16382 1
sentinel current-epoch 1
如果配置多个 sentinel 则复制该sentinel.conf文件即可

 

启动主从redis ./bin/redis-server /conf/redis.conf &

启动sentinel ./bin/redis-sentinel /conf/sentinel.conf &

 

spring-data-redis 使用该模式




    
        
            
        
    

    
        
            
                
                
            

               
                
                
            

            
                
                
            
        

    






    
    
    
    




    
    
    




    
    
    

 

 

转载于:https://my.oschina.net/TonyTaotao/blog/3000653

你可能感兴趣的:(redis 哨兵模式配置与spring集成)