In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Redis is still quite fun. Today, we tested the addition of clusters, deletion of nodes, reassignment of slot, and so on. More in-depth understanding of the rules of the redis game. There are many steps, but they are detailed.
Environmental explanation:
I tested it on a Centos 6.9, and each redis node was distinguished by port number. For each redis in this article, I am only represented by the port number.
The Node~172.16.32.116:9000172.16.32.116:9001 that Master Node~172.16.32.116:7000172.16.32.116:7001172.16.32.116:7002~~~~Slave Node~172.16.32.116:8000172.16.32.116:8001172.16.32.116:8002~~~~ uses to toss about.
1. Create a redis cluster
Note: for more redis cluster creation, see
Redis Cluster cluster deployment build
#. / redis-trib.rb create-- replicas 1172.16.32.116: 7000172.16.32.116redis-trib.rb create 7001172.16.32.116redis-trib.rb create 7002 172.16.32.116redis-trib.rb create 8000 172.16.32.116Creating cluster > Performing hash slots allocation on 6 nodes...Using 3 masters:172.16.32.116:7000172.16.32.116:7001172.16.32.116:7002Adding replica 172.16.32.116 16000 to 172.16.32.116:7000Adding replica 172.16.32.116slots:0 8001 to 172.16.32.116:7001Adding replica 172.16.32.116a0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.116V 7002M: a0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.116V 7000 slots:0-5460 (5461 slots) masterM: 273107e5ac994d675749be0979556e761274bb93 172.16.32.116V 7001 slots:5461-10922 (5462 slots) masterM: 88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116purl 7002 slots:10923-16383 (5461 slots) masterS: aeb684429d220c0fd1392574d193cc1ae7577782 172.16 . 32.116:8000 replicates a0b91f48e933c1f1d427c54917ce970bd25d29f8S: a96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116:8001 replicates 273107e5ac994d675749be0979556e761274bb93S: 3d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116:8002 replicates 88fe075375295b59eabe69fa1438ed7c7c314f43Can 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 clusterWaiting for the cluster to join... > > Performing Cluster Check (using node 172.16.32.116 masterM 7000 slots:0-5460 (5461 slots) masterM: 273107e5ac994d675749be0979556e761274bb93 172.16.32.116 masterM 7001 slots:5461-10922 (5462slots) masterM: 88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116Nodes configuration updated 7002 slots:10923-16383 (5461 slots) MasterM: aeb684429d220c0fd1392574d193cc1ae7577782 172.16.32.116 master replicates a0b91f48e933c1f1d427c54917ce970bd25d29f8M 8000 slots: (0 slots) master replicates a0b91f48e933c1f1d427c54917ce970bd25d29f8M: a96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116 masterM 8001 slots: (0 slots) master replicates 273107e5ac994d675749be0979556e761274bb93M: 3d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116 slots 8002 slots: (0 slots) master replicates 88fe075375295b59eabe69fa1438ed7c7c314f43 [OK] All nodes agree about slots configuration. > > Check for open slots... > Check slots coverage... [OK] All 16384slots covered.
two。 Check cluster status
#. / redis-trib.rb check 172.16.32.116master 7000 > Performing Cluster Check (using node 172.16.32.116a0b91f48e933c1f1d427c54917ce970bd25d29f8 7000) slots:0-5460 (5461 slots) master 1 additional replica (s) M: 88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116a0b91f48e933c1f1d427c54917ce970bd25d29f8 7002 slots:10923-16383 (5461 slots) master 1 additional replica (s) M: 273107e5ac994d675749be0979556e761274bb93 172.16.32.116a0b91f48e933c1f1d427c54917ce970bd25d29f8 7001 slots:5461-10922 (5462 slots) master 1 Additional replica (s) S: 3d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116 slots 8002 slots: (0 slots) slave replicates 88fe075375295b59eabe69fa1438ed7c7c314f43S: a96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116 slave replicates 88fe075375295b59eabe69fa1438ed7c7c314f43S 8001 slots: (0 slots) slave replicates 273107e5ac994d675749be0979556e761274bb93S: aeb684429d220c0fd1392574d193cc1ae7577782 172.16.32.116 slots 8000 slots: (0 slots) slave replicates a0b91f48e933c1f1d427c54917ce970bd25d29f8 [OK] All nodes agree about slots configuration. > > Check for open slots... > > Check slots coverage... [OK] All 16384 slots covered.
~ ~ add nodes ~ ~
3. Add new node redis-trib.rb add-node add node name original cluster node name
#. / redis-trib.rb add-node 172.16.32.116Performing Cluster Check 9000 172.16.32.116V 7000 > Adding node 172.16.32.116V 9000 to cluster 172.16.32.116V 7000 > Performing Cluster Check (using node 172.16.32.116V 7000) M: a0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.1167000 slots:0-5460 (5461 slots) master 1 additional replica (s) M: 88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116V 7002 slots:10923-16383 (5461 slots) Master 1 additional replica (s) M: 273107e5ac994d675749be0979556e761274bb93 172.16.32.116master 7001 slots:5461-10922 (5462 slots) master 1 additional replica (s) S: 3d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116slots:5461 8002 slots: (0 slots) slave replicates 88fe075375295b59eabe69fa1438ed7c7c314f43S: a96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116a96cad95dca2a8e1e0302bff4f835260d92e3d31 8001 slots: (0 slots) slave replicates 273107e5ac994d675749be0979556e761274bb93S: aeb684429d220c0fd1392574d193cc1ae7577782 172.16.32.116mer 8000 slots: (0 slots) slave replicates a0b91f48e933c1f1d427c54917ce970bd25d29f8 [OK] All nodes agree about slots configuration. > > Check For open slots... > > Check slots coverage...
4. Check the current cluster status. 9000 is an empty Master.
#. / redis-cli-p 9000 cluster nodesa0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.1167000 master-01505321254767 1 connected 0-5460273107e5ac994d675749be0979556e761274bb93 172.16.32.116Vol 7001 master-01505321250759 2 connected 5461-1092288fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116redis-cli 7002 master-01505321251761 3 connected 10923-163833d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116purl 8002 slave 88fe075375295b59eabe69fa1438ed7c7c314f43 01505321255769 3 connectedaeb684429d220c0fd1392574d193cc1ae7577782 172.16.32.116hand8000 slave a0b91f48e933c1f1d427c54917ce970bd25d29f8 01505321253765 1 connecteda96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116Rich 8001 slave 273107e5ac994d675749be0979556e761274bb93 01505321256771 2 connected
5. Assign slot to 9000. The solt of redis is fixed, that is, 16384. Only slot can be obtained from other nodes, and then assigned to 9000.
#. / redis-trib.rb reshard 172.16.32.116master 9000 > > Performing Cluster Check (using node 172.16.32.116364ae8322ab2627e25b05d45b702448c74afad10 9000) slots: (0 slots) master 0 additional replica (s) M: a0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.1167000 slots:0-5460 (5461 slots) master 1 additional replica (s) M: 273107e5ac994d675749be0979556e761274bb93 172.16.32.116D 7001 slots:5461-10922 (5462 slots) master 1 additional replica (s) S: 3d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116 master 8002 slots: (0 slots) slave replicates 88fe075375295b59eabe69fa1438ed7c7c314f43S: aeb684429d220c0fd1392574d193cc1ae7577782 172.16.32.116 aeb684429d220c0fd1392574d193cc1ae7577782 8000 slots: (0 slots) slave replicates a0b91f48e933c1f1d427c54917ce970bd25d29f8M: 88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116 master 7002 slots:10923-16383 (5461 slots) master 1 additional replica (s) S: a96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116001 slots: (0 slots) slave replicates 273107e5ac994d675749be0979556e761274bb93 [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)? What is the receiving node ID? 364ae8322ab2627e25b05d45b702448c74afad10 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 300 slots. Source nodes: M: a0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.116slots 7000 slots:0-5460 (5461 slots) master 1 additional replica (s) M: 273107e5ac994d675749be0979556e761274bb93 172.16.32.116Source nodes 7001 slots:5461-10922 (5462 slots) master 1 additional replica (s) M: 88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116slots 7002 slots:10923-16383 (5461 slots) master 1 additional replica (s) Destination node: M: 364ae8322ab2627e25b05d45b702448c74afad10 172.16.32.116 additional replica 9000 slots: (0 slots) master 0 additional replica (s) Resharding plan: Moving slot 5461 from 273107e5ac994d675749be0979556e761274bb93 Moving slot 5469 from 273107e5ac994d675749be0979556e761274bb93Do you want to proceed with the proposed reshard plan (yes/no)? YesMoving slot 5461 from 172.16.32.116:7001 to 172.16.32.116:9000:
6. As you can see, the slot assigned to 9000 is 0-98 5461-5561 10923-11021
#. / redis-cli-p 9000 cluster nodesa0b91f48e933c1f1d427c54917ce970bd25d29f8 172.16.32.116master-01505324905062 1 connected 99-5460273107e5ac994d675749be0979556e761274bb93 172.16.32.116redis-cli 7001 master-015053249100752 connected 5562-10922364ae8322ab2627e25b05d45b702448c74afad10 172.16.32.1169000 myself Master-00 7 connected 0-98 5461-5561 10923-110213d27f60a1cc4d9c8f09aca928b03f0e083722d3b 172.16.32.116 slave 88fe075375295b59eabe69fa1438ed7c7c314f43 8002 slave 88fe075375295b59eabe69fa1438ed7c7c314f43 01505324908070 3 connectedaeb684429d220c0fd1392574d193cc1ae7577782 172.16.32.116 slave a0b91f48e933c1f1d427c54917ce970bd25d29f8 01505324911077 1 connected88fe075375295b59eabe69fa1438ed7c7c314f43 172.16.32.116V 7002 master-01505324902057 3 connected 11022-16383a96cad95dca2a8e1e0302bff4f835260d92e3d31 172.16.32.116 slave 273107e5ac994d675749be0979556e761274bb93 01505324909073 2 connected
~ change 9000 to slave~~
7. You want to change 9000 to 7000 slave, but due to slot, the execution failed, so you need to transfer slot first.
# redis-cli-c-p 9000 cluster replicate a0b91f48e933c1f1d427c54917ce970bd25d29f8 (error) ERR To set a master the node must be empty and without assigned slots.
8. It is also not possible to delete a node, in short, as long as there is a slot on it. Redis won't let you delete it, and you need human intervention to rebalance these slot.
#. / redis-trib.rb del-node 172.16.32.116ERR 9000 364ae8322ab2627e25b05d45b702448c74afad10 > Removing node 364ae8322ab2627e25b05d45b702448c74afad10 from cluster 172.16.32.116ERR 9000 [ERR] Node 172.16.32.116ERR 9000 is not empty! Reshard data away and try again.
9. Reassign 9000 of slot to 7000
#. / redis-trib.rb reshard 172.16.32.116 Check slots coverage... 9000 Check for open slots... > Check slots coverage... [OK] All 16384 slots covered.How many slots do you want to move (from 1 to 16384)? 300
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.