To prepare
Download and install Redis
Redis successfully installed after the file
Redis only has clustering after 3.0
Modify the redis.windows.conf configuration file
The modified content is
Appendonly yes specifies whether to log after each update operation. Redis writes data to disk asynchronously by default. If this is not enabled, data may be lost for a period of time in the event of a power outage. Yes, said: Storage mode, AOF, Save write operation records to logs cluster-enabled yes // Enable cluster mode cluster-config-file nodes-701. conf // Save node configurations, automatic creation, and automatic update (port numbers are recommended) Cluster-node-timeout 15000 // Cluster timeout period. If a node does not respond after the timeout period, the node is downCopy the code
Then copy the 7001 REDis file to 7002 7003 —- 7006!
The Redis cluster needs at least 3 master nodes, so now there are 6 nodes in total, so it can only be 1master for 1slave.
Conf file and cluster-config-file. If the cluster-config-file is cluster-config-file, the cluster-config-file can be used to replace the cluster-config-file and the cluster-config-file.
Then create a startup BAT file under each node file
startbat.bat
title redis
redis-server.exe redis.windows.conf
Copy the code
Then start with each click
Download Ruby and install it
Download address: dl.bintray.com/oneclick/ru… Double-click install next and check all.
Download and install Redis Ruby driver redis-xx.gem
Download according to your version of Redis
Download it and place it in the Ruby installation directory
CMD Open the command box and run the gem install –local C:\ ruby22-x64 \redis-3.2.2.gem command. If the following information is displayed, the configuration is successful
Install the cluster script redis-trib
Download address raw.githubusercontent.com/antirez/red…
Or baidu cloud link: pan.baidu.com/s/1kOZs9f7o… Extraction code: VDHF
Download the file and place it in the redis cluster file root directory
Start the cluster
First of all,
Start all redis from 7001 to 7006 (or start all cluster nodes start.bat).
then
Run CMD to run the script redis-trib.rb to build the cluster
Ruby redis-trib.rb create --replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006Copy the code
In Replicas 1, 1 represents the ratio of the master to the slave. In replicas 1, there are three master and three slave, so it is 1
Each cluster is in progress
The script launched above creates the cluster by asking if you want to print more details. Type yes, and redis-Trib will apply this configuration to the cluster, allowing the nodes to start communicating with each other.
A lot of logs are printed out along the way
test
Adding a data test to the 7001 library and then synchronizing the query data from other libraries is considered successful.
Allocation policy
Redis cluster data allocation policy
Hash slots are used to allocate data. By default, the Redis Cluster allocates 16,384 slots to each of the three nodes