linux目录结构
内网配置
哨兵配置文件如下,创建3个哨兵配置文件
# sentinel26379.conf sentinel26380.conf sentinel26381.conf 内容如下
protected-mode no
sentinel monitor mymaster redis-master 6379 2
sentinel down-after-milliseconds mymaster 60000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
docker-compose.yaml
version: '3'
services:
redis-master:
image: redis:4.0.8
container_name: redis-master
ports:
- "6379:6379"
volumes:
- redis-master-data:/data
command: ["redis-server", "--appendonly", "yes"]
redis-slave1:
image: redis:4.0.8
container_name: redis-slave1
ports:
- "6380:6379"
volumes:
- redis-slave1-data:/data
command: ["redis-server", "--slaveof", "redis-master", "6379", "--appendonly", "yes"]
depends_on:
- redis-master
redis-slave2:
image: redis:4.0.8
container_name: redis-slave2
ports:
- "6381:6379"
volumes:
- redis-slave2-data:/data
command: ["redis-server", "--slaveof", "redis-master", "6379", "--appendonly", "yes"]
depends_on:
- redis-master
redis-sentinel-1:
image: redis:4.0.8
container_name: redis-sentinel-1
ports:
- "26379:26379"
volumes:
- ./sentinel26379.conf:/usr/local/etc/redis/sentinel.conf
command: ["redis-sentinel", "/usr/local/etc/redis/sentinel.conf"]
depends_on:
- redis-master
- redis-slave1
- redis-slave2
redis-sentinel-2:
image: redis:4.0.8
container_name: redis-sentinel-2
ports:
- "26380:26379"
volumes:
- ./sentinel26380.conf:/usr/local/etc/redis/sentinel.conf
command: ["redis-sentinel", "/usr/local/etc/redis/sentinel.conf"]
depends_on:
- redis-master
- redis-slave1
- redis-slave2
redis-sentinel-3:
image: redis:4.0.8
container_name: redis-sentinel-3
ports:
- "26381:26379"
volumes:
- ./sentinel26381.conf:/usr/local/etc/redis/sentinel.conf
command: ["redis-sentinel", "/usr/local/etc/redis/sentinel.conf"]
depends_on:
- redis-master
- redis-slave1
- redis-slave2
volumes:
redis-master-data:
redis-slave1-data:
redis-slave2-data:
host版本
version: '3'
services:
redis-master:
image: redis:4.0.8
container_name: redis-master
network_mode: host
ports:
- "17000:17000"
volumes:
- redis-master-data:/data
command: ["redis-server", "--appendonly", "yes","--port","17000"]
redis-slave1:
image: redis:4.0.8
container_name: redis-slave1
network_mode: host
ports:
- "17001:17001"
volumes:
- redis-slave1-data:/data
command: ["redis-server", "--slaveof", "192.168.0.203", "17000", "--appendonly", "yes","--port","17001"]
depends_on:
- redis-master
redis-slave2:
image: redis:4.0.8
container_name: redis-slave2
network_mode: host
ports:
- "17002:17002"
volumes:
- redis-slave2-data:/data
command: ["redis-server", "--slaveof", "192.168.0.203", "17000", "--appendonly", "yes","--port","17002"]
depends_on:
- redis-master
redis-sentinel-1:
image: redis:4.0.8
container_name: redis-sentinel-1
network_mode: host
ports:
- "16000:16000"
volumes:
- ./sentinel16000.conf:/usr/local/etc/redis/sentinel.conf
command: ["redis-sentinel", "/usr/local/etc/redis/sentinel.conf"]
depends_on:
- redis-master
- redis-slave1
- redis-slave2
redis-sentinel-2:
image: redis:4.0.8
container_name: redis-sentinel-2
network_mode: host
ports:
- "16001:16001"
volumes:
- ./sentinel16001.conf:/usr/local/etc/redis/sentinel.conf
command: ["redis-sentinel", "/usr/local/etc/redis/sentinel.conf"]
depends_on:
- redis-master
- redis-slave1
- redis-slave2
redis-sentinel-3:
image: redis:4.0.8
container_name: redis-sentinel-3
network_mode: host
ports:
- "16002:16002"
volumes:
- ./sentinel16002.conf:/usr/local/etc/redis/sentinel.conf
command: ["redis-sentinel", "/usr/local/etc/redis/sentinel.conf"]
depends_on:
- redis-master
- redis-slave1
- redis-slave2
volumes:
redis-master-data:
redis-slave1-data:
redis-slave2-data:
protected-mode no
sentinel myid d1ccb49b4c07533de9e7357402dcb79e2f4a4458
sentinel monitor mymaster 192.168.0.203 17000 2
sentinel down-after-milliseconds mymaster 60000
sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
port 16000
dir "/data"
############################################################
protected-mode no
sentinel myid d1ccb49b4c07533de9e7357402dcb79e2f4a4458
sentinel monitor mymaster 192.168.0.203 17000 2
sentinel down-after-milliseconds mymaster 60000
sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
port 16001
dir "/data"
############################################################
protected-mode no
sentinel myid d1ccb49b4c07533de9e7357402dcb79e2f4a4458
sentinel monitor mymaster 192.168.0.203 17000 2
sentinel down-after-milliseconds mymaster 60000
sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
port 16002
dir "/data"