Redis 클러스터

2023. 7. 10. 13:54· DataBase/Redis
목차
  1. 클러스터 테스트 환경
  2. 클러스터
  3. 클러스터 구성
  4. 클러스터 확인
  5. 클러스터 해제
728x90

redis logo

클러스터 테스트 환경

  • Ubuntu 22.0.4 LTS Version
  • VM 3대로 Master-Slave 구성
    • VM 1대에 Redis 2개씩 기동

클러스터

데이터를 자동으로 여러 개의 Redis 노드에 나누어 저장할 수 있는 데이터 샤딩을 제공하며, 노드가 죽거나 통신이 되지 않을 때에도 작업을 계속 할 수 있는 가용성을 제공

클러스터 구성

1. config 파일 구성

cluster-enabled yes 
cluster-config-file nodes-6379.conf
cluster-node-timeout 3000
  • cluster-enabled : 클러스터 활성화
  • cluster-config-file : 클러스터 구성한 내용을 저장하는 파일명 설정
  • cluster-node-timeout : 클러스터 노드가 다운되었는지 확인하는 시간 단위

2. Redis 기동

  • 총 6대 기동 (VM 3대에 각 2개씩 기동)
$ redis-server [설정파일].conf

3. 클러스터 구성

$ redis-cli --cluster create [VM 1번 ip]:6379 [VM 2번 ip]:6379 [VM 3번 ip]:6379 [VM 1번 ip]:6380 [VM 2번 ip]:6380 [VM 3번 ip]:6380 --cluster-replicas 1

아래와 같은 메시지가 나오면 클러스터가 구성 됨

Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.219.144:6380 to 192.168.219.143:6379
Adding replica 192.168.219.145:6380 to 192.168.219.144:6379
Adding replica 192.168.219.143:6380 to 192.168.219.145:6379
M: 890f8286f6f0558ac1430c9a87acbbe274548e62 192.168.219.143:6379
slots:[0-5460] (5461 slots) master
M: 62bf7e320925316a41108925ed3090198a726199 192.168.219.144:6379
slots:[5461-10922] (5462 slots) master
M: 3f100b2a6321caa821dd7f266b8da02aa406db12 192.168.219.145:6379
slots:[10923-16383] (5461 slots) master
S: 4a0cc430e7e8c50c525134bafb8a0ee9b6ffcdaf 192.168.219.143:6380
replicates 3f100b2a6321caa821dd7f266b8da02aa406db12
S: aff262e06d68406bbe518baf470e5f0e7058072d 192.168.219.144:6380
replicates 890f8286f6f0558ac1430c9a87acbbe274548e62
S: f9977f6dbd7233146a952aa5de26f6efbf354eeb 192.168.219.145:6380
replicates 62bf7e320925316a41108925ed3090198a726199
Can I set the above configuration? (type 'yes' to accept): yes
Nodes configuration updated
Assign a different config epoch to each node
Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
.
Performing Cluster Check (using node 192.168.219.143:6379)
M: 890f8286f6f0558ac1430c9a87acbbe274548e62 192.168.219.143:6379
slots:[0-5460] (5461 slots) master
1 additional replica(s)
M: 3f100b2a6321caa821dd7f266b8da02aa406db12 192.168.219.145:6379
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: aff262e06d68406bbe518baf470e5f0e7058072d 192.168.219.144:6380
slots: (0 slots) slave
replicates 890f8286f6f0558ac1430c9a87acbbe274548e62
S: f9977f6dbd7233146a952aa5de26f6efbf354eeb 192.168.219.145:6380
slots: (0 slots) slave
replicates 62bf7e320925316a41108925ed3090198a726199
M: 62bf7e320925316a41108925ed3090198a726199 192.168.219.144:6379
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
S: 4a0cc430e7e8c50c525134bafb8a0ee9b6ffcdaf 192.168.219.143:6380
slots: (0 slots) slave
replicates 3f100b2a6321caa821dd7f266b8da02aa406db12
[OK] All nodes agree about slots configuration.
Check for open slots...
Check slots coverage...
[OK] All 16384 slots covered.

클러스터 확인

  • redis-cli 접속하여 확인
    • master, slave 연결 확인 가능
$ redis-cli -p 6379

127.0.0.1:6379> cluster nodes
3f100b2a6321caa821dd7f266b8da02aa406db12 192.168.219.145:6379@16379 master - 0 1687842014097 3 connected 10923-16383
aff262e06d68406bbe518baf470e5f0e7058072d 192.168.219.144:6380@16380 slave 890f8286f6f0558ac1430c9a87acbbe274548e62 0 1687842014503 1 connected
f9977f6dbd7233146a952aa5de26f6efbf354eeb 192.168.219.145:6380@16380 slave 62bf7e320925316a41108925ed3090198a726199 0 1687842014098 2 connected
890f8286f6f0558ac1430c9a87acbbe274548e62 192.168.219.143:6379@16379 myself,master - 0 1687842013000 1 connected 0-5460
62bf7e320925316a41108925ed3090198a726199 192.168.219.144:6379@16379 master - 0 1687842014000 2 connected 5461-10922
4a0cc430e7e8c50c525134bafb8a0ee9b6ffcdaf 192.168.219.143:6380@16380 slave 3f100b2a6321caa821dd7f266b8da02aa406db12 0 1687842014605 3 connected

클러스터 해제

  • Redis 데이터 삭제
$  redis-cli --cluster call localhost:6379 flushall
  • Redis 클러스터 리셋
    • hard : node Id 새로 할당, Epoch 데이터 0으로 초기화
    • soft : 이전 node Id 유지, Epoch 데이터 유지
$ redis-cli --cluster call localhost:6379 cluster reset hard

Calling cluster reset hard

localhost:6379: OK
  • 클러스터 해제 확인
$ redis-cli --cluster call localhost:6379 cluster nodes

//클러스터 노드가 1개인 것을 확인

Calling cluster nodes
localhost:6379: 8f7dc25f39d8f4ff0324c290edecd48b3b47682c 192.168.219.143:6379@16379 myself,master - 0 1687849216000 0 connected

 

728x90
저작자표시 비영리 변경금지 (새창열림)

'DataBase > Redis' 카테고리의 다른 글

Redis 설정(GENERAL)  (0) 2023.07.12
Redis 설정(NetWork)  (0) 2023.07.12
Benchmark  (0) 2023.07.10
Redis 기동 및 종료  (0) 2023.06.08
Redis 설치  (0) 2023.06.08
  1. 클러스터 테스트 환경
  2. 클러스터
  3. 클러스터 구성
  4. 클러스터 확인
  5. 클러스터 해제
'DataBase/Redis' 카테고리의 다른 글
  • Redis 설정(NetWork)
  • Benchmark
  • Redis 기동 및 종료
  • Redis 설치
JOTAN
JOTAN
기술 블로그
JOTAN
조탄 기술블로그
JOTAN
전체
오늘
어제
  • 목 록
    • Security
    • WEB
      • WebtoB
      • Apache
      • Nginx
    • WAS
      • Tomcat
      • JEUS
    • Observability
      • Fluentd
    • CI CD
    • DataBase
      • Redis
      • PostgreSQL
      • Victoria Metrics
    • Container Registry
      • Harbor
    • Docker
    • Kubernetes
    • Message Queue
      • Kafka
    • 개발
      • Spring Boot
      • Java
      • Shell Script
    • 기본지식
    • OS
      • Debian
      • Red Hat

블로그 메뉴

  • 홈

공지사항

  • 조'S IT 영역

인기 글

태그

  • kubernetes dns
  • victoria metrics
  • kubernetes install
  • 쿠버네티스 설치
  • webtob
  • fluentd
  • SSL
  • nginx
  • KAFKA
  • 설치
  • 쿠버네티스
  • Redis 기능 검증
  • Kubernetes
  • hostaliases
  • 인증서
  • kubernetes dashboard
  • apache
  • apache vhosts
  • Redis TEST
  • ssl vhosts
  • tomcat
  • Redis Cache
  • redis
  • harbor
  • victoria metrics 설치
  • 레디스
  • redis 설정
  • 쿠버네티스 대시보드
  • 레디스 설정
  • apache ssl 설정

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
JOTAN
Redis 클러스터
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.