Publish redis stand-alone pseudo cluster under window s (redis version 5 or above)

Posted by longhorn14 on Sat, 29 Jan 2022 20:06:34 +0100

catalogue

1, Download windows version of redis

2, Unzip redis to a directory

3, Create cluster node directory

4, Register windows services

5, Create cluster

6, Testing

7, Summary and expansion

1, Download windows version of redis

Baidu online disk: https://pan.baidu.com/s/19LVXqtp8lHNRqeYQkc8CKA 
Extraction code: v5oj

win_ The current version of x64 is 5.0.10

2, Unzip redis to a directory

Take the figure as an example, unzip and select the directory

3, Create cluster node directory

Create a clsuter (Note: this word is misspelled, the name is taken from itself) directory, create a folder of 6 nodes under the directory, and redis windows-service. Copy conf to the corresponding folder, as shown in the figure:

Modify redis windows-service. Conf file, starting with the line port 6379, add the following.

#Mask current port
#port 6379

#Open 7001 port
port 7001 


cluster-enabled yes 
cluster-config-file nodes7001.conf 
cluster-node-timeout 5000 
appendonly yes 

Port corresponds to the port name of 6 folders, nodes7001 The same goes for conf

So far, the preparations have been fully completed. At present, redis5 does not need a ruby environment, so rubyinstall and rubygems do not need to be installed. This pit has been filled.

4, Register windows services

Use the cmd command to return to the D: \ reidclsuter \ redis directory, and execute the following command in cmd to register instances under different ports of redis

#Registration service
redis-server --service-install redis.windows-service.conf --loglevel verbose

redis-server --service-install D:\reidsClsuter\redis\clsuter\7001\redis.windows-service.conf --service-name redis7001

redis-server --service-install D:\reidsClsuter\redis\clsuter\7002\redis.windows-service.conf --service-name redis7002

redis-server --service-install D:\reidsClsuter\redis\clsuter\7003\redis.windows-service.conf --service-name redis7003

redis-server --service-install D:\reidsClsuter\redis\clsuter\7004\redis.windows-service.conf --service-name redis7004

redis-server --service-install D:\reidsClsuter\redis\clsuter\7005\redis.windows-service.conf --service-name redis7005

redis-server --service-install D:\reidsClsuter\redis\clsuter\7006\redis.windows-service.conf --service-name redis7006

Through the task manager, you can see that all redis services have been registered successfully and all instances have been started. As shown in the figure:

5, Create cluster

Or use the cmd console to return to the D: \ reidclsuter \ redis directory and execute the following command

#Create cluster
redis-cli --cluster create 192.168.1.80:7001 192.168.1.80:7002 192.168.1.80:7003 192.168.1.80:7004 192.168.1.80:7005 192.168.1.80:7006 --cluster-replicas 1

#--Cluster replicas 1 indicates that each master node has a slave node

The following information will be output after execution

If all slot s are allocated successfully, the cluster has been deployed.

6, Testing

Test 1: Hello World (the deployment is successful, of course, it is inseparable from the initial hello world)

Log in through a certain computer, and the login command is:

#Login cluster
redis-cli -c -p 7001 -h 192.168.1.80

Test 2: query cluster status

#View cluster information
cluster nodes

As shown in the figure, 7001 ~ 7003 are primary nodes and 7004 ~ 7006 are slave nodes

Test 3:

1. Will data stored on a redis instance be stored on another instance

2. Can a redis instance that does not store data read the stored data

Figure I

Figure II

As shown in Figure 1, after storing a key on 7002, it will be stored in the instance of 7003.

As shown in Figure 2, the data on 7003 is read on 7004.

There seems to be a problem here. Why doesn't the data be read from the node? (to be verified)

Test 4:

1. Test whether the master node is offline and whether the slave node can be filled immediately

2. Whether master-slave replication is followed

We take node 7003 offline and stop the windows service to test whether there will be other slave nodes switching to the master node

The experimental results are as follows:

When the 7003 goes down, the 7004 jumps to the master node and passes the data test of hello world. The results are as follows:

You can see that the data has been written to 7004 after the shutdown of 7003.

7, Summary and expansion

Summary:

I. pseudo cluster deployment can be realized under single machine.

II. Master slave automatic switching can be realized under single machine.

III. redis-cli can be used to create the cluster version.

IV. after deploying the redis cluster, redis has encapsulated the hash algorithm of how to store to which node.

Expansion: (subject to a notebook with 16g memory)

I. can redis instances exceed the size of notebook memory to realize cross allocation?

2. If the memory applied for redis instance is crossed, will the data be shared?

III. is the single deployment concurrency of redis under single machine the same as that of pseudo cluster deployment?

 

Topics: Java Redis