Redis cluster construction [2] - Redis cluster construction in Windows

Windows configuration Reids cluster Redis Cluster

1. Prepare materials

1.1 Download and install Redis

Address:
https://github.com/MSOpenTech/redis/releases
Steps:
1. After decompressing, copy it to your own directory
2. Open cmd, switch to the Redis directory, enter the command, and start the server


redis-server redis.windows.conf

If the interface as shown in the figure appears, it is successful, otherwise it fails:
write picture description here
3. Then enter the command and use the client to connect to the server

`
redis-cli.exe -h 127.0.0.1 -p 6379

`
Success as shown
write picture description here

1.2 Install Ruby and configure the environment

Address:
http://railsinstaller.org/en
Steps: 1. Find
setup.rb, and keep clicking Next , enter the following commands in sequence, and the success is shown as follows:


write picture description here

1.3 Download the redis-trib.rb file

Address: https://github.com/MicrosoftArchive/redis/tree/3.0/src
Steps:
Copy the redis-trib.rb file to your local directory and use it later

2. Build a Redis cluster

A minimum of three master nodes is required for the cluster to function properly, but when first trying out the cluster functionality, it is highly recommended to use six nodes: three of which are masters and the remaining three are slaves to each master.

When the master node crashes, the Redis of the slave node will be promoted to the master node and work instead of the original master node. After the crashed master Redis resumes work, it will become the slave node.

2.1 Create a Redis cluster directory

Create 6 folders named after the port in the root directory of the redis installation,
write picture description here
as shown in the figure. Copy the redis.windows.conf and redis-server in the installed redis folder to the newly created six folders respectively.

2.2 Change the configuration of each folder

Modify the following properties in the redis.windows.conf file in the six folders:

port 7001(对应文件夹的端口号)
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

2.3 Start 6 Redis services

Originally, I used the command to enter each folder to open it, but it was too troublesome. So the subsequent deployment deploys redis to the service.
Please see the command (enter under each folder and enter)

redis-server --service-install redis.windows.conf --service-name redis-6380

If the creation is successful, as shown in the figure:

2.4 Enter the create cluster command

Put redis-trib.rb into the 7000 folder and the Redis folder respectively.
Then open cmd and enter the command

ruby 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

After using this command, the system will create a Redis cluster for you, and will print out an expected configuration for you to see. If you think there is no problem, you can enter yes, and redis-trib will apply this configuration to the cluster. Among them, let each node start communicating with each other. As shown
write picture description here

3. Test

3.1 Use the command to connect to the cluster

redis-cli.exe -c -p 7000

write picture description here

At this point, the cluster is built!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324933872&siteId=291194637