A required software
Redis, Ruby language runtime, Redis's Ruby driver Redis-xxxx.gem, the tools to create Redis clusters redis-trib.rb
Two-installation configuration Redis
Redis https://github.com/MSOpenTech/redis/releases; Download Redis.
Cluster planning has three nodes of the cluster, each node has a master one. Requires 6 virtual machines.
After the Redis decompression, and then copied 5 copies, configuration three master three from the cluster. Since the Redis default port number is 6379, the other 5-part ports can be 6380,6381,6382,6383,6384. and name the directory using the port number
Open the redis.windows.conf configuration file under each directory, modify the port number inside, and the cluster support configuration.
// set the port number // not yes, when using the Jediscluster cluster code gets the error. /// adjusted to 15000, the cluster will not time out when it is created. // is the configuration information for the node, where the nodes-port is used. conf naming method. The file is generated in the directory after the service is started. // open aof Persistent // Set Password, if not required can not set
Then write a bat in each folder to start Redis and create Start.bat in each node directory, as follows:
Title redis-6379redis-server.exe redis.windows.conf
Three-Mount Ruby
Redis clusters are written in Ruby script, so the system needs to have a ruby environment, http://dl.bintray.com/oneclick/rubyinstaller/, open to find the version of the corresponding EXE file download
3 options are checked at the time of installation.
Quad-Install Redis's Ruby driver Redis-xxxx.gem
Https://rubygems.org/pages/download, unzip it after downloading, and then execute SETUP.RB in the extracted directory.
Then gem installs Redis: Switch to Redis's installation directory and need to perform a gem install Redis at the command line
Five Install cluster script Redis-trib
Https://raw.githubusercontent.com/antirez/redis/unstable/src/redis-trib.rb
Open the link if you do not download, but instead open a page, then save the page as a redis-trib.rb, it is recommended to save to a Redis directory, for example, put in 6379 directory.
Six start each node and execute the cluster build script
Double-click the Start.bat under each node to start the switch to the Redis directory at the command line to execute
1 127.0. 0.1:6379127.0. 0.1:6380127.0. 0.1:6381127.0. 0.1:6382127.0. 0.1:6383127.0. 0.1:6384
--replicas 1 indicates that each primary database has a number of 1 from the database. The master node cannot be less than 3, so we used 6 Redis
Note: There is a friend reaction above the statement execution is unsuccessful. You can add Ruby to the front and run it.
1 127.0. 0.1:6379127.0. 0.1:6380127.0. 0.1:6381127.0. 0.1:6382127.0. 0.1:6383127.0. 0.1:6384
Is the Can I set the above configuration appear? (Type ' yes ' to accept): Please confirm and enter Yes. Successful results are as follows:
Note: If you set a password before setting the redis.windows.conf file, you will get an error
The workaround is to locate the file: \ruby23-x64\lib\ruby\gems\2.3.0\gems\redis-4.0.1\lib\redis\client.rb, open and modify password to the password previously set:
Seven Tests
Use Redis client Redis-cli.exe to see the number of data records and cluster-related information
Command redis-cli–c–h "Address" –p "Port number"-a "password"; C represents the cluster
Enter the total number of dbsize query records
Enter cluster info to view the cluster's information from the client
Reference:
Building a Redis cluster on Windows (redis-cluster)
Redis Cluster Password settings
Building a Redis cluster on Windows