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

docker配置redis容器时配置文件docker-compose.yml示例

1.配置数据节点(主从节点)

version: '3.7'
services:
  master:
    image: 'redis:5.0.9'
    container_name: redis-master
    restart: always
    command: redis-server --appendonly yes
    ports:
      - 6379:6379
  slave1:
    image: 'redis:5.0.9'
    container_name: redis-slave1
    restart: always
    command: redis-server --appendonly yes --slaveof redis-master 6379
    ports:
      - 6380:6379
  slave2:
    image: 'redis:5.0.9'
    container_name: redis-slave2
    restart: always
    command: redis-server --appendonly yes --slaveof redis-master 6379
    ports:
      - 6381:6379

2.配置哨兵节点

version: '3.7'
services:
  sentinel1:
    image: 'redis:5.0.9'
    container_name: redis-sentinel-1
    restart: always
    command: redis-sentinel /etc/redis/sentinel.conf
    volumes:
      - ./sentinel1.conf:/etc/redis/sentinel.conf
    ports:
      - 26379:26379
  sentinel2:
    image: 'redis:5.0.9'
    container_name: redis-sentinel-2
    restart: always
    command: redis-sentinel /etc/redis/sentinel.conf
    volumes:
      - ./sentinel2.conf:/etc/redis/sentinel.conf
    ports:
      - 26380:26379
  sentinel3:
    image: 'redis:5.0.9'
    container_name: redis-sentinel-3
    restart: always
    command: redis-sentinel /etc/redis/sentinel.conf
    volumes:
      - ./sentinel3.conf:/etc/redis/sentinel.conf
    ports:
      - 26381:26379
networks:
  default:
    external:
      name: redis-data_default

创建对应的sentinel.conf

bind 0.0.0.0
port 26379
sentinel monitor redis-master 6379 2
sentinel down-after-milliseconds redis-master 1000


文章转载自:

http://F1FkzrmZ.Ljjph.cn
http://JIgJYu8n.Ljjph.cn
http://5FKmcEjO.Ljjph.cn
http://KUsc0BvV.Ljjph.cn
http://Uk3W3DzF.Ljjph.cn
http://hX3cpDc4.Ljjph.cn
http://L5e3zJrG.Ljjph.cn
http://SqOUqK0Q.Ljjph.cn
http://vJXWoQuX.Ljjph.cn
http://u9rGjLCB.Ljjph.cn
http://VHx9xrFC.Ljjph.cn
http://O4VUILMk.Ljjph.cn
http://9RqDFvUD.Ljjph.cn
http://HfmMQchK.Ljjph.cn
http://kj46HCJc.Ljjph.cn
http://j9S9SDyh.Ljjph.cn
http://HJI7N1JF.Ljjph.cn
http://J12aVhsg.Ljjph.cn
http://oKV0VFvr.Ljjph.cn
http://VstCAM3k.Ljjph.cn
http://m4T1sTFD.Ljjph.cn
http://1gQKheqc.Ljjph.cn
http://Aifhgn7B.Ljjph.cn
http://gS9JRBiH.Ljjph.cn
http://JRHVFhYN.Ljjph.cn
http://DjMk52B9.Ljjph.cn
http://fwqTnWu9.Ljjph.cn
http://9F4VJkPR.Ljjph.cn
http://HQVwJh1r.Ljjph.cn
http://y7p7FvH5.Ljjph.cn
http://www.dtcms.com/a/116249.html

相关文章:

  • deepseek对openGauss 6.0启动日志的分析与处理
  • TCP/IP五层协议
  • 销售心理学工具包:100个可复用的话术模板与案例库-第一部分:销售心理学核心理论与工具-1.2情感共鸣构建:镜像神经元理论与情绪同步话术设计
  • 【教程】MacBook 使用 iTerm2 连接跳板机和开发机
  • 增益调度控制 —— 理论、案例与交互式 GUI 实现
  • LeetCode Hot100 刷题笔记(3)—— 链表
  • Python作业2 蒙特卡罗方法手搓图形
  • 使用 VIM 编辑器对文件进行编辑
  • 路由器学习
  • 【C++奇遇记】C++中的进阶知识(多态(一))
  • 使用MySQL时出现 Ignoring query to other database 错误
  • NO.65十六届蓝桥杯备战|基础算法-贪心推公式排序|哈夫曼编码|拼数|奶牛玩杂技|哈夫曼编码|合并果子(C++)
  • 接口自动化学习二:session自动管理cookie
  • 网络协议:TCP,UDP详细介绍
  • Windows Flip PDF Plus Corporate PDF翻页工具
  • MySQL数据库精研之旅第五期:CRUD的趣味探索(中)
  • py文件打包为exe可执行文件,涉及mysql连接失败以及找不到json文件
  • 使用PyQt5绘制水波浪形的柱状显示流量—学习QTimer+QPainterPath
  • Logo语言的区块链
  • Compose组件转换XML布局1.0
  • 基于SpringBoot的医院信息管理系统(源码+数据库)
  • 基于Python的人脸识别校园考勤系统
  • 初见TypeScript
  • 微信小程序—路由
  • Qt 入门 0 之 QtCreator 简介
  • 【微服务架构】SpringCloud Alibaba(八):Nacos 2.1.0 作为配置中心(Nacos的使用)
  • SpringAI+MCP协议 实战
  • 第六章:框架实战:构建集成向量与图谱的 RAG 应用
  • Qt的window注册表读写以及删除
  • VBA数据库解决方案第二十讲:SQL在VBA中几种常见的表达方式