Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a stand-alone Redis Cluster Test Environment under Windows

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to build a stand-alone Redis cluster test environment under Windows, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.

Due to business needs, sometimes we need to use Redis cache, I believe there are still a large number of small partners like me, the development environment is under WIndows (although the actual production environment may be in Linux), sometimes we need to simulate some environments, such as the Redis environment we are going to introduce today. Here we use the cluster approach. Due to limited resources, we can use stand-alone cluster to simulate. It is enough in the development environment!

Redis version

Using the 64-bit version of 5.0.9 under Windows

Https://github.com/tporadowski/redis/releases

Start

First of all, you can download the latest version of Redis from the above Github page and decompress it to a folder. The directory structure of the author is as follows:

Every folder is the same except for the configuration.

Next, let's talk about configuration:

1. Open the redis.windows.conf under each file, and modify all the following configurations (each folder needs to be modified)

Port 6380 / / is modified to the same port number as the current folder name appendonly yes / / to specify whether to log after each update operation. Redis writes data to disk asynchronously by default. If it is not enabled, it may cause data loss for a period of time in the event of a power outage. Yes said: storage method, aof, save write records to the log cluster-enabled yes / / enable cluster mode cluster-config-file nodes-6380.conf / / save node configuration, automatically create, automatically update (port number is recommended) cluster-node-timeout 15000 / / cluster timeout, if the node does not respond to this time, it is determined to be down

2. Create a new batch file start.bat under each folder for quick startup

Title redis-6380; # redis-server.exe redis.windows.conf

Note: when modifying the configuration of the configuration file, there must be no spaces in front of the configuration item.

After all the above operations are completed, you can try to start each node to test whether it can be started successfully.

To write a batch to start the cluster, we can create a new batch under one of the folders, as follows

Redis-cli-- cluster create-- cluster-replicas 1 192.168.3.12 cluster-replicas 6375 192.168.3.12 pause 6376 192.168.12 pause 6377 192.168.3.12 pause 6378 192.168.3.12

If you set the password, then the command can be modified as follows. Pwd is the password you set. Set the password in the redis configuration file.

Redis-cli-a pwd-- cluster create-- cluster-replicas 1 192.168.3.12 cluster-replicas 6375 192.168.3.12 pause 6379 192.168.3.12 pause 6379 192.168.3.12

Start

Open the startup batch under each of the newly built files, and we start separately. After starting successfully, we are opening the batch processing of the startup cluster. In order to facilitate each startup, we have tested the aspects, that is, the contents of the folder seen above. In fact, if you want to be more convenient, you can also write a unified batch outside the folder. As follows

At this time, we can test whether the construction is successful, and the author happens to have a visual interface (

AnotherRedisDesktopManager), just use it!

Randomly choose two nodes to connect, look at the picture

Here are the results

These are all the contents of the article "how to build a stand-alone Redis cluster test environment under Windows". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report