Redis Sentinel Stunnel配置

时间:2019-12-16 23:20:29

标签: redis spring-data-redis redis-sentinel stunnel

我已经配置了一个3节点的Redis实例,该实例具有具有Redis主Redis副本的stunnel。在每个节点上运行的哨兵。所有的复制设置和哨兵通信都很好。

但是当我使用生菜客户端连接到哨兵节点时,我将redis master ip设为127.0.0.1。我将在sentinel conf中给localhost ip,因为sentinel会通过tunnel连接到redis的实际端口。

Sentinel和Stunnel配置在下面给出。将检索到的ip更改为实际主机ip而不是localhost的任何方法。

Sentinel.conf

port 26379
sentinel myid 35e0a516f99072d1652f366c49a7f56dd0bcddbd
sentinel deny-scripts-reconfig yes
daemonize no
pidfile "/var/run/redis-sentinel.pid"
logfile "/var/log/redis/redis-sentinel.log"
sentinel monitor mymaster 127.0.0.1 6373 2
dir "/tmp"
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 10000
sentinel config-epoch mymaster 1

Stunnel.conf

pid = /run/stunnel-redis.pid
debug=debug
output = /var/log/stunnel/stunnel.log
CAfile = /etc/certs/stunnel/chain.pem

[redis-master]
cert = /etc/certs/stunnel/pos-redis01.pem
key = /etc/certs/stunnel/pos-redis01.key
accept  = 172.19.146.232:6373
connect = 127.0.0.1:6379

[sentinel-redis-master]
client = yes
accept  = 127.0.0.1:6373
connect = 172.19.146.232:6373

[redis-master-client]
client = yes
accept = 127.0.0.1:6374
connect = 172.19.145.139:6374


[redis-sentinel]
cert = /etc/certs/stunnel/pos-redis01.pem
key = /etc/certs/stunnel/pos-redis01.key
accept  = 172.19.146.232:26373
connect = 127.0.0.1:26379




[sentinel-redis-sentinel2]
client = yes
accept  = 127.0.0.1:26374
connect = 172.19.145.139:26374


[sentinel-redis-sentinel3]
client = yes
accept  = 127.0.0.1:26375
connect = 172.19.146.244:26375

应用日志

019-12-16 10:49:55.832-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.RedisChannelHandler context={} dispatching command SubscriptionCommand [type=SENTINEL, output=SocketAddressOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-12-16 10:49:55.832-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.DefaultEndpoint context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373, epid=0x2] write() writeAndFlush command SubscriptionCommand [type=SENTINEL, output=SocketAddressOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-12-16 10:49:55.832-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.CommandHandler context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373, chid=0x1] write(ctx, SubscriptionCommand [type=SENTINEL, output=SocketAddressOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)
2019-12-16 10:49:55.835-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.CommandEncoder context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373] writing command SubscriptionCommand [type=SENTINEL, output=SocketAddressOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2019-12-16 10:49:55.837-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.DefaultEndpoint context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373, epid=0x2] write() done
2019-12-16 10:49:55.837-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.ConnectionWatchdog context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373, last known addr=/172.19.146.232:26373] userEventTriggered(ctx, io.lettuce.core.ConnectionEvents$Activated@60a933b7)
2019-12-16 10:49:55.905-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.CommandHandler context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373, chid=0x1] Received: 29 bytes, 1 commands in the stack
2019-12-16 10:49:55.905-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.CommandHandler context={} [channel=0x3114b70d, /10.4.59.34:62446 -> /172.19.146.232:26373, chid=0x1] Stack contains: 1 commands
2019-12-16 10:49:55.905-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.RedisStateMachine context={} Decode LatencyMeteredCommand [type=SENTINEL, output=SocketAddressOutput [output=null, error='null'], commandType=io.lettuce.core.RedisPublisher$SubscriptionCommand]
2019-12-16 10:49:55.907-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.protocol.RedisStateMachine context={} Decoded LatencyMeteredCommand [type=SENTINEL, output=SocketAddressOutput [output=127.0.0.1:6373, error='null'], commandType=io.lettuce.core.RedisPublisher$SubscriptionCommand], empty stack: true
2019-12-16 10:49:55.916-0800 lettuce-nioEventLoop-6-1 [DEBUG] io.lettuce.core.RedisClient context={} Resolved Master mymaster SocketAddress 127.0.0.1:6373 to 127.0.0.1:6373

0 个答案:

没有答案