方案一:在portainer上进行安装
#如果集群故障了,则所有节点重启一次即可 如果单独重启了启动节点 则把启动节点数改为0 不然会一直在重启
version: '3.8'
#网络模式配置 redis集群固定要用host模式
x-common-ports: &common-ports
protocol: tcp
mode: host
#日志大小设置
x-logging: &default-logging
options:
max-size: "3g"
max-file: "1"
driver: json-file
#公共参数
x-common-setting: &common-setting
image: master:5000/redis:5.0.7
logging: *default-logging
restart: always
networks:
- default
#集群启动节点
x-common-startup-setting: &common-startup-setting
<< : *common-setting
deploy:
restart_policy:
condition: on-failure
#redis工作节点的资源配置
x-common-worker-deploy-resources: &common-worker-deploy-resources
resources:
limits:
memory: 1030M
reservations:
memory: 1030M
#redis工作节点的基础配置
x-common-worker-setting: &common-worker-setting
<< : *common-setting
entrypoint:
- "redis-server"
- "--bind 0.0.0.0"
- "--cluster-enabled"
- "yes"
- "--cluster-config-file"
- "nodes.conf"
- "--cluster-node-timeout"
- "5000"
- "--requirepass"
- "37621040"
- "--masterauth"
- "37621040"
- "--maxmemory"
- "1024MB"
- "--maxmemory-policy"
- "volatile-lru"
- "--appendonly"
- "yes"
services:
redis-startup:
<< : *common-startup-setting
command:
- "/bin/bash"
- "-c"
#主从模式 至少6个工作节点
- "redis-cli -h 192.168.35.210 -p 26379 -a 37621040 --cluster create 192.168.35.210:26379 192.168.35.211:26380 192.168.35.212:26381 192.168.35.213:26382 192.168.35.214:26383 192.168.35.215:26384 --cluste