Redis cluster building ~ redis-x64-3.2.100


Reference documents:


1. Configure redis service

Download redis-x64-3.2.100 in ZIP format, unzip it to the root directory of disk D, and then copy 6 configuration files, namely 6279 ~ 6384
Download Directory:

The contents of the main configuration file are as follows: take [redis. Windows-service6379. Conf] as an example, the other files are modified in the same way, and then the port number of 6379 is also modified to the corresponding number

Bind 192. * *. * * IP is changed to the IP corresponding to the server

Port 6379? Port number

Appendonly yes – save data in AOF format

Appendfilename “appendonly. 6379. AOF”? Data saving file

Cluster enabled yes? Enable cluster

Cluster-config-file nodes.6379.conf – cluster node configuration file

Cluster node timeout 15000 – cluster node timeout

Cluster slave validity factor 10: verify whether the slave node can perform master-slave replication 10 times

Cluster migration barrier 1 – configure data transfer

Cluster require full coverage yes

Protected mode no ා it is enabled by default and needs to be closed temporarily. Otherwise, the cluster cannot be configured at the bottom, and it can be started after the configuration is completed

After all modifications, install the service, open CMD, and switch to the redis directory,Separate executionThe following command installs the service:

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\ –service-name RedisService6379

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\ –service-name RedisService6380

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\ –service-name RedisService6381

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\ –service-name RedisService6382

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\ –service-name RedisService6383

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\ –service-name RedisService6384

After the installation is complete, open the services, you will see the following services, and then start them all

After startup, you will see that 12 files have been generated under the set persistence directory. My persistence directory is set under the data file path (default is under the root directory)


2. Install Ruby running environment

Download the ruby runtime environment file:

During installation, check the last two to automatically configure environment variables, and finally install them in this folder [ruby22-x64]


3. Download redis driver in Ruby environment

Download path: for compatibility, version 3.2.2 is downloaded here


Then copy the downloaded file: redis-3.2.2.gem to the installation directory of ruby running environment

Open CMD and switch to the installation directory of ruby running environment. My installation directory is: C: \ ruby22-x64

Then execute the command: Gem install — local C: \ ruby 22-x64 \ redis-3.2.2.gem


4. Download redis cluster tool redis-trib.rb

The download path is as follows: download and extract the file. It is recommended to put the file in the redis root directory

Open CMD, switch to the redis directory, and execute the command:

ruby redis-trib.rb create –replicas 1

Here, replicas 1, 1 represents one master corresponding to one slave, and 2 represents one master corresponding to two slave

Note: is the IP address bound in your configuration file. If the bind in your configuration file is not, the command should be changed accordingly

If you encounter the following error, please refer to the document:

The reason for my error report is that the password has been set. The solution is to comment out the password first, and then restart the password after the cluster is fully configured.

Please refer to the document:

After all roadblocks have been resolved, a successful installation of the driver:


5. Redis cluster password setting

1. If you use redis-trib.rb to build a cluster, do not configure the password before the cluster is built. After the cluster is built, set the password one by one through the config Set + config rewrite command

2. If you set the password for the cluster, you need to set both requirepass and masterauth. Otherwise, when the master-slave switch occurs, you will encounter authorization problems

3. The passwords of all nodes must be the same, or redirected will fail


6, test

If you use the client to connect to the redis cluster, you will find that there is only one database, db0, as shown in the following figure:

Reason: reference document:

1. In stand-alone mode, the default number of databases in the redis.conf configuration file is 16

2. In cluster mode, this configuration does not work. Cluster clients do not support multiple databases (DB). Only one database is SELECT 0 by default

3. The slave node of the cluster slave does not support read and write operations by default, but it can perform read operations after the readonly command is executed

Next: add a set command to port 6379

You’ll find that the other five will all be added synchronously


After the cluster is built, it is used. How to use the cluster service in the project? Please refer to the following documents:


Recommended Today

Python basics Chinese series tutorial · translation completed

Original: Python basics Python tutorial Protocol: CC by-nc-sa 4.0 Welcome anyone to participate and improve: a person can go very fast, but a group of people can go further. Online reading Apache CN learning resources catalog introduce Seven reasons to learn Python Why Python is great Learn Python introduction Executing Python scripts variable character string […]