Building redis cluster in windows Environment

redis used in the project is a cluster deployed in the windows server environment. Because the development environment and test environment are deployed and used by other colleagues, but there are often problems that affect business services, so I made some suggestions in the previous stage Brief introduction to Redis principle, cluster construction and integrated use of springboot Based on the summary of learning and practice, a set of redis cluster under windows server is built separately to verify relevant problems, and a summary record is made here, so as to facilitate subsequent continuous learning and research and provide reference for latecomers. There are some omissions in this paper. I hope readers can correct them. Thank you very much!

1. Installation environment and installation package download

To install redis cluster under windows system, four components are required:
Redis, ruby running environment, redis's Ruby driver redis-xxxx.gem, and redis-trib.rb, a tool for creating redis clusters
Use the redis-trib.rb tool to create a Redis cluster. Since the file is written in Ruby language, you need to install the ruby development environment and drive redis-xxxx.gem.

Redis only has the official Linux version and does not support the Windows version. Windows can only download the lower version in github. Because redis is single threaded and high-performance, redis needs single thread polling. The polling mechanism of the operating system is different. In short, epoll is used for Linux polling and selector is used for windows, but the performance of epoll is higher than that of selector. Therefore, redis recommends using the Linux version, while the Windows version of redis has been modified by the folk God

1.1 installation environment version

Windows Environmental Science: Windows Server 2019 Standard
Redis edition: Redis-x64-4.0.14.1
Ruby edition: rubyinstaller-2.6.8-1-x64
RubyGems edition: rubygems-3.2.28
GemsRedis edition: redis-4.1.3.gem

1.2 installation package download

  1. Download redis

Download the Windows version of redis. Note: only redis versions after 3.0 have clusters

https://github.com/tporadowski/redis/releases


3. Download ruby

https://rubyinstaller.org/downloads/

  1. Download rubygems
https://rubygems.org/pages/download

  1. Download redis.gem
https://rubygems.org/gems/redis/versions/


6. Download redis-trib.rb

https://github.com/microsoftarchive/redis/tree/3.2/src

redis-trib.rb Is adopted Ruby Realized Redis Cluster management tools. Internal pass Cluster Relevant commands help us simplify common operation and maintenance operations such as cluster creation, inspection, slot migration and balancing. It needs to be installed before use Ruby Dependent environment.
redis 3.0 The above cluster mode is through redis Under the installation directory redis-trib.rb Script construction.

The download method is sent from Microsoft project team 3.2 Version, get redis-trib.rb File script

2. Cluster deployment steps

2.1 overall process

install ruby -- install rubygems -- install gem-redis -- Configure and start each redis node -- Create cluster -- Cluster validation

2.2 detailed process

  1. Install ruby
rubyinstaller.exe

  1. Install ruby driver rubygems for redis
get into rubygems Unzip the package file:

ruby setup.rb

  1. gem installs redis
get into redis Unzip package execution path:

gem install redis-4.1.3.gem

  1. Modify the configuration file redis.windows.conf and start redis of each node
#bind 127.0.0.1
protected-mode no
port 7001
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 15000
appendonly yes
  1. Start redis command bat script
title redis-port
redis-server.exe redis.windows.conf
  1. Install cluster script
Execute command:

ruby redis-trib.rb create --replicas 1 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384 127.0.0.1:6385

Of which:–replicas 1 Represents creating a slave node for each master node in the cluster
 Note: 127.0.0.1 Replace with that of the corresponding server ip Address. Otherwise, even if the cluster is started successfully, an error will be reported when other servers connect to modify the address.

  1. The redis client executes commands to view cluster information
Client connect to redis Node:

redis-cli.exe -c -p 6380

Of which:-c Indicates cluster mode,-h express ip Address,-p Represents the port

To view cluster information:
cluster info

To view cluster node information:
cluster nodes


3. References

[1] https://blog.csdn.net/qq_39086296/article/details/90699622
[2] https://blog.csdn.net/fangyuandoit/article/details/102565287

Tags: Redis Windows Ruby

Posted by jawa on Fri, 01 Oct 2021 07:07:36 +0530