环境:
Redis 3.0+jedis 2.4.1
启动3个redis实例,1个master,2个slave
./src/redis-server ~/opt/conf/redis/redis-master.conf
./src/redis-server ~/opt/conf/redis/redis-slave1.conf
./src/redis-server ~/opt/conf/redis/redis-slave2.conf
./src/redis-sentinel ~/opt/conf/redis/sentinel1.conf
./src/redis-sentinel ~/opt/conf/redis/sentinel2.conf
./src/redis-sentinel ~/opt/conf/redis/sentinel3.conf
以下为文件内容
redis-master.conf
port 6380
redis-slave1.conf
port 6381
slaveof 127.0.0.1 6380
redis-slave2.conf
port 6382
slaveof 127.0.0.1 6380
sentinel1.conf
port 26380
daemonize yes
logfile "/Users/niuyp/Downloads/redis/sentinel.log"
sentinel monitor mymaster 127.0.0.1 6380 2
sentinel down-after-milliseconds mymaster 60000
sentinel2.conf
port 26381
daemonize yes
logfile "/Users/niuyp/Downloads/redis/sentinel.log"
sentinel monitor mymaster 127.0.0.1 6380 2
sentinel down-after-milliseconds mymaster 10000
sentinel parallel-syncs mymaster 5
sentinel3.conf
port 26382
daemonize yes
logfile "/Users/niuyp/Downloads/redis/sentinel.log"
sentinel monitor mymaster 127.0.0.1 6380 2
sentinel down-after-milliseconds mymaster 60000
redis.properties
# Redis settings
#sentinel1的IP和端口
im.hs.server.redis.sentinel1.host=127.0.0.1
im.hs.server.redis.sentinel1.port=26380
#sentinel2的IP和端口
im.hs.server.redis.sentinel2.host=127.0.0.1
im.hs.server.redis.sentinel2.port=26381
#sentinel3的IP和端口
im.hs.server.redis.sentinel3.host=127.0.0.1
im.hs.server.redis.sentinel3.port=26382
#sentinel的鉴权密码
im.hs.server.redis.sentinel.masterName=mymaster
#im.hs.server.redis.sentinel.password=0123456789
#最大闲置连接数
im.hs.server.redis.maxIdle=500
#最大连接数,超过此连接时操作redis会报错
im.hs.server.redis.maxTotal=5000
im.hs.server.redis.maxWaitTime=1000
im.hs.server.redis.testOnBorrow=true
#最小闲置连接数,spring启动的时候自动建立该数目的连接供应用程序使用,不够的时候会申请。
im.hs.server.redis.minIdle=300