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

Building redis Cluster with redis-trib.rb

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Building clusters with redis-trib.rb [common methods]

Redis-trib.rb is a redis cluster management tool implemented by Ruby.

Internal Cluster related commands are used to simplify common operation and maintenance operations such as cluster creation, inspection, slot Joy and equalization.

Ruby dependent environment needs to be installed before use

1 、 Ruby environment prepares https://cache.ruby-lang.org/pub/ruby/2.3/ [download URL]-- download ruby- cd / soft/toolswget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.gz-- install ruby- tar zxf ruby-2.3.4.tar.gzcd ruby-2.3.4./configure-- prefix=/soft/ruby-2.3. 4makemake installln-s / soft/ruby-2.3.4 / soft/rubycd / soft/rubycp bin/ruby / usr/local/bin/cp bin/gem / usr/local/bin/ [root@lbl ruby] # ll / usr/local/bin/ {ruby Gem}-rwxr-xr-x. 1 root root 548 Apr 21 00:42 / usr/local/bin/gem-rwxr-xr-x. 1 root root 22306743 Apr 21 00:42 / usr/local/bin/ruby-- install rubygem redis dependency-wget http://rubygems.org/downloads/redis-3.3.0.gemgem install-l redis-3.3.0.gemgem list-- check redis gem-- install redis-rb management tools-[root@test ruby] # cp / soft/tools/redis-3.2.0/src/redis-trib.rb / usr/local/bin/ [ Root@test ruby] # ll / usr/local/bin/ {ruby Gem,*.rb}-rwxr-xr-x. 1 root root 548 Apr 16 10:05 / usr/local/bin/gem-rwxr-xr-x. 1 root root 60578 Apr 16 10:07 / usr/local/bin/redis-trib.rb-rwxr-xr-x. 1 root root 22306727 Apr 16 10:05 / usr/local/bin/ruby2, standby node-master node redis-server / soft/redis/cluster/7000/redis.conf & redis-server / soft/redis/cluster/7100/redis.conf & redis-server / soft/redis/cluster/7200/redis.conf &-slave node redis-server / soft/redis/cluster/7001/redis.conf & redis-server / soft/redis/cluster/7101/redis.conf & redis-server / soft/redis/cluster/7201/redis.conf & 3, Create a cluster

After starting the 6 nodes, use the redis-trib.rb create command to complete the node handshake and slot allocation process:

Note: when the master and slave nodes are specified, the first three master nodes and the last three corresponding slave nodes

[root@test cluster] # redis-trib.rb create-- replicas 1127.0.0.1: 7000127.0.0.1 Performing hash slots allocation on 7001127.0.0.1 masters:127.0.0.1:7000127.0.0.1:7001127.0.0.1:7100Adding replica 7100 127.0.0.1 : 7101 to 127.0.0.1:7000Adding replica 127.0.0.1 to 7200 to 127.0.0.1:7001Adding replica 127.0.0.1 085d2851ef195428786f7df14a2c00fedb6ccec9 7300 to 127.0.0.1 masterS 7100m: b70ce6df43039cd8ef2004a031851668dfe51982 127.0.0.1 slots:0-5460 (5461 slots) masterM: 3300b8f899d7f369d7095025954f2069857801c0 127.0.0.1 masterM 7001 slots:5461-10922 (5462 slots) 085d2851ef195428786f7df14a2c00fedb6ccec9 127.0.0.1 085d2851ef195428786f7df14a2c00fedb6ccec9 7100 slots:10923-16383 (5461 slots) masterS: 97cf943c9fac35520fdd9426e344f7b7cc390fb8 127.0.0.1:7101 replicates b70ce6df43039cd8ef2004a031851668dfe51982S: e2fae64bbac1fc28d66c4cb21c5be95be4ba8953 127.0.0.1:7200 replicates 3300b8f899d7f369d7095025954f2069857801c0S: 5207520b05fd05240a56d132bf90fa4e9dde97cb 127.0.0.1:7300 replicates 085d2851ef195428786f7df14a2c00fedb6ccec9Can 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 127.0.0.1VL 7000) M: b70ce6df43039cd8ef2004a031851668dfe51982 127.0.0.1VL 7000 slots:0-5460 (5461 slots) masterM: 3300b8f899d7f369d7095025954f2069857801c0 127.0.0.1 Rod 7001 slots:5461-10922 (5462slots) masterM: 085d2851ef195428786f7df14a2c00fedb6ccec9 127.0.0.1RU 7100 slots:10923-16383 (5461slots) MasterM: 97cf943c9fac35520fdd9426e344f7b7cc390fb8 127.0.0.1 slots 7101 slots: (0 slots) master replicates b70ce6df43039cd8ef2004a031851668dfe51982M: e2fae64bbac1fc28d66c4cb21c5be95be4ba8953 127.0.0.1 slots 7200 slots: (0 slots) master replicates 3300b8f899d7f369d7095025954f2069857801c0M: 5207520b05fd05240a56d132bf90fa4e9dde97cb 127.0.1 slots: (0 slots) master replicates 085d2851ef195428786f7df14a2c00fedb6ccec9 [OK] All nodes agree about slots configuration. > > Check for open slots... > > Check slots coverage... [OK] All 16384 slots covered.4, Cluster integrity check

