Mes Post-Its
Raphael Piccolo

redis master slave

Retour

docker-compose.yml

version: "3.7"
services:
  redismaster:
    image: redis
    container_name: redismaster

  redisslave:
    image: redis
    container_name: redisslave
    command: redis-server --slaveof redismaster 6379

test it

# start redis
docker compose up -d
# set a value on master
docker exec -ti redismaster redis-cli set a 1
# get a value on slave (shows "1")
docker exec -ti redisslave redis-cli get a

i can kill a slave and restart it and it has the updated data

docker rm -f redisslave
docker compose up -d
docker exec -ti redisslave redis-cli get a

i can kill the master and the slave still have the data

if i kill the master the data is gone.
to keep the data i need to activate persistence (run bgsave) and add a volume like ./master:/data


cv.raphaelpiccolo.com |Connexion