클러스터 노드 추가, slot 이동, 노드 제거 (add-node, reshard, rebalance)
Redis클러스터명령어
# Add the new master to the cluster (joins empty, with no slots):
redis-cli --cluster add-node node7:6379 node1:6379
# Attach a new replica to a specific master:
redis-cli --cluster add-node node8:6379 node1:6379 --cluster-slave --cluster-master-id <master-node-id>
# Move 1000 slots from all masters to the new node:
redis-cli --cluster reshard node1:6379 --cluster-from all --cluster-to <node7-id> --cluster-slots 1000 --cluster-yes
# Or rebalance automatically (give slots to empty masters too):
redis-cli --cluster rebalance node1:6379 --cluster-use-empty-masters
# Remove a node whose slots have been emptied:
redis-cli --cluster del-node node1:6379 <node-id>하는 일
클러스터에 새 master 또는 replica를 추가하고, 노드 간에 slot과 key를 온라인으로 이동하며, slot 분포를 자동으로 재조정하고, 비워진 노드를 클러스터에서 제거한다.
사용 시점
메모리/처리량을 수평 확장할 때, hot 노드의 부하를 분산할 때, 또는 노드를 폐기할 때.
주의
slot 마이그레이션은 MIGRATE로 key를 하나씩 전송한다. 큰 key가 이동하는 동안 두 노드가 잠시 블로킹될 수 있다. 마이그레이션 중 클라이언트는 ASK 리다이렉트를 받으므로 cluster-aware 클라이언트가 필요하다. reshard가 중단되면 slot이 migrating/importing 상태로 남으므로 --cluster fix로 완료한다. 아직 slot을 소유한 master를 del-node로 제거하지 않는다. 먼저 slot을 옮긴다.