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

在用Docker配置Redis哨兵节点的时候出现的错误及其解决办法

在用Docker配置Redis哨兵节点的时候,出现了以下的错误:

WARNING: Sentinel was not able to save the new configuration on disk!!!: Device or resource busy

redis-sentinel throws error: " Can’t resolve master instance hostname.

这都是我踩过的坑,问AI也半天搞不定,现在来记录一下是怎么解决的。

首先是第一个问题

字面来看,就是Redis无法进行写入操作。

你的docker-compose.yml文件关于sentinel的配置可能是这样的

    command: "redis-server /etc/redis-config/redis.conf --sentinel"
    volumes:
      - "./config/redis-sentinel/sentinel.conf:/etc/redis-config/redis.conf"

为了让redis能够进行写入,我们不能仅仅挂载一个配置文件,需要将文件夹一同挂载下来,所以解决办法是:

    command: "redis-server /etc/redis-config/redis.conf --sentinel"
    volumes:
      - "./config/redis-sentinel:/etc/redis-config"

总体应该看起来是这样的:

  sentinel:
    image: redis:latest
    container_name: redis-sentinel
    networks:
      - redis-net
    ports:
      - "26381:26379"
    command: "redis-server /etc/redis-config/redis.conf --sentinel"
    volumes:
      - "./config/redis-sentinel:/etc/redis-config"
    depends_on:
      - redis-master
      - redis-slave1
      - redis-slave2

那么回到第二个问题,

redis-sentinel throws error: " Can’t resolve master instance hostname.

这里如果你的redis版本比较旧,需要在配置文件中将其修改成hostname修改为ip。

如果你已经确保你的redis版本在6.2之后,依旧出现这个问题,可以在挂载的配置文件中加上

sentinel resolve-hostnames yes

这一行配置,就可以了。

参考文献

WARNING: Sentinel was not able to save the new configuration on disk!!!: Device or resource busy

redis-sentinel throws error: " Can’t resolve master instance hostname."

总结

StackOverflow永远的神.


http://www.kler.cn/a/590506.html

相关文章:

  • 【Python 算法零基础 1.线性枚举】
  • DeepSeek私有化部署与安装浏览器插件内网穿透远程访问实战
  • ISP--Gamma Correction
  • 搞定python之八----操作mysql
  • 【SpringMVC】常用注解:@SessionAttributes
  • Qt QML解决SVG图片显示模糊的问题
  • @RequestBody注解解释
  • 服务创造未来 东隆科技携多款产品亮相慕尼黑
  • 【网络协议】基于UDP的可靠协议:KCP
  • Git 使用指南
  • 【多线程】单例模式
  • Unity学习之Shader总结(一)
  • Docker入门篇2:查看容器、运行容器、启动和停止容器、删除容器
  • Android PC 要来了?Android 16 Beta3 出现 Enable desktop experience features 选项
  • 【STM32】NVIC(嵌套向量中断控制器)
  • Android之RecyclerView列表拖动排序
  • Vue3项目白屏问题深度解析:从AI辅助诊断到性能优化实战
  • 《灵珠觉醒:从零到算法金仙的C++修炼》卷三·天劫试炼(49)万鸦壶焚网络 - 网络延迟时间(Bellman-Ford)
  • Spring boot+mybatis的批量删除
  • 【AI】深度学习与人工智能应用案例详解