Created
June 28, 2024 16:58
-
-
Save sombriks/8a518063098334f27dd23c41bb44c52e to your computer and use it in GitHub Desktop.
docker compose for testing redis cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# need to run this to have a proper local cluster | |
sleep 5 ; echo yes | redis-cli --cluster create redis-7003:7003 redis-7001:7001 redis-7002:7002 --cluster-replicas 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# compose to spin up an actual redis cluster. | |
# whenever a standalone redis is not enough for | |
# your testing workflow and you find the docs too | |
# vague, remember that to provision a cluster you | |
# actually need more than one instance (3 at least!) | |
# and do one more step to make them an actual cluster. | |
services: | |
redis-7001: | |
image: redis:7.0.10-alpine3.17 | |
ports: | |
- "7001:7001" | |
volumes: | |
- ./redis-7001.conf:/data/redis.conf # provide a redis.conf | |
entrypoint: [ "redis-server", "/data/redis.conf" ] | |
redis-7002: | |
image: redis:7.0.10-alpine3.17 | |
ports: | |
- "7002:7002" | |
volumes: | |
- ./redis-7002.conf:/data/redis.conf # provide a redis.conf | |
entrypoint: [ "redis-server", "/data/redis.conf" ]] | |
redis-7003: | |
image: redis:7.0.10-alpine3.17 | |
ports: | |
- "7003:7003" | |
volumes: | |
- ./redis-7003.conf:/data/redis.conf # provide a redis.conf | |
entrypoint: [ "redis-server", "/data/redis.conf" ] | |
redis-cluster-creator: | |
image: redis:7.0.10-alpine3.17 | |
depends_on: | |
redis-7001: | |
condition: service_started | |
redis-7002: | |
condition: service_started | |
redis-7003: | |
condition: service_started | |
volumes: | |
- ./create-cluster.sh:/create-cluster.sh | |
entrypoint: ["sh", "/create-cluster.sh" ] | |
# install and call redis-cli on host if everything else fails | |
# echo yes | redis-cli --cluster create localhost:7003 localhost:7001 localhost:7002 --cluster-replicas 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port 7001 | |
cluster-enabled yes | |
cluster-node-timeout 1500 | |
cluster-slave-validity-factor 0 | |
cluster-require-full-coverage no | |
cluster-allow-reads-when-down no | |
appendonly yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port 7002 | |
cluster-enabled yes | |
cluster-node-timeout 1500 | |
cluster-slave-validity-factor 0 | |
cluster-require-full-coverage no | |
cluster-allow-reads-when-down no | |
appendonly yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port 7003 | |
cluster-enabled yes | |
cluster-node-timeout 1500 | |
cluster-slave-validity-factor 0 | |
cluster-require-full-coverage no | |
cluster-allow-reads-when-down no | |
appendonly yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment