Test the Cluster of Redis Cluster on Windows to fill in the note, rediscluster
For the principle of redis cluster implementation, see the http://www.tuicool.com/articles/VvIZje cluster environment requires at least three nodes. We recommend that you use six nodes, namely three master nodes and three slave nodes. Create 6 new folders: 7000/7001/7002/7003/7004/7005 copy redis. windows. conf and modify the following options in the configuration file.
- Port 7000 (redis port number)
- Daemonize yes (whether to run windows in the daemon mode in the future is not supported, but can be ignored)
- Cluster-enabled yes (enable cluster)
- Cluster-config-file nodes. conf (in cluster mode, each redis node generates its own cluster configuration file. This file does not need to be manually modified and is maintained by redis itself)
- Cluster-node-timeout 5000 (in cluster mode, when the current node is alive with other nodes, when there is no response, it is considered that the other nodes are in the fail state, the above is 5 seconds)
- Appendonly yes (whether to enable appendonlylog. If it is enabled, a log is recorded for each write operation, which improves data risk resistance but affects efficiency .)
- Cluster-require-full-coverage yes (the default value is Yes. After a certain percentage of keys are lost (Node may not be connected or fails), the cluster stops accepting the write operation no: some slots can be used when they do not have active nodes. That is, if one of the instances fails, the entire redis cluster will not be available)
- Cluster-slave-validity-factor 10 (control slave node FailOver related settings to set to 0, the slave node will always try to start FailOver. it is set to a positive number, and the loss of the common node is at a certain time (factor * node TimeOut), and no FailOver is performed)
Put them in the five folders above (Note: After the copy is complete, modify redis under the 7001/7002/7003/7004/7005 directory. in the conf file, change the port parameter to the corresponding folder name) Start the six redis slave redis-server.exe H: \ Tools \ cluster \ 7000 \ redis.7000.confredis-server.exe H: \ Tools \ cluster \ 7001 \ redis.7001.confredis-server.exe H: \ Tools \ cluster \ 7002 \ redis.7002.conf
Redis-server.exe H: \ Tools \ cluster \ 7003 \ redis.7003.conf
Redis-server.exe H: \ Tools \ cluster \ 7004 \ redis.7004.conf
Redis-server.exe H: \ Tools \ cluster \ 7005 \ redis.7005.conf
After startup, the following log information is displayed, prompting Node. conf does not exist, and each node creates a NodeID, the last step to form the cluster configuration source code src file provides a script file called redis-trib.rb, is a Ruby script used to create a cluster, detection and repartitioning. but you have to install the ruby environment. Then install the ruby function of redis and run the command: ruby H: \ Tools \ cluster \ redis. trib. rb create -- replicas 1 127.0.0.1: 7000 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 Ruby requires nodes to be changed when it is created. conf, enter yes. After entering yes, I will wait until the message is successful. Who knows how to give me an infinite waiting?
H:\Tools\cluster>ruby H:\Tools\cluster\redis.trib.rb create --replicas 0 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
>>> Creating cluster
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 5 nodes...
Using 5 masters:
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
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7001
slots:0-3276 (3277 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7002
slots:3277-6553 (3277 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7003
slots:6554-9829 (3276 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7004
slots:9830-13106 (3277 slots) master
M: 6c5c8b20e7f051e19a41e96a1d0b37cc79abf647 127.0.0.1:7005
slots:13107-16383 (3277 slots) master
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..........................................................................................................................................................
NND: I was confused at the moment. I tried several solutions on the Internet, but I still couldn't. Google does not find the relevant information. I posted a post on stackoverflow to ask for help from foreigners. Http://stackoverflow.com/questions/37193338/redis-cluster-errorit's still nobody else .. Maybe my English is too bad. Because ruby code is used to configure the cluster. Next, we will debug the ruby code to see where the block is in waiting. You need to modify the redis. trib. rb file before debugging, because the parameters are not passed through the argv command. The error message is: ERR Slot 6387 is already busy solution is changed to the following (http://stackoverflow.com/questions/34230131/err-slot-xxx-is-already-busy-rediscommanderror) So OK solves a problem. If you run F5, no error is reported, but TMD still blocks it in waiting. 10 thousand horses are omitted here. Analyzed. Here, 7005, 7000, are all sent to the meet command. After receiving the signature, it is deemed that the allocation is successful.
signatures
All of them are receipt signatures of 7000. No. It should be 7001--7005. Unless it is sent to yourself? Take a closer look, the nodeids of-are the same. No error! Looking back, I started the redis command and found that the created NodeID is the same. It was wrong at the beginning !!! Modify the configuration as follows:
Port 7005 appendonly yesappendfilename "appendonly.7005.aof" cluster-enabled yescluster-config-file nodes.7005.confcluster-node-timeout limit 10cluster-migration-barrier 1cluster-require-full-coverage yes The following result is displayed again, indicating that the configuration is complete: [OK] All 16384 slots covered.
Test
Set a value from port 7000 and set the expiration time to 10 seconds. Then, get the value from port 7001. No problem! Finally, we recommend that you do not have to engage in redis on windows for personal experience.