[redis] 도커컴포즈로 레디스 클러스터 3개 만들기 (docker-compose)

[redis] 도커컴포즈로 레디스 클러스터 3개 만들기 (docker-compose)

3_redis_cluster.zip 0.00MB

docker-compose.yml

version: '3' services: # redis:6.2.6 redis1: hostname: redis1 container_name: redis1 image: redis:6.2.6 network_mode: "host" command: redis-server /etc/redis.conf volumes: - ./redis1.conf:/etc/redis.conf ports: - 7001:7001 - 17001:17001 # redis:6.2.6 redis2: hostname: redis2 container_name: redis2 image: redis:6.2.6 network_mode: "host" command: redis-server /etc/redis.conf volumes: - ./redis2.conf:/etc/redis.conf ports: - 7002:7002 - 17002:17002 # redis:6.2.6 redis3: hostname: redis3 container_name: redis3 image: redis:6.2.6 network_mode: "host" command: redis-server /etc/redis.conf volumes: - ./redis3.conf:/etc/redis.conf ports: - 7003:7003 - 17003:17003

redis1.conf

port 7001 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 3000 appendonly yes

redis2.conf

port 7002 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 3000 appendonly yes

redis3.conf

port 7003 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 3000 appendonly yes

도커 컴포즈 실행

docker-compose up -d

컨테이너 실행 상태 확인

docker ps

redis1 컨테이너 접속

docker exec -it redis1 bash

클러스터 만들기

redis-cli --cluster create 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003

redis-cli 접속

redis-cli -p 7001

클러스터 정보 확인

cluster info

클러스터 노드 확인

cluster nodes

from http://pinggoopark.tistory.com/268 by ccl(A) rewrite - 2021-12-27 18:00:51