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

New nodes (master, slave) in Redis cluster (experiment)

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

Share

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

Add the configuration file for the master node:

# vim / usr/local/redis-3.0.6-6379/redis.conf

Daemonize yes / / enable background operation

Pidfile / var/run/redis_6379.pid / / pid file

Port 6379 / / Port

Bind 192.168.2.100 / / defaults to 127.0.0.1, which needs to be changed to an address accessible to other nodes

Logfile "/ usr/local/redis-3.0.6-6379/redis_6379.log" / / log file path

Dir / usr/local/redis-3.0.6-6379 / RDB file path

Appendonly yes / / enable AOF persistence

Cluster-enabled yes / / start the cluster

Cluster-config-file nodes-6379.conf / / Cluster configuration file

Cluster-node-timeout 15000 / / request timed out. Default is 15 seconds.

Start the new master node:

# redis-server redis.conf

Install the ruby environment: (redis-trib.rb command, which needs to be executed in the ruby environment)

# yum-y install ruby ruby-devel rubygems rpm-build

# gem install redis

Successfully installed redis-3.2.1

Parsing documentation for redis-3.2.1

1 gem installed

Errors that may be encountered:

ERROR: Could not find a valid gem 'redis' (> = 0), here is why:

Unable to download data from https://rubygems.org/-no such name (https://rubygems.org/latest_specs.4.8.gz)

Download manually: https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem

Execute: # gem install-l. / redis-3.2.1.gem

Add the master node to the cluster:

# redis-trib.rb add-node 192.168.2.202:6379 192.168.2.100:6379

/ / the first new ip:port node

Any node in the second ip:port cluster

View the information of all nodes in the cluster: (you can see that the new node has joined the cluster, but no hash slot has been assigned)

# redis-trib.rb check 192.168.2.202:6379

> Performing Cluster Check (using node 192.168.2.202)

M: 8326ff0be199fa0d4db74f0ebcc58f27e65991b4 192.168.2.202:6379

Slots: (0 slots) master

0 additional replica (s)

......

Assign slot to the new master node:

# redis-trib.rb reshard 192.168.2.202:6379

> Performing Cluster Check (using node 192.168.2.202)

M: 8326ff0be199fa0d4db74f0ebcc58f27e65991b4 192.168.2.202:6379

Slots: (0 slots) master

0 additional replica (s)

......

[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)? 1000

/ / how many hash slot do you want to move? (assigned to new node)

What is the receiving node ID? 8326ff0be199fa0d4db74f0ebcc58f27e65991b4

/ / what is the accepted node ID? (ID of Singapore node)

Please enter all the source node IDs.

Type 'all' to use all the nodes as source nodes for the hash slots.

/ / if moving from all nodes, enter all

Type 'done' once you entered all the source nodes IDs.

/ / enter the end of the specified node ID,done

Source node # 1:all

......

Do you want to proceed with the proposed reshard plan (yes/no)? Yes

/ / are you satisfied with the hash slot mobility plan?

View the information of the cluster node: (make sure that the new node hash slot is assigned correctly)

# redis-trib.rb check 192.168.2.202:6379

> Performing Cluster Check (using node 192.168.2.202)

M: 8326ff0be199fa0d4db74f0ebcc58f27e65991b4 192.168.2.202:6379

Slots:0-332 slots 5461-5794 master 10923-11255 (1000)

0 additional replica (s)

......

Start the slave node: (configuration is the same as above)

# redis-server / usr/local/redis-3.0.6-6380/redis.conf

Join the slave node to the cluster:

# redis-trib.rb add-node-- slave 192.168.2.202 6380 192.168.2.100

/ / add-- slave parameter, indicating that slave is added

The first IP is the new slave.

The second IP is any node in the node

View the cluster information: (you can see that the newly added slave belongs to the slave node of 192.168.2.202)

# redis-trib.rb check 192.168.2.100:6379

> Performing Cluster Check (using node 192.168.2.100)

M: 8326ff0be199fa0d4db74f0ebcc58f27e65991b4 192.168.2.202:6379

Slots:0-332 slots 5461-5794 master 10923-11255 (1000)

1 additional replica (s)

S: e4dc23dc67418bf66c6c63655110612cb9516aff 192.168.2.202:6380

Slots: (0 slots) slave

Replicates 8326ff0be199fa0d4db74f0ebcc58f27e65991b4

......

[OK] All nodes agree about slots configuration.

> Check for open slots...

> Check slots coverage...

[OK] All 16384 slots covered.

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