クラスタでノードの追加、スロットの移動、ノードの削除を行う (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>概要
クラスタに新しいマスターまたはレプリカを追加し、ノード間でスロットとそのキーをオンラインで移動し、スロットの分散を自動的に再バランスし、空にしたノードをクラスタから削除する。
使用する場面
メモリ / スループットを水平方向に拡張する場合、ホットノードの負荷を分散する場合、またはノードを廃止する場合。
注意
スロットの移行は MIGRATE でキーを 1 つずつ転送する。大きなキーの移動中は、両方のノードが短時間ブロックされることがある。移行中、クライアントは ASK リダイレクトを受け取るため、クラスタ対応のクライアントが必要。reshard が中断されると、スロットは migrating/importing 状態のまま残るため、--cluster fix で完了させる。まだスロットを所有しているマスターを del-node で削除しない。先にスロットを移動する。