ããã¯ããªã«ãããããŠæžãããã®ïŒ
- Redis 5.0ããªãªãŒã¹ãããã¯ã©ã¹ã¿ãæ§æããã³ãã³ã ãæ°ãããªã£ãããã
- ä¹ ãã¶ãã«ãRedis Clusterãæ§æããŠéãã§ã¿ãã
ãšãããåã«Redis 5.0ã§ã®æé ã§Redis Clusterãæ§æããŠã¿ãããšãããšã³ããªã§ãã
ãªããRedis 3.0ã®é ã«Redis Clusterãæ§æããŠéãã ããšãããã®ã§ããã¡ããèŠã€ã€ã©ãå€ãã£ãŠãã£ããã確èªããŠ
ãããããšæããŸãã
Ubuntu LinuxでRedis ClusterのDockerイメージを作って遊ぶ - CLOVER🍀
Redis 5.0ã®æŽæ°å 容ã¯ããã¡ãã«ãŸãšãŸã£ãŠããã®ã§åèã«ãããŠããã ããŸããã
Redis Clusterã£ãŠãªã«ïŒ
ååã®ãšã³ããªã§ãæžããŠããã®ã§ãããããããçã«ã
- è€æ°ã®RedisããŒãã䜿ã£ãŠæ§æããã¯ã©ã¹ã¿ã§ãããŒã¿ã¯èªåçã«ã·ã£ãŒãã£ã³ã°ããŠä¿æããã
- äžéšã®ãµãŒããŒã§é害ããã£ãŠããåŠçãç¶ç¶å¯èœ
- ã¹ã¬ãŒãïŒã¬ããªã«ïŒãæãŠã
ãã ãå€§èŠæš¡ãªé害ïŒå€æ°ã®ãã¹ã¿ãŒã忢ãããªã©ïŒãçºçããå Žåã¯ãã¯ã©ã¹ã¿ã¯åæ¢ããããã§ãã
ãŸããéåžžã®Redisãšéã£ãŠTCPããŒãã2ã€å¿
èŠã§ãéåžžã®Redisã¯ïŒããã©ã«ãã§ïŒ6379ããŒãã䜿çšããŸããã
10000ã远å ããããŒãïŒäŸãã°16379ïŒã䜿çšããŸãã
ãã®ããã²ãšã€ã®ããŒãã¯ãã¯ã©ã¹ã¿ããŒãéã§ã®éä¿¡ã«äœ¿çšãããé害æ€åºãæ§æã®æŽæ°ããã§ã€ã«ãªãŒããŒã®èš±å¯
ãªã©ãšãã£ãçšéã§äœ¿çšãããŸãããã®ããŒãã®éä¿¡ã鮿ãããšãRedis Clusterå
ã®ããŒããããŸãéä¿¡ã§ããªããªããŸãã
ãã®10000ãšããããŒãã®ãªãã»ããã¯ãåºå®ã¿ããã§ãã
ã¹ã¬ãŒãã«ã€ããŠã§ããããã¹ã¿ãŒãšã¹ã¬ãŒãã«ã€ããŠã¯ãã£ã¡ã圹å²ãããããŠãããããªã®ã§ãäŸãã°
ã¬ããªã«æ°ã1ã«ãããšãRedis Clusterãæ§æããã«ã¯ãã¹ã¿ãŒæ°Ã2ã®ããŒããå¿
èŠã«ãªããŸãã
3å°åã®ããŒã¿ãæã¡ããæã«ãã¬ããªã«æ°ã1ã«ãããšãèš6ããŒãå¿
èŠã«ãªããŸãããšãã¯ã©ã¹ã¿ã®æ§ææã«ã¬ããªã«æ°ã
æå®ããã®ã§ãããåæããŒãæ°ããã®èšç®ãäžåããšãšã©ãŒã«ãªããŸãã
ãã£ããã豪快ãªâŠã
ç°å¢
ä»å䜿çšããŠããRedisã¯ã5.0.2ã§ãããŸããOSã¯Ubuntu Linux 18.04 LTSã
ãµãŒããŒã¯ãRedis3å°æ§æãšããŸããIPã¢ãã¬ã¹ã®ç¯å²ã¯172.17.0.2ã4ãããŒãã¯æšæºã®6379ã
Redisèªäœã¯ããã«ãã»ã€ã³ã¹ããŒã«æžã¿ãšããŸãã
åRedisãµãŒããŒã®èµ·å
ãµãŒããŒããããã«ãèšå®ãã¡ã€ã«ãçšæã
conf/redis.conf
bind 0.0.0.0 port 6379 masterauth redispass cluster-enabled yes cluster-config-file conf/nodes.conf cluster-node-timeout 5000 appendonly yes
èšå®ã¯ãããã¥ã¡ã³ããèŠã€ã€ã
Redis cluster tutorial – Redis
ãã¥ãŒããªã¢ã«ã§ã¯7000ããŒã以éã䜿çšããŠããŸãããä»åã¯ããã©ã«ãã®ããŒãããã®ãŸãŸäœ¿ãããšã«ããŸããã
ãŸãããã¹ã¯ãŒãã¯ãredispassããšããŠããŸãã
Redis Clusterã«é¢ããèšå®ã¯ããã¡ããåç §ã
Redis Cluster configuration parameters
ä»åèšå®ããŠããRedis Clusteré¢é£ã®ãã©ã¡ãŒã¿ãŒã¯ããcluster-enabledãããcluster-config-fileãããcluster-node-timeoutãã®
3ã€ã§ãã
èšå®ã®ãµã³ãã«ã¯ããã¡ããåç §ã
Creating and using a Redis Cluster
ãã®èšå®ã§ãåRedisãµãŒããŒãèµ·åããŸãã
## 172.17.0.2 $ bin/redis-server conf/redis.conf ## 172.17.0.3 $ bin/redis-server conf/redis.conf ## 172.17.0.4 $ bin/redis-server conf/redis.conf
ã¯ã©ã¹ã¿ãæ§æãã
ããã§ã¯ãRedis Clusterãæ§æããŠã¿ãŸãããã
$ bin/redis-cli --cluster create 172.17.0.2:6379 172.17.0.3:6379 172.17.0.4:6379 >>> Performing hash slots allocation on 3 nodes... Master[0] -> Slots 0 - 5460 Master[1] -> Slots 5461 - 10922 Master[2] -> Slots 10923 - 16383 M: fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379 slots:[0-5460] (5461 slots) master M: 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379 slots:[5461-10922] (5462 slots) master M: a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379 slots:[10923-16383] (5461 slots) master 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 172.17.0.2:6379) M: fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379 slots:[0-5460] (5461 slots) master M: 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379 slots:[5461-10922] (5462 slots) master M: a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379 slots:[10923-16383] (5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
ã¯ã©ã¹ã¿ãæ§æãããŸããã
åããŒãã®ãã°ã«ã¯ãã¯ã©ã¹ã¿æ§ææã«ãããªæãã®ãã°ãåºåãããŸãã
9:M 25 Nov 2018 14:29:11.190 # configEpoch set to 3 via CLUSTER SET-CONFIG-EPOCH 9:M 25 Nov 2018 14:29:11.256 # IP address for this node updated to 172.17.0.4 9:M 25 Nov 2018 14:29:16.160 # Cluster state changed: ok
ä»åã¯3ããŒãã§æ§æããããšããŠããã®ã§ãäŸãã°ã--cluster-replicasãã1ãã倧ãããããšãã¬ããªã«ãäœãã ãã®
ããŒãæ°ãè¶³ããªããªãã®ã§ãã³ãã³ãã®å®è¡ã«å€±æããŸãã
$ bin/redis-cli --cluster create 172.17.0.2:6379 172.17.0.3:6379 172.17.0.4:6379 --cluster-replicas 1 *** ERROR: Invalid configuration for cluster creation. *** Redis Cluster requires at least 3 master nodes. *** This is not possible with 3 nodes and 1 replicas per node. *** At least 6 nodes are required.
ã€ãŸããä»åã®æ§æã¯èé害æ§ã®ãªãæ§æããã¹ãŠã®ããŒãããã¹ã¿ãŒããŒããšãªã£ãŠããŸãã
ãšããã§ã以åã¯ãã®ã³ãã³ãã¯ãredis-trib.rbããšããRubyã¹ã¯ãªããã§è¡ã£ãŠããŸããã
Redis 5.0ã§ã¯ããããredis-cliã§å®è¡ããããšãå¯èœã«ãªã£ãŠããŸãã
å°ãåãŸã§ã¯ãã¯ã©ã¹ã¿ã®ãã¥ãŒããªã¢ã«ãredis-cliã®ã¿ã®å
容ã«ãªã£ãŠããã®ã§ãããæè¿ã«ãªã£ãŠredis-trib.rbã®å
容ã
æžãããã«ä¿®æ£ãããã¿ããã§ãã
Add info about redis-trib back into the Cluster tutorial.
Redis 4ããã³3ã¯ããŸã redis-trib.rbã䜿ãããã§ãããããã
ã¯ã©ã¹ã¿ã®æ å ±ã確èªããŠã¿ã
ã¯ã©ã¹ã¿ã®æ å ±ãèŠãŠã¿ãŸãããããredis-cliãã䜿ããŸãã
$ bin/redis-cli cluster info cluster_state:ok cluster_slots_assigned:16384 cluster_slots_ok:16384 cluster_slots_pfail:0 cluster_slots_fail:0 cluster_known_nodes:3 cluster_size:3 cluster_current_epoch:3 cluster_my_epoch:1 cluster_stats_messages_ping_sent:35 cluster_stats_messages_pong_sent:36 cluster_stats_messages_sent:71 cluster_stats_messages_ping_received:34 cluster_stats_messages_pong_received:35 cluster_stats_messages_meet_received:2 cluster_stats_messages_received:71
ããŒãã®æ å ±ã
$ bin/redis-cli cluster nodes 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379@16379 master - 0 1543156193386 2 connected 5461-10922 a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379@16379 master - 0 1543156192383 3 connected 10923-16383 fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379@16379 myself,master - 0 1543156191000 1 connected 0-5460
ãã®æ å ±ãèšå®é ç®ãcluster-config-fileãã«èšèŒãããå 容ãåºåãããŠããæããããŸããã
$ cat conf/nodes.conf 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379@16379 master - 0 1543156151447 2 connected 5461-10922 a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379@16379 master - 0 1543156151447 3 connected 10923-16383 fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379@16379 myself,master - 0 0 1 connected 0-5460 vars currentEpoch 3 lastVoteEpoch 0
ãredis-cli --cluster infoãã§ãã䌌ããããªæ å ±ãåŸãããŸãã
$ bin/redis-cli --cluster info 172.17.0.2:6379 172.17.0.2:6379 (fbf478e6...) -> 0 keys | 5461 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 0 keys | 5462 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 0 keys | 5461 slots | 0 slaves. [OK] 0 keys in 3 masters. 0.00 keys per slot on average.
ãredis-cli --clusterãã®ãã«ãã¯ããhelpãã³ãã³ãã§ç¢ºèªã§ããŸãã
$ bin/redis-cli --cluster help Cluster Manager Commands: create host1:port1 ... hostN:portN --cluster-replicas <arg> check host:port info host:port fix host:port reshard host:port --cluster-from <arg> --cluster-to <arg> --cluster-slots <arg> --cluster-yes --cluster-timeout <arg> --cluster-pipeline <arg> rebalance host:port --cluster-weight <node1=w1...nodeN=wN> --cluster-use-empty-masters --cluster-timeout <arg> --cluster-simulate --cluster-pipeline <arg> --cluster-threshold <arg> add-node new_host:new_port existing_host:existing_port --cluster-slave --cluster-master-id <arg> del-node host:port node_id call host:port command arg arg .. arg set-timeout host:port milliseconds import host:port --cluster-from <arg> --cluster-copy --cluster-replace help For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
ããŒã¿ãæäœããŠã¿ã
ç¶ããŠãããŒã¿ãæäœããŠã¿ãŸãããããredis-cliãã§æ¥ç¶ã
$ bin/redis-cli -h 172.17.0.2 -p 6379 172.17.0.2:6379>
ãªã«ãä»ããªããšãããŒã®é 眮å ã«ãã£ãŠã¯ãšã©ãŒã«ãªããŸããå¥ã®ããŒããžã®ãªãã€ã¬ã¯ããå¿ èŠã«ãªãããã§ãã
172.17.0.2:6379> set key1 value1 (error) MOVED 9189 172.17.0.3:6379
ãããåé¿ããâŠèªåã§ãªãã€ã¬ã¯ãããŠãããã«ã¯ãã-cããªãã·ã§ã³ãä»ããŸãã
$ bin/redis-cli -h 172.17.0.2 -p 6379 -c 172.17.0.2:6379>
ä»åºŠã¯OKã§ãã
172.17.0.2:6379> set key1 value1 -> Redirected to slot [9189] located at 172.17.0.3:6379 OK 172.17.0.3:6379> set key2 value2 -> Redirected to slot [4998] located at 172.17.0.2:6379 OK 172.17.0.2:6379> set key3 value3 OK 172.17.0.2:6379> set key4 value4 -> Redirected to slot [13120] located at 172.17.0.4:6379 OK 172.17.0.4:6379> set key5 value5 -> Redirected to slot [9057] located at 172.17.0.3:6379 OK 172.17.0.3:6379> set key6 value6 -> Redirected to slot [4866] located at 172.17.0.2:6379 OK
ããããèŠããšããªãã€ã¬ã¯ããããããšæ¥ç¶å ã®ããŒããåãæ¿ãã£ãŠããŸããâŠã
ããŒã®é çœ®ç¶æ³ã¯ããredis-cli --cluster infoãã§èŠãããã§ããã
172.17.0.2:6379 (fbf478e6...) -> 3 keys | 5461 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 2 keys | 5462 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 1 keys | 5461 slots | 0 slaves. [OK] 6 keys in 3 masters. 0.00 keys per slot on average.
ããŒãã远å ãã
ä»åºŠã¯ãå°ãæ¹åãå€ããŠãããŒãã远å ããŠã¿ãŸããããä»ã®ã¯ã©ã¹ã¿ã«ã172.17.0.5ãšããIPã¢ãã¬ã¹ãæã€ããŒãã
远å ããŠã¿ãŸãã
ãŸãã¯ãRedisãèµ·åã
## 172.17.0.4 $ bin/redis-server conf/redis.conf
ããŒãã远å ããã«ã¯ããredis-cli --cluster add-nodeãã䜿çšããŸãã第1åŒæ°ã¯æ°ããããŒãã第2åŒæ°ã¯æ¢åã®ããŒãã§ãã
$ bin/redis-cli --cluster add-node 172.17.0.5:6379 172.17.0.2:6379 >>> Adding node 172.17.0.5:6379 to cluster 172.17.0.2:6379 >>> Performing Cluster Check (using node 172.17.0.2:6379) M: fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379 slots:[0-5460] (5461 slots) master M: 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379 slots:[5461-10922] (5462 slots) master M: a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379 slots:[10923-16383] (5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 172.17.0.5:6379 to make it join the cluster. [OK] New node added correctly.
ããŒãã远å ãããŸããâŠãã¹ããããå²ãåœãŠãããŠããŸããã
$ bin/redis-cli --cluster info 172.17.0.2:6379 172.17.0.2:6379 (fbf478e6...) -> 3 keys | 5461 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 2 keys | 5462 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 1 keys | 5461 slots | 0 slaves. 172.17.0.5:6379 (7a796a7f...) -> 0 keys | 0 slots | 0 slaves. [OK] 6 keys in 4 masters. 0.00 keys per slot on average.
ãã®ç¶æ ã§ããã¯ã©ã€ã¢ã³ãããã®ãªã¯ãšã¹ãã«ã¯å¿ããããšãã§ããã¿ããã§ããã
$ bin/redis-cli -h 172.17.0.5 -p 6379 -c 172.17.0.5:6379> get key1 -> Redirected to slot [9189] located at 172.17.0.3:6379 "value1"
ã§ã¯ããªã·ã£ãŒãããŸãããããredis-cli --cluster reshardãã§å®è¡ããŸãã
$ bin/redis-cli --cluster reshard 172.17.0.2:6379 >>> Performing Cluster Check (using node 172.17.0.2:6379) M: fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379 slots:[0-5460] (5461 slots) master M: 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379 slots:[5461-10922] (5462 slots) master M: a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379 slots:[10923-16383] (5461 slots) master M: 7a796a7fb7c4e61699717acaa7d39ec8cb130581 172.17.0.5:6379 slots: (0 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. How many slots do you want to move (from 1 to 16384)?
ã¹ãããïŒ1ã16384ïŒã®ç¯å²ãã©ãåããã®ãèãããã®ã§ãä»å㯠16384 / 4ã§4096ã§ãããŸãã
How many slots do you want to move (from 1 to 16384)? 4096
ããŒã¿ãåãåãããŒãã«ã€ããŠèãããã®ã§ãä»å远å ããããŒãã®IDãæå®ããŸãã
What is the receiving node ID? 7a796a7fb7c4e61699717acaa7d39ec8cb130581
IDã¯ããredis-cli cluster nodesããªã©ã§ç¢ºèªããŠãããã§ããããªã·ã£ãŒãã®å®è¡æã«ã衚瀺ãããŠããŸããã
IDãæå®ãããšãã©ã®ããŒãããããŒã¿ãåãããèãããã®ã§âŠä»åã¯ãallããéžãã§å šããŒãããåããããã«ããŸãã
Please enter all the source node IDs. Type 'all' to use all the nodes as source nodes for the hash slots. Type 'done' once you entered all the source nodes IDs. Source node #1: all
ãããšããªã·ã£ãŒãã®ãã©ã³ã«ã€ããŠã®ç¢ºèªãæ±ããããã®ã§
Ready to move 4096 slots. Source nodes: M: fbf478e684be17192c16a550bb4b85fa177262c2 172.17.0.2:6379 slots:[0-5460] (5461 slots) master M: 33a5bbdb99f768cfd320867ed31292ab3107a26e 172.17.0.3:6379 slots:[5461-10922] (5462 slots) master M: a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 172.17.0.4:6379 slots:[10923-16383] (5461 slots) master Destination node: M: 7a796a7fb7c4e61699717acaa7d39ec8cb130581 172.17.0.5:6379 slots: (0 slots) master Resharding plan: Moving slot 5461 from 33a5bbdb99f768cfd320867ed31292ab3107a26e Moving slot 5462 from 33a5bbdb99f768cfd320867ed31292ab3107a26e Moving slot 5463 from 33a5bbdb99f768cfd320867ed31292ab3107a26e Moving slot 5464 from 33a5bbdb99f768cfd320867ed31292ab3107a26e Moving slot 5465 from 33a5bbdb99f768cfd320867ed31292ab3107a26e ... Moving slot 12285 from a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 Moving slot 12286 from a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 Moving slot 12287 from a2ee1afd473c5a04ae88fdd84da4cc86e4aa1f26 Do you want to proceed with the proposed reshard plan (yes/no)?
ãyesããšåçã
Do you want to proceed with the proposed reshard plan (yes/no)? yes
ããŒã¿ã®ç§»åãå§ãŸããŸãã
Moving slot 5461 from 172.17.0.3:6379 to 172.17.0.5:6379: Moving slot 5462 from 172.17.0.3:6379 to 172.17.0.5:6379: Moving slot 5463 from 172.17.0.3:6379 to 172.17.0.5:6379: Moving slot 5464 from 172.17.0.3:6379 to 172.17.0.5:6379: Moving slot 5465 from 172.17.0.3:6379 to 172.17.0.5:6379: ...
å®äºãåããŒãã4096ã¹ããããã€å²ãåœãŠãããããã«ããªã·ã£ãŒãã§ããŸããããšã
$ bin/redis-cli --cluster info 172.17.0.2:6379 172.17.0.2:6379 (fbf478e6...) -> 2 keys | 4096 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 2 keys | 4096 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 1 keys | 4096 slots | 0 slaves. 172.17.0.5:6379 (7a796a7f...) -> 1 keys | 4096 slots | 0 slaves. [OK] 6 keys in 4 masters. 0.00 keys per slot on average.
確èªããŠã¿ãŸãããã
$ bin/redis-cli -h 172.17.0.2 -p 6379 -c 172.17.0.2:6379> set key7 value7 -> Redirected to slot [803] located at 172.17.0.5:6379 OK
远å ããããŒãã«ããããŒã¿ãç»é²ã§ããŸããã
ããŒããåé€ãã
æåŸã«ãããŒããåé€ããŠã¿ãŸããå ã»ã©è¿œå ããããŒãããã¯ã©ã¹ã¿ããåé€ããŠã¿ãŸãããã
ããŒãã®åé€ã¯ããredis-cli --cluster del-nodeãã§è¡ããŸãã察象ã®ããŒãã®IPã¢ãã¬ã¹ãããŒããããŒãã®IDãå¿ èŠã§ãã
$ bin/redis-cli --cluster del-node 172.17.0.5:6379 7a796a7fb7c4e61699717acaa7d39ec8cb130581
ã§ããããããå®è¡ãããšãã¹ããããå²ãåœãŠãããŠããããããšã©ãŒã«ãªããŸãã
bin/redis-cli --cluster del-node 172.17.0.5:6379 7a796a7fb7c4e61699717acaa7d39ec8cb130581 >>> Removing node 7a796a7fb7c4e61699717acaa7d39ec8cb130581 from cluster 172.17.0.5:6379 [ERR] Node 172.17.0.5:6379 is not empty! Reshard data away and try again.
ã§ã¯ããªã·ã£ãŒãããŸããããâŠã
$ bin/redis-cli --cluster reshard 172.17.0.2:6379 >>> Performing Cluster Check (using node 172.17.0.2:6379) M: d452b0232e6acb296deb78b09e6bc244f81f0ac7 172.17.0.2:6379 slots:[1365-5460] (4096 slots) master M: f97cb7a053f25161a2367a7ed6c107d2d6129065 172.17.0.4:6379 slots:[12288-16383] (4096 slots) master M: 6bf112f4d510a5273f89cb6c99e261df492800c0 172.17.0.5:6379 slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master M: 2a166ae9825e03447f6d6d664f6c5e7d425bb11a 172.17.0.3:6379 slots:[6827-10922] (4096 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
ç§»åããã¹ãããã¯ãåé€ããããŒããæã£ãŠããæ°ãªã®ã§ã4096ã
How many slots do you want to move (from 1 to 16384)? 4096
ããŒã¿ãåãåãããŒãã¯ãã¯ã©ã¹ã¿ã«æ®ãããŒããéžã³
What is the receiving node ID? fbf478e684be17192c16a550bb4b85fa177262c2
ç§»åå ãšãªãããŒãã¯ãåé€å¯Ÿè±¡ãšããããŒããéžã³ãŸãã
Please enter all the source node IDs. Type 'all' to use all the nodes as source nodes for the hash slots. Type 'done' once you entered all the source nodes IDs. Source node #1: 7a796a7fb7c4e61699717acaa7d39ec8cb130581
2ã€ç®ä»¥éã«ããŒã¿ã®ç§»åå ãšãªãããŒãã¯ãªãã®ã§ããdoneãã
Source node #2: done
ãªã·ã£ãŒãã®ãã©ã³ã衚瀺ãããã®ã§ãåé¡ããªããã°ãyesãã
Do you want to proceed with the proposed reshard plan (yes/no)? yes
ä»åºŠã¯ãããŒããåé€ã§ããŸãïŒã¹ãããã®é çœ®ç¶æ³ã確èªããã®å¿ããâŠïŒã
$ bin/redis-cli --cluster del-node 172.17.0.5:6379 7a796a7fb7c4e61699717acaa7d39ec8cb130581 >>> Removing node 7a796a7fb7c4e61699717acaa7d39ec8cb130581 from cluster 172.17.0.5:6379 >>> Sending CLUSTER FORGET messages to the cluster... >>> SHUTDOWN the node.
ãããŠãåé€ããããŒãã¯ã·ã£ããããŠã³ããŸãâŠã
9:M 25 Nov 2018 14:38:54.822 # User requested shutdown... 9:M 25 Nov 2018 14:38:54.822 * Calling fsync() on the AOF file. 9:M 25 Nov 2018 14:38:54.827 # Redis is now ready to exit, bye bye...
ã¯ã©ã¹ã¿ãããããŒããããªããªããŸãããã
$ bin/redis-cli --cluster info 172.17.0.2:6379 172.17.0.2:6379 (fbf478e6...) -> 4 keys | 8192 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 2 keys | 4096 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 1 keys | 4096 slots | 0 slaves. [OK] 7 keys in 3 masters. 0.00 keys per slot on average.
åé€ããããŒããæã£ãŠããããŒã¿ããååŸå¯èœã§ãã
$ bin/redis-cli -h 172.17.0.2 -p 6379 -c 172.17.0.2:6379> get key7 "value7"
ãšããã§ãã¹ãããã®é åãèŠããšããã®ããããã©ã³ã¹ãæªãã§ãâŠã
$ bin/redis-cli --cluster info 172.17.0.2:6379 172.17.0.2:6379 (fbf478e6...) -> 4 keys | 8192 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 2 keys | 4096 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 1 keys | 4096 slots | 0 slaves. [OK] 7 keys in 3 masters. 0.00 keys per slot on average.
ãªãã©ã³ã¹ããŸãããã
$ bin/redis-cli --cluster rebalance 172.17.0.2:6379 >>> Performing Cluster Check (using node 172.17.0.2:6379) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Rebalancing across 3 nodes. Total weight = 3.00 Moving 1366 slots from 172.17.0.2:6379 to 172.17.0.3:6379 ###################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### Moving 1365 slots from 172.17.0.2:6379 to 172.17.0.4:6379 #####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
ã¹ãããã®ãªãã©ã³ã¹ãå®äºãã§ãã
$ bin/redis-cli --cluster info 172.17.0.2:6379 172.17.0.2:6379 (fbf478e6...) -> 2 keys | 5461 slots | 0 slaves. 172.17.0.3:6379 (33a5bbdb...) -> 4 keys | 5462 slots | 0 slaves. 172.17.0.4:6379 (a2ee1afd...) -> 1 keys | 5461 slots | 0 slaves. [OK] 7 keys in 3 masters. 0.00 keys per slot on average.
ãŸãšã
Redis 5.0ã§ãã¯ã©ã¹ã¿ãæ§æããããæäœãããã€ããã£ãŠã¿ãŸããã
ä»åã¯æåã§ããŒããåé€ãããããŸããããããããæé ãä»ããã«ããŒãã忢ãããããªã±ãŒã¹ãªã©ã
ã©ããã§ãŸã詊ããŠã¿ããïŒããïŒ