当前位置: 首页 > news >正文

学校二级网站建设自查情况wordpress手机模板插件

学校二级网站建设自查情况,wordpress手机模板插件,成都定制公交app,网站建设mng使用SpringBoot Data Redis无法连接Redis-Cluster集群 最近在研究系统高并发下的缓存架构,因此自己在自己买的云服务器上搭建好Redis 5.0 版本的集群后,使用springboot的 RedisTemplate连接是发现总是访问不到集群节点。上网百度了发现没有好的解决办法&…

使用SpringBoot Data Redis无法连接Redis-Cluster集群

最近在研究系统高并发下的缓存架构,因此自己在自己买的云服务器上搭建好Redis 5.0 版本的集群后,使用springboot的 RedisTemplate连接是发现总是访问不到集群节点。上网百度了发现没有好的解决办法,没办法只好自己debug。

RedisTemplat封装Lettuce来实现Redis操作

在Spring boot 2.X 之后,SpringBoot 将默认的客户端换成了Lettuce。对于这个客户端的好处,大家可以自行查找。

Lettuce 初始化连接池时,无法连接到Redis-Cluster集群

在使用Jedis创建Redis-Cluster集群连接时,没有任何问题,但是使用了Lettuce客户端创建,就会出现连接超时的问题,具体配置如下:

application.jpg

但是当我启动程序时,Redis客户端访问的IP:PORT 与我在如上图所示配置的IP和端口不一致。这就让我很无奈。于是只好针对日志打印的类去查找相关源码。

最后查找到了这个方法io.lettuce.core.cluster.topology.NodeTopologyView#getOwnPartition

    RedisClusterNode getOwnPartition() {for (RedisClusterNode partition : partitions) {if (partition.is(RedisClusterNode.NodeFlag.MYSELF)) {return partition;}}

在走到这段代码的时候,他会将当前Redis服务器对外的互联网及IP转变为 本机IP。 知道这个问题就好办了。通过查看redis.conf配置文件,我发现了这么一段内容。

########################## CLUSTER DOCKER/NAT support  ######################### In certain deployments, Redis Cluster nodes address discovery fails, because
# addresses are NAT-ted or because ports are forwarded (the typical case is
# Docker and other containers).
#
# In order to make Redis Cluster working in such environments, a static
# configuration where each node knows its public address is needed. The
# following two options are used for this scope, and are:
#
# * cluster-announce-ip
# * cluster-announce-port
# * cluster-announce-bus-port
#
# Each instruct the node about its address, client port, and cluster message
# bus port. The information is then published in the header of the bus packets
# so that other nodes will be able to correctly map the address of the node
# publishing the information.
#
# If the above options are not used, the normal Redis Cluster auto-detection
# will be used instead.
#
# Note that when remapped, the bus port may not be at the fixed offset of
# clients port + 10000, so you can specify any port and bus-port depending
# on how they get remapped. If the bus-port is not set, a fixed offset of
# 10000 will be used as usually.
#
# Example:
#
#cluster-announce-ip 127.0.01
#cluster-announce-port 7001
#cluster-announce-bus-port 6380

我们通过上面的英文解读可以知道这段配置的大致内容

在某些部署中,Redis 群集节点地址发现失败,因为地址是 NAT-ted 或者因为端口被转发(典型的情况是Docker 和其他集装箱)为了让 Redis 集群在这样的环境中工作,静态配置,每个节点都知道它的公共地址是必需的。

我们可以知道 以下这几个配置 是可以静态配置,保证Redis集群工作的时候,可以发现需要的公共地址(这里就是我所配置的外网地址)

因此我将以上两个配置取消了注释,并修改为我对外访问的集群 IP和PORT

cluster-announce-ip 对外访问IP
cluster-announce-port 对外端口

修改完之后,重启集群再启动SpringBoot 程序即可。

小结

有些网上的解决方法,不一定是我们真正需要的,凡是还是要自己去探索和动脑。

最后编辑于:2024-11-11 21:08:21


喜欢的朋友记得点赞、收藏、关注哦!!!

http://www.yayakq.cn/news/280245/

相关文章:

  • 怎么让别人看到自己做的网站毕业设计做网站low
  • 浙江网站seo一个网站 两个域名
  • 信息型网站制造业生产管理系统
  • 江西网站备案商城网站开发报价方案
  • 小企业网站服务器h5商城网站模板下载
  • 免费网站平台推荐金华市建设技工学校网站
  • phpcmsv9中英文网站汕头网站
  • wordpress专题页面企业网站做优化
  • 科技感网页设计徐州百度seo排名优化
  • 做网站好找工作吗搜索引擎营销策划方案
  • 国内做网站的顶尖公司内蒙网络_网站建设
  • 新宾区网站建设吉林市做网站公司
  • 做商品推广有那些网站申请备案网站首页
  • 有没有做门面设计的网站wordpress 页面调用
  • 移动端网站的重要性用vs2010做网站教程
  • 东莞企业网站推广wordpress发布文章_发布
  • windows服务器怎么建设网站做网站优化的关键词怎么设置
  • 专业型网站网站做音乐 交流网站
  • 做视频网站视频用什么插件吗cn结尾的网站 做外贸
  • 如何用网站模板房产达人
  • 吉安企业做网站企业管理培训课程ppt
  • 阀门公司网站建设网址大全黄页男女
  • 民治营销型网站设计哪家好贵州住房和城乡建设厅官方网站
  • 免费建站网站一级南京网站优化报价
  • 十大购物网站网络营销的定义与特点
  • 学做网站要什么基础室内设计公司简介
  • 网站建设福永附近网络公司wordpress 官方文档
  • 大连龙彩科技的网站在谁家做wordpress 菜单 固定
  • 网站包装推广之网络营销案例wordpress栏目关键词描述标签
  • 十大免费cad网站入口软件绿化信息网站建设