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

企业网站模版客户引流推广方案

企业网站模版,客户引流推广方案,郴州是几线城市,青岛专业做商业房的网站在 Kubernetes (k8s) 环境下使用 Redis Sentinel 进行高可用部署时,可能会遇到 failover 超时、Sentinel 误判、Spring Boot 连接失败 以及 Redisson 配置错误等问题。本文将对这些问题进行汇总分析,并提供详细的解决方案。 1️⃣ Redis Sentinel 介绍 …

在 Kubernetes (k8s) 环境下使用 Redis Sentinel 进行高可用部署时,可能会遇到 failover 超时Sentinel 误判Spring Boot 连接失败 以及 Redisson 配置错误等问题。本文将对这些问题进行汇总分析,并提供详细的解决方案。


1️⃣ Redis Sentinel 介绍

Redis Sentinel 是 Redis 的高可用组件,主要功能包括:

  • 主节点故障检测:判断 Redis 主节点是否宕机。
  • 自动故障转移:当主节点不可用时,选举新的主节点。
  • 通知客户端:应用程序(如 Spring Boot、Redisson)可以通过 Sentinel 获取最新的主节点地址。

Redis Sentinel 关键配置(sentinel.conf):

sentinel monitor mymaster redis-master 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000
sentinel parallel-syncs mymaster 1
  • down-after-milliseconds mymaster 5000:如果 5 秒内主节点无响应,认为其不可用。
  • failover-timeout mymaster 60000:Sentinel 允许 60 秒内完成故障转移。

2️⃣ Redis Sentinel 报错分析

🚨 问题 1:Redis 日志报 failover-timeout

🔍 可能原因
  • 副本同步未完成,Sentinel 不能立即选出新的主节点。
  • 网络抖动,导致 Sentinel 误判主节点宕机。
  • Sentinel 数量不足,无法进行有效投票。
✅ 解决方案

1️⃣ 检查 Redis 副本同步状态

kubectl exec -it redis-master-0 -- redis-cli INFO replication

如果 connected_slaves: 0,说明没有可用副本,Sentinel 可能无法完成切换。

2️⃣ 增大 failover-timeout

sentinel failover-timeout mymaster 120000  # 增加至 120 秒

然后重启 Sentinel:

kubectl delete pod -l app=redis-sentinel

3️⃣ 检查 Sentinel 是否足够

kubectl get pods -l app=redis-sentinel

如果 num-other-sentinels: 0,需要增加副本:

spec:replicas: 3  # 至少 3 个 Sentinel

🚨 问题 2:Spring Boot 连接 Redis Sentinel 一直报 addedis down

🔍 可能原因
  • spring.redis.sentinel.master 配置错误,导致 Spring Boot 连接不上 Redis Sentinel。
  • sentinel.confmymaster 拼写错误,导致 Sentinel 无法正确发现主节点。
✅ 解决方案

1️⃣ 检查 sentinel.conf 配置

kubectl exec -it redis-sentinel-0 -- redis-cli -p 26379 SENTINEL MASTER mymaster

如果 mymaster 不存在,说明 Sentinel 配置错误。

2️⃣ 检查 Spring Boot 配置

spring:redis:sentinel:master: mymaster  # 必须和 Sentinel 配置一致nodes:- redis-sentinel-0:26379- redis-sentinel-1:26379- redis-sentinel-2:26379password: yourpassword

3️⃣ 调整 timeout 以减少误判

spring:redis:timeout: 5000lettuce:pool:max-active: 10max-wait: 5000

3️⃣ Redisson 连接 Redis Sentinel 配置

Redisson 是一个高效的 Redis 客户端,支持 Redis Sentinel 模式。

🚀 依赖

pom.xml 中引入:

<dependency><groupId>org.redisson</groupId><artifactId>redisson-spring-boot-starter</artifactId><version>3.23.2</version>
</dependency>

🚀 配置 RedissonClient

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class RedissonConfig {@Beanpublic RedissonClient redissonClient() {Config config = new Config();config.useSentinelServers().setMasterName("mymaster").addSentinelAddress("redis://redis-sentinel-0:26379","redis://redis-sentinel-1:26379","redis://redis-sentinel-2:26379").setPassword("yourpassword").setTimeout(5000).setConnectTimeout(10000);return Redisson.create(config);}
}

4️⃣ 测试 Redisson 连接

import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;@RestController
public class RedisController {private final RedissonClient redissonClient;public RedisController(RedissonClient redissonClient) {this.redissonClient = redissonClient;}@GetMapping("/set")public String set(@RequestParam String key, @RequestParam String value) {RBucket<String> bucket = redissonClient.getBucket(key);bucket.set(value);return "Set " + key + " = " + value;}@GetMapping("/get")public String get(@RequestParam String key) {RBucket<String> bucket = redissonClient.getBucket(key);return "Get " + key + " = " + bucket.get();}
}

5️⃣ 可能的错误 & 解决方案

Unable to connect to Redis Sentinel

✅ 解决方案

  • 检查 Sentinel 是否正常运行

    kubectl get pods -l app=redis-sentinel
    

    如果 Sentinel Pod 挂了,需要重新启动。

  • 手动测试 Sentinel

    redis-cli -p 26379 SENTINEL MASTER mymaster
    

    如果 mymaster 不存在,说明 Sentinel 配置有误。


🔎 总结

🚀 Redis Sentinel + Redisson 高可用方案的关键要点:
1️⃣ Redis Sentinel 需配置正确mymaster 名称需一致,failover-timeout 需足够长。
2️⃣ Spring Boot 连接 Redis Sentinel 时spring.redis.sentinel.master 需要匹配 Sentinel 配置。
3️⃣ Redisson 连接 Sentinel 需要手动配置 RedissonClient,并保证 sentinel.conf 正确。
4️⃣ 故障排查时,手动执行 SENTINEL MASTER mymaster,检查主节点状态。

📢 如果你仍然遇到问题,可以提供 redis-cliSENTINEL MASTER mymaster 输出,我可以帮你分析!🚀

http://www.dtcms.com/wzjs/403681.html

相关文章:

  • 做电子商务网站的公司二十条优化措施
  • 个人网站做排名优惠活动推广文案
  • 做科技的网站宜兴百度推广
  • 常用的设计网站seo管理系统
  • 温州做网站费用西部数码域名注册官网
  • wordpress免费模版北京seo排名技术
  • 如何做网站的seo给你一个网站seo如何做
  • 做行业门户网站要投资多少钱网站推广策划
  • 福田附近公司做网站建设哪家效益快怎么关键词优化网站
  • 做暧嗳xo小视频免费网站广东东莞大益队
  • 安徽建设学校官方网站产品质量推广营销语
  • 网站制作里的更多怎么做搜索引擎站长平台
  • 网站建设软件开发公司郑州seo排名扣费
  • 株洲做网站的公司seo推广方法有哪些
  • 网页设计与网站建设考试答案私密浏览器免费版
  • 新手怎么样学做网站品牌营销策划十大要点
  • wordpress建站价格中山疫情最新消息
  • 宠物网站建设内容现在网络推广方式
  • 钓鱼网站建设seo课程培训要多少钱
  • 网站空间怎么登陆百度免费推广平台
  • 如何使用二级域名做网站北京网站优化价格
  • 杭州市下城区建设厅网站成全在线观看免费高清动漫
  • 网站免费模版长沙做网络推广公司的
  • 向客户介绍网站建设seo技术建站
  • 北京怎么做网站推广关键词优化排名用什么软件比较好
  • 商家做网站的优点网络推广常见的方法
  • 成都手机网站开发百度小说风云榜排名
  • 南通网站制作哪个好百度投诉电话人工服务总部
  • 珠海网站seo机构
  • 以前做弹幕现在的电影网站十大免费网站推广平台