Redis Sentinel 구성 - Docker compose
version: '3.8'
services:
redis-master:
image: redis:latest
container_name: "redis-master"
command:
[
"redis-server",
"--appendonly",
"yes",
"--repl-diskless-load",
"on-empty-db",
"--replica-announce-ip",
"192.168.10.68",
"--replica-announce-port",
"6379",
"--protected-mode",
"no"
]
ports:
- "6379:6379"
networks:
redis-net:
ipv4_address: 172.21.0.3
redis-slave-1:
image: redis:latest
command:
[
"redis-server",
"--appendonly",
"yes",
"--replicaof",
"redis-master",
"6379",
"--replica-announce-ip",
"192.168.10.68",
"--replica-announce-port",
"6380",
"--protected-mode",
"no"
]
container_name: "redis-slave1"
ports:
- "6380:6379"
networks:
redis-net:
ipv4_address: 172.21.0.4
redis-slave-2:
image: redis:latest
command:
[
"redis-server",
"--appendonly",
"yes",
"--replicaof",
"redis-master",
"6379",
"--replica-announce-ip",
"192.168.10.68",
"--replica-announce-port",
"6381",
"--protected-mode",
"no"
]
container_name: "redis-slave2"
ports:
- "6381:6379"
networks:
redis-net:
ipv4_address: 172.21.0.5
sentinel-1:
image: redis:7.4
container_name: sentinel-1
command: >
sh -c 'echo "bind 0.0.0.0" > /etc/sentinel.conf &&
echo "sentinel monitor mymaster 192.168.10.68 6379 2" >> /etc/sentinel.conf &&
echo "sentinel resolve-hostnames yes" >> /etc/sentinel.conf &&
echo "sentinel down-after-milliseconds mymaster 10000" >> /etc/sentinel.conf &&
echo "sentinel failover-timeout mymaster 10000" >> /etc/sentinel.conf &&
echo "sentinel parallel-syncs mymaster 1" >> /etc/sentinel.conf &&
redis-sentinel /etc/sentinel.conf'
ports:
- "26379:26379"
depends_on:
- redis-master
- redis-slave-1
- redis-slave-2
networks:
redis-net:
ipv4_address: 172.21.0.6
sentinel-2:
image: redis:7.4
container_name: sentinel-2
command: >
sh -c 'echo "bind 0.0.0.0" > /etc/sentinel.conf &&
echo "sentinel monitor mymaster 192.168.10.68 6379 2" >> /etc/sentinel.conf &&
echo "sentinel resolve-hostnames yes" >> /etc/sentinel.conf &&
echo "sentinel down-after-milliseconds mymaster 10000" >> /etc/sentinel.conf &&
echo "sentinel failover-timeout mymaster 10000" >> /etc/sentinel.conf &&
echo "sentinel parallel-syncs mymaster 1" >> /etc/sentinel.conf &&
redis-sentinel /etc/sentinel.conf'
ports:
- "26380:26379"
depends_on:
- redis-master
- redis-slave-1
- redis-slave-2
networks:
redis-net:
ipv4_address: 172.21.0.7
sentinel-3:
image: redis:7.4
container_name: sentinel-3
command: >
sh -c 'echo "bind 0.0.0.0" > /etc/sentinel.conf &&
echo "sentinel monitor mymaster 192.168.10.68 6379 2" >> /etc/sentinel.conf &&
echo "sentinel resolve-hostnames yes" >> /etc/sentinel.conf &&
echo "sentinel down-after-milliseconds mymaster 10000" >> /etc/sentinel.conf &&
echo "sentinel failover-timeout mymaster 10000" >> /etc/sentinel.conf &&
echo "sentinel parallel-syncs mymaster 1" >> /etc/sentinel.conf &&
redis-sentinel /etc/sentinel.conf'
ports:
- "26381:26379"
depends_on:
- redis-master
- redis-slave-1
- redis-slave-2
networks:
redis-net:
ipv4_address: 172.21.0.8
networks:
redis-net:
driver: bridge
ipam:
config:
- subnet: 172.21.0.0/16