情景介绍:
三台宿主机,然后在上面分别用docker-compose部署Redis,Redis-sentinel,来做成Redis集群
服务原来是单机用docker-compose部署的,现在要改成高可用,时间紧,先用三台机器做个简单负载
Redis负载这里就有个大坑
表现出来就是,有个服务一直报错
2024-11-22 16:31:46.119 ERROR --- [sson-netty-2-13] o.r.connection.SentinelConnectionManager : io.netty.channel.ConnectTimeoutException: connection timed out: 172.20.0.24/172.20.0.24:26379
java.util.concurrent.CompletionException: io.netty.channel.ConnectTimeoutException: connection timed out: 172.20.0.24/172.20.0.24:26379
经过无数次的排查后发现sentinel的配置少了密码
sentinel auth-pass mymaster xxx@xxxx
加上之后满心欢喜的去重启服务,以为这就搞定了
但是服务依然报错
又经过各种查资料,发现因为redis-sentinel是用docker部署的,所以,在连接后上报的地址是docker容器的地址,这就会有问题,而且三台主机的redis-sentinel容器ip还一模一样
于是,又在配置文件中加了这一行,修改上报的ip地址
sentinel announce-ip ${宿主机ip},在三台机器上分别加上这个配置
然后在重启容器,再重启服务,发现服务终于好了
(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ\`ლ)゙
正常的启动是这样的 :
2024-11-22 17:33:04.354 INFO --- [ main] com.alibaba.nacos.client.naming : initializer namespace from System Property :null
2024-11-22 17:33:07.343 INFO --- [ main] org.redisson.Version : Redisson 3.17.6
2024-11-22 17:33:08.434 INFO --- [ main] o.r.connection.SentinelConnectionManager : master: redis://100.100.0.100:6379 added
2024-11-22 17:33:08.486 INFO --- [ main] o.r.connection.SentinelConnectionManager : slave: redis://100.100.0.200:6379 added
2024-11-22 17:33:08.486 INFO --- [ main] o.r.connection.SentinelConnectionManager : slave: redis://100.100.0.300:6379 added
2024-11-22 17:33:08.633 INFO --- [sson-netty-2-11] o.r.connection.SentinelConnectionManager : sentinel: redis://100.100.0.300:26379 added
2024-11-22 17:33:08.715 INFO --- [sson-netty-2-12] o.r.connection.SentinelConnectionManager : sentinel: redis://100.100.0.100:26379 added
2024-11-22 17:33:08.727 INFO --- [sson-netty-2-13] o.r.connection.SentinelConnectionManager : sentinel: redis://100.100.0.300:26379 added
2024-11-22 17:33:09.098 INFO --- [sson-netty-2-22] o.r.c.pool.MasterPubSubConnectionPool : 1 connections initialized for 100.100.0.100/100.100.0.100:6379
2024-11-22 17:33:09.608 INFO --- [isson-netty-2-4] o.r.connection.pool.MasterConnectionPool : 24 connections initialized for 100.100.0.100/100.100.0.100:6379
2024-11-22 17:33:09.633 INFO --- [isson-netty-2-9] o.r.connection.pool.PubSubConnectionPool : 1 connections initialized for 100.100.0.300/100.100.0.300:6379
2024-11-22 17:33:09.793 INFO --- [sson-netty-2-31] o.r.connection.pool.PubSubConnectionPool : 1 connections initialized for 10.10.7.22/100.100.0.200:6379
2024-11-22 17:33:09.954 INFO --- [isson-netty-2-1] o.r.connection.pool.SlaveConnectionPool : 24 connections initialized for 10.10.7.22/100.100.0.200:6379
2024-11-22 17:33:09.995 INFO --- [sson-netty-2-29] o.r.connection.pool.SlaveConnectionPool : 24 connections initialized for 100.100.0.300/100.100.0.300:6379
舒服了
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。