Cluster integrity means that all slots are assigned to the surviving primary node, and as long as one of the 16384 slots is not allocated to the node, the cluster is incomplete.

You can use the redis-trib.rb check command to check whether the two previously created clusters are successful. The check command only needs to give the address of any node in the cluster to check the entire cluster.

-- the command is as follows:-- redis-trib.rb check 127.0.0.1:7000redis-trib.rb check 127.0.0.1purl 7100tel-outputs the following information It is suggested that all slots in the cluster have been assigned to nodes-- [root@test cluster] # redis-trib.rb check 127.0.0.1Performing Cluster Check 7000 > Performing Cluster Check (using node 127.0.0.1VR 7000) M: b70ce6df43039cd8ef2004a031851668dfe51982 127.0.0.1 master 7000 slots:0-5460 (5461 slots) master 1 additional replica (s) S: e2fae64bbac1fc28d66c4cb21c5be95be4ba8953 127.0.0.1 slots 7200 slots: (0 slots) slave replicates 3300b8f899d7f369d7095025954f2069857801c0S: 97cf943c9fac35520fdd9426e344f7b7cc390fb8 127.0.0.1: 7101 slots: (0 slots) slave replicates b70ce6df43039cd8ef2004a031851668dfe51982M: 085d2851ef195428786f7df14a2c00fedb6ccec9 127.0.0.1 slots:10923 7100 slots:10923-16383 (5461 slots) master 1 additional replica (s) S: 5207520b05fd05240a56d132bf90fa4e9dde97cb 127.0.1 slave replicates 085d2851ef195428786f7df14a2c00fedb6ccec9M 7300 slots: (0 slots) slave replicates 085d2851ef195428786f7df14a2c00fedb6ccec9M: 3300b8f899d7f369d7095025954f2069857801c0 127.0.0.1 slave replicates 085d2851ef195428786f7df14a2c00fedb6ccec9M 7001 slots:5461-10922 (5462 slots) master 1 additional replica (s) [OK] All nodes agree about slots configuration. > Check for open slots... > > Check slots coverage... [OK] All 16384 slots covered.5 Summary 1. The main steps to establish a cluster are as follows: ① prepares node ② node handshake [meet command, is an asynchronous command] ③ allocation slot [cluster addslots {number_start..number_end}] 2. Redis cluster requires at least 6 nodes, 3 master nodes + 3 slave nodes. The master-slave node must be a replication relationship [cluster replicate master ID command to establish a replication relationship] 4. The node handshake protocol communicates with Gossip protocol, establishes handshake relationship through meet command, and maintains normal communication through ping/pong command. Nodes added to the cluster cannot perform any read and write operations without allocation slots

Related links:

Manually build a redis cluster

Redis cluster [error summary]

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

Servers

Wechat

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

12
Report