Redis CLUSTER FAILOVER

Redis Cluster Course Redis Technical Support Redis Enterprise Server

Redis CLUSTER FAILOVER

CLUSTER FAILOVER [FORCE|TAKEOVER]는 슬레이브 노드를 마스터 노드로 역할을 바꾸어 주는 명령이다.
이 명령은 슬레이브 노드에서만 실행 수 있다.

이 문서는 버전 3.2.0을 기준으로 만들었습니다.

사용법

  • No option: 마스터가 살아있을 때 사용한다.
  • FORCE: 마스터가 다운되었을 때 사용한다.
  • TAKEOVER: 마스터가 다운되었고, 마스터 개수가 2개 이하일 때 사용한다.

Master 1 - Slave 1 일때: cluster failover를 사용

  • CLUSTER FAILOVER
  • [redis-3.2.0]# src2/redis-cli -p 7001 cluster failover
    OK
  • Master 7000번 서버 로그
  • 22:07:25.759 # Manual failover requested by slave 7b93c61f5600b44fc123d4e553096264f9406520.
    22:07:26.018 # Failover auth granted to 7b93c61f5600b44fc123d4e553096264f9406520 for epoch 2
    22:07:26.018 # Connection with slave 127.0.0.1:7001 lost.
    22:07:26.039 # Configuration change detected. Reconfiguring myself as a replica of 7b93c61f5600b44fc123d4e553096264f9406520
    22:07:26.824 * Connecting to MASTER 127.0.0.1:7001
    22:07:26.824 * MASTER <-> SLAVE sync started
    22:07:26.824 * Non blocking connect for SYNC fired the event.
    22:07:26.824 * Master replied to PING, replication can continue...
    22:07:26.824 * Partial resynchronization not possible (no cached master)
    22:07:26.825 * Full resync from master: e70c6ce94355b9cd5986c21930835ffc4fe92e6e:3891
    22:07:26.894 * MASTER <-> SLAVE sync: receiving 1566 bytes from master
    22:07:26.895 * MASTER <-> SLAVE sync: Flushing old data
    22:07:26.895 * MASTER <-> SLAVE sync: Loading DB in memory
    22:07:26.895 * MASTER <-> SLAVE sync: Finished with success
  • Master 7001번 서버 로그
  • 22:07:25.759 # Manual failover user request accepted.
    22:07:25.821 # Received replication offset for paused master manual failover: 3890
    22:07:25.891 # All master replication stream processed, manual failover can start.
    22:07:25.891 # Start of election delayed for 0 milliseconds (rank #0, offset 3890).
    22:07:25.992 # Starting a failover election for epoch 2.
    22:07:26.018 # Failover election won: I'm the new master.
    22:07:26.018 # configEpoch set to 2 after successful failover
    22:07:26.018 # Connection with master lost.
    22:07:26.018 * Caching the disconnected master state.
    22:07:26.018 * Discarding previously cached master state.
    22:07:26.825 * Slave 127.0.0.1:7000 asks for synchronization
    22:07:26.825 * Full resync requested by slave 127.0.0.1:7000
    22:07:26.825 * Starting BGSAVE for SYNC with target: disk
    22:07:26.825 * Background saving started by pid 52834
    22:07:26.841 * DB saved on disk
    22:07:26.841 * RDB: 0 MB of memory used by copy-on-write
    22:07:26.894 * Background saving terminated with success
    22:07:26.894 * Synchronization with slave 127.0.0.1:7000 succeeded
  • FAILOVER 결과
  • [redis-3.2.0]# src2/redis-cli -p 7001 cluster slots
    1) 1) (integer) 0
        2) (integer) 16383
        3) 1) "127.0.0.1"
            2) (integer) 7001
            3) "7b93c61f5600b44fc123d4e553096264f9406520"
        4) 1) "127.0.0.1"
            2) (integer) 7000
            3) "3a452aae5e19b91f212eef18276325b13cd57513"

Master 1 이 다운되고 Slave 1 만 살아있을 일때 cluster failover takeover를 사용

  • CLUSTER FAILOVER를 사용하면
  • [redis-3.2.0]# src/redis-cli -p 7000 cluster failover
    (error) ERR Master is down or failed, please use CLUSTER FAILOVER FORCE
  • CLUSTER FAILOVER FORCE를 사용하면
  • [redis-3.2.0]# src/redis-cli -p 7000 cluster failover force
    7000번 서버 로그: failover는 되지 않는다.
    22:31:50.126 # Forced failover user request accepted.
    22:31:50.215 # Start of election delayed for 0 milliseconds (rank #0, offset 5795).
    22:31:50.315 # Starting a failover election for epoch 3.
    22:31:50.416 # Currently unable to failover: Waiting for votes, but majority still not reached.
  • CLUSTER FAILOVER TAKEOVER: failover 성공
  • [redis-3.2.0]# src/redis-cli -p 7000 cluster failover takeover
    7000번 서버 로그
    22:32:13.557 # Taking over the master (user request).
    22:32:13.557 # New configEpoch set to 4
    22:32:13.557 * Discarding previously cached master state.
    22:32:16.498 # Cluster state changed: ok

명령문

CLUSTER FAILOVER [FORCE|TAKEOVER]

  • 이 명령은 version 3.0.0 부터 사용할 수 있다.
  • 논리적 처리 소요시간은 O(1)이다.

Clients for Java Jedis, Lettuce
Clients for C Hiredis

<< CLUSTER SLOTS CLUSTER FAILOVER CLUSTER COUNT-FAILURE-REPORTS >>

조회수 :

Email 답글이 올라오면 이메일로 알려드리겠습니다.

혹시 처음이세요?
레디스게이트에는 레디스에 대한 많은 정보가 있습니다.
레디스 소개, 명령어, SQL, 클라이언트, 서버, 센티널, 클러스터 등이 있습니다.
혹시 필요한 정보를 찾기 어려우시면 redisgate@gmail.com로 메일 주세요.
제가 찾아서 알려드리겠습니다.
 
close
IP를 기반으로 보여집니다.