Redis cluster building ~ redis-x64-3.2.100

Time:2020-4-1

Reference documents:

https://www.cnblogs.com/yaopengfei/p/12418227.html

https://blog.csdn.net/weixin_42694286/article/details/92974535

https://blog.csdn.net/qq_42815754/article/details/82912130

https://blog.csdn.net/u010963948/article/details/78963572

 

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: https://github.com/msopentech/redis/releases/

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\redis.windows-service6379.conf –service-name RedisService6379

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

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

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

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

D:\Redis-x64-3.2.100_cluster\redis-server.exe –service-install D:\Redis-x64-3.2.100_cluster\redis.windows-service6384.conf –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: http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.2.4-x64.exe

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: https://rubygems.org/gems/redis/versions/3.2.2 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: https://github.com/beebol/redis-trib.rb 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 127.0.0.1:6379 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

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

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

If you encounter the following error, please refer to the document: https://blog.csdn.net/maoyuanming0806/article/details/103171182

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: https://blog.csdn.net/xufei512/article/details/82758676

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: https://blog.csdn.net/yaomingyang/article/details/79094869

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:

https://blog.csdn.net/u010963948/article/details/78963572

 

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 […]