作者:胆小的女屌丝 | 来源:互联网 | 2023-09-07 10:30
创建文件夹在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