Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis5 cluster expansion-adding master and slave nodes

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Review the cluster nodes that have been built in the previous section when getting started with redis cluster cluster

B3363a81c3c59d57143cd3323481259c044e66d2 192.168.196Vera 5006 "15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 01572917132045 6 connected9dc870942555447543694e42e40061823ed91271 192.168.196VO5004" 15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 01572917130038 4 connected1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.196VOV 5003 "15003 master-01572917131041 3 connected 10923-16383b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.196Ranger 5002" 15002 master-01572917130000 2 connected 5461-10922fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.196155150015005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 01572917131000 5 connectedd1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.1961919151001 myself,master-0157291770001 connected 0-5460

Objectives of this chapter

Last time there were 6 nodes, this time 5007 focus 5008 will be added as a master-slave node to demonstrate how redis5 can be dynamically expanded.

Add two service nodes to the cluster

Redis-cli-- cluster add-node 192.168.196purl 5007 192.168.196purl 5001

Redis-cli-- cluster add-node 192.168.196purl 5008 192.168.196purl 5001

Looking at the nodes in the cluster at this time, it is found that 5007 and 5008 are all master by default.

Second, add shards for master nodes

Here, we use 192.168.196rig 5007 as the master node, and slice it.

Redis-cli-- cluster reshard 192.168.8.196pur5007

At this point, the following options appear:

How many slots do you want to move (from 1 to 16384)? 500

# fill in how many slots are allocated to 5007 here

What is the receiving node ID? 63aa476d990dfa9f5f40eeeaa0315e7f9948554d

# add the ID of the receiving node here, and fill in the ID of the 5007 service node

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

# fill in the source of the slot here, and all indicates that it is all service nodes

Here, the slicing work is completed.

Third, set the slave node

Here we use the 5008 service node as the slave node of 5007

Log in to the 5008 service node first

Redis-cli-c-h 192.168.8.196-p 5008

Specify the master node ID of the 5008 slave node, here we fill in the 5007 service node ID

Cluster replicate 63aa476d990dfa9f5f40eeeaa0315e7f9948554d

4. View the current cluster node

Cluster nodes

B3363a81c3c59d57143cd3323481259c044e66d2 192.168.196VR 5006 "15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 01573003356000 3 connected1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.196Vl500315003 master-01573003352829 3 connected 11089-16383fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.19615005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 01573003356842 2 connectedb1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.1968.196VOV 5002" 15002 master-01573003355000 2 connected 5628-10922d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.1961815 master-0 1573003354837 1 connected 1 connected 166-54609dc870942555447543694e42e40061823ed91271 192.168.196Val 500415004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573003357846 1 connected63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.196: 5007 "15007 master-01573003356000 7 connected 0165 5461-5627 10923-11088d3a9de370962873d17f1124bcf9ac166cc6ba950 192.168.196pur5008" 15008 myself Slave 63aa476d990dfa9f5f40eeeaa0315e7f9948554d 0 1573003350000 0 connected

The great task has been completed.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report