热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

dockercompose配置redis集群

创建文件夹在usrlocaldocker下创建,方便管理cdusrlocaldockermkdirreids-cluster#创建redis-1~redis-6文件夹mkdirre

文章目录[隐藏]

  • 创建文件夹
  • 新建配置文件
  • docker-compose.yaml文件配置 (复制有问题可以用 cat > docker-compose.yaml <
  • 启动容器


创建文件夹

在 /usr/local/docker/下创建,方便管理

cd /usr/local/docker
mkdir reids-cluster # 创建redis-1~redis-6文件夹 mkdir redis-cluster/redis-1 / redis-cluster/redis-2 / redis-cluster/redis-3 / redis-cluster/redis-4 / redis-cluster/redis-5 / redis-cluster/redis-6

新建配置文件

cd redis-cluster

cat > redis-1/redis.conf < redis-2/redis.conf < redis-3/redis.conf < redis-4/redis.conf < redis-5/redis.conf < redis-6/redis.conf <

docker-compose.yaml文件配置 (复制有问题可以用 cat > docker-compose.yaml <
version: '3'
services:
  # redis1配置
  redis1:
    image: redis:6.0.16
    container_name: redis-1
    restart: always
    network_mode: "host"
    volumes:
      - ./redis-1/redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
  # redis2配置
  redis2:
    image: redis:6.0.16
    container_name: redis-2
    restart: always
    network_mode: "host"
    volumes:
      - ./redis-2/redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
  # redis3配置
  redis3:
    image: redis:6.0.16
    container_name: redis-3
    restart: always
    network_mode: "host"
    volumes:
      - ./redis-3/redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
  # redis4配置
  redis4:
    image: redis:6.0.16
    container_name: redis-4
    restart: always
    network_mode: "host"
    volumes:
      - ./redis-4/redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
  # redis5配置
  redis5:
    image: redis:6.0.16
    container_name: redis-5
    restart: always
    network_mode: "host"
    volumes:
      - ./redis-5/redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
  # redis6配置
  redis6:
    image: redis:6.0.16
    container_name: redis-6
    restart: always
    network_mode: "host"
    volumes:
      - ./redis-6/redis.conf:/usr/local/etc/redis/redis.conf
    command: ["redis-server", "/usr/local/etc/redis/redis.conf"]

启动容器

docker-compose up -d

推荐阅读
author-avatar
胆小的女屌丝
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有