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 Environment (experiment)

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

Share

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

Environmental Information:

There are at least an odd number of primary nodes in the cluster, so at least three primary nodes

At least one backup node per node, so there are 6 nodes (3 for master and 3 for slave)

Node information: (I have 3 hosts here, each running a master and a slave)

Node 1RV 192.168.2.100RV 6379 master

Node 2RV 192.168.2.100RV 6380 slave

Node 3RV 192.168.2.200RV 6379 master

Node 4RV 192.168.2.200RV 6380 slave

Node 5VR 192.168.2.201379 master

Node 6RV 192.168.2.201201RV 6380 slave

Master and slave installation paths:

Master:/usr/local/redis-3.0.6-6379

Slave:/usr/local/redis-3.0.6-6380

Master profile:

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.

Slave profile:

Daemonize yes

Pidfile / var/run/redis_6380.pid

Port 6380

Bind 192.168.2.100

Logfile "/ usr/local/redis-3.0.6-6380/redis_6380.log"

Dir / usr/local/redis-3.0.6-638 /

Appendonly yes

Cluster-enabled yes

Cluster-config-file nodes-6380.conf

Cluster-node-timeout 15000

Start redis

# redis-server redis.conf / / 6 nodes

# ps-ef | grep redis

Root 22584 10 17:41? 00:00:00 redis-server 192.168.2.100:6379 [cluster]

Root 22599 10 17:41? 00:00:00 redis-server 192.168.2.100:6380 [cluster]

Root 22606 6650 0 17:41 pts/0 00:00:00 grep-color=auto redis

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

Create a cluster:

Copy redis-trib.rb to the / usr/local/bin directory

# cp / usr/local/redis-3.0.6-6379/src/redis-trib.rb / usr/local/bin/

# redis-trib.rb create-- replicas 1 192.168.2.100 replicas 6379 192.168.2.100 6380 192.168.2.200 192.168.2.200 6380 192.168.2.201379 192.168.2.201379 / / create a cluster

> Creating cluster

> Performing hash slots allocation on 6 nodes...

Using 3 masters:

192.168.2.100 6379 / / 3 master nodes

192.168.2.200:6379

192.168.2.201:6379

Adding replica 192.168.2.200 slave 6380 to 192.168.2.100 slave nodes

Adding replica 192.168.2.100:6380 to 192.168.2.200:6379

Adding replica 192.168.2.201:6380 to 192.168.2.201:6379

M: 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379

Slots:0-5460 (5461 slots) master / / hash slot [0-5460]

S: 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380

Replicates 5844b4272c39456b0fdf73e384ff8c479547de47

M: 5844b4272c39456b0fdf73e384ff8c479547de47 192.168.2.200:6379

Slots:5461-10922 (5462 slots) master / / hash slot [5461-10922]

S: 227f51028bbe827f27b4e40ed7a08fcc7d8df969 192.168.2.200:6380

Replicates 098e7eb756b6047fde988ab3c0b7189e1724ecf5

M: 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 192.168.2.201:6379

Slots:10923-16383 (5461 slots) master / / hash slot [10923-16383]

S: 2faf68564a70372cfc06c1afff197019cc6a39f3 192.168.2.201:6380

Replicates 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69

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 192.168.2.100)

M: 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379

Slots:0-5460 (5461 slots) master

M: 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380

Slots: (0 slots) master

Replicates 5844b4272c39456b0fdf73e384ff8c479547de47

M: 5844b4272c39456b0fdf73e384ff8c479547de47 192.168.2.200:6379

Slots:5461-10922 (5462 slots) master

M: 227f51028bbe827f27b4e40ed7a08fcc7d8df969 192.168.2.200:6380

Slots: (0 slots) master

Replicates 098e7eb756b6047fde988ab3c0b7189e1724ecf5

M: 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 192.168.2.201:6379

Slots:10923-16383 (5461 slots) master

M: 2faf68564a70372cfc06c1afff197019cc6a39f3 192.168.2.201:6380

Slots: (0 slots) master

Replicates 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69

[OK] All nodes agree about slots configuration. / / all nodes agree to slot configuration

> Check for open slots... / / start checking slot

> Check slots coverage... / / check the coverage of the slot

[OK] All 16384 slots covered. / / all slots (16384 slots) are covered (allocated)

At this point, the deployment of the redis cluster environment is complete.

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