HASH_SLOT = CRC16(key) mod 16384
MEGET user1:name user2:name
{ }
사이에 있는 문자열로 해싱하여 해시슬롯에 배치하는 방법{ }
가 여러개 있다면 가장 처음의 {
부터 가장 처음의 }
사이 값들이 해싱된다.user:{123}:profile
user:{123}:account
cluster-require-full-coverage yes
cluster-allow-repolica-migration
옵션이 yes일 때 동작cluster-migration-barrier
cluster-enabled
설정을 yes로 변경해 클러스터 모드로 변경할 수 있다.cluster-enabled yes
—cluster create
옵션을 이용해 새로운 클러스터를 생성—cluster-replicas
1 옵션으로 각 마스터마다 1개 복제본을 추가$ src/redis-cli --cluster create 192.168.0.11:6379 192.168.0.22:6379 ... --cluster replicas 1 -a nhncloud
CLUSTER NODES
커맨드로 현재 클러스터 상태를 확인할 수 있다.
<id> <ip:port@cport> <flags> <master> <ping-sent> <pong-recv> <config-epoch> <link-state> <slot> <slot> ... <slot>
cluster failover
커맨드로 페일오버를 발생시킬 수 있다.redis-cli -h <master-host> -p <master-port> shutdown
redis-cli --cluster reshard <host>:<port>
redis-cli --cluster reshard <host>:<port> --cluster-from <node-id>
--cluster-to <node-id> --cluster-slots <number of slots> --cluster-yes
redis-cli —cluster add-node <추가할 노드 IP:PORT> <기존 노드 IP:PORT>
redis-cli —cluster add-node <추가할 노드 IP:PORT> <기존 노드 IP:PORT> —cluster-slave [—cluster-master-id <기존 마스터 ID> ]
redis-cli —cluster del-node <기존 노드 IP:PORT> <삭제할 노드 ID>
CLUSTER FORGET
, CLUSTER RESET SOFT
를 수행했다는 로그가 남는다.CLUSTER FORGET
CLUSTER FORGET <node-id>
를 수신한 노드는 노드 테이블에서 해당 노드 정보를 지운다.CLUSTER RESET
SOFT
와 HARD
옵션이 있으며 기본은 SOFT
redis-cli --cluster import 192.168.0.11:6379 --cluster-from 192.168.0.88:6379 --cluster-copy
$ redis-cli -h 192.168.0.55 -c
192.168.0.55:6379> readonly
OK
CLUSTER MEET
CLUSTER MEET
를 통해 신규 연결을 맺게 된다.CLUSTER SETSLOT 8 MIGRATING B
CLUSTER SETSLOT 8 IMPORTING A