First of all, everyone is welcome to read this document. This document is mainly divided into three modules: introduction and installation of Redis, installation of RedisDesktopManager visualization tool, and configuration of master-slave (sentry) mode.
Table of contents
3. Installation of RedisDesktopManager visualization tool
Fourth, the configuration of the master-slave (sentry) mode
1. Introduction to Redis
Redis is completely open source and free, and complies with the BSD protocol. It is a flexible high-performance key-value data structure storage that can be used as a database, cache, and message queue.
Compared with other key-value cache products, Redis has the following three characteristics:
- Redis supports data persistence, which can save the data in the memory to the disk, and can be loaded into the memory again when restarting.
- Redis not only supports simple key-value type data, but also provides storage of data structures such as list, set, zset, and hash.
- Redis supports master-slave replication, that is, data backup in master-slave mode.
2. Redis installation:
1. Here are three installation methods for you:
(1) Download the installation package from Baidu Netdisk: https://pan.baidu.com/s/1CTl6_0MSSjWC4kIcM5Ov1w
Extraction code: 1111
(2) Baidu network disk download compressed package: https://pan.baidu.com/s/1Cp01oF23PaEQz-mFMbM7WA
Extraction code: 1111
(3) Download the compressed package from the official website: Releases tporadowski/redis (github.com)
Note: Using the compressed package is the quickest and most convenient method. After downloading the compressed package, just decompress it and put it on the corresponding disk.
Verify it:
Enter the command: redis-server redis.windows.conf Enter
Start successfully
2. After the download is complete, we can configure the environment variables:
Open the Redis file location, copy the path,
Example: E:\Redis-x64-5.0.14.1
After copying, start configuring
then click OK
Keyboard win+R enter cmd and press Enter
Open the black window and enter: redis-server
Start successfully
3. Installation of RedisDesktopManager visualization tool
Baidu network disk download: https://pan.baidu.com/s/1K4L5w6wRMda7VAIxbfauFw
Extraction code: 1111
Official website download: https://redis.com.cn/clients.html
Note: It is recommended to use Baidu network disk to download
After the download is complete, double-click the installation package
Next step
Agree to the user agreement
It is recommended to choose the D drive or the E drive instead of the C drive. After selecting the installation location, click Install.
Note: After the installation is complete, we first open the Redis service, and then open the software
Note: There are tutorials on the opening method
Just turn it off here
After closing, we create a new
Once done, we double-click the connection
connection succeeded
new content
success
Note: You can check the command operation by yourself, the wooden man will not show you here, and only teach you the installation and basics here.
Fourth, the configuration of the master-slave (sentry) mode
1. Function
read-write separation
- One master and multiple slaves, master-slave synchronization
- The master is responsible for writing, and the slave is responsible for reading
- Improve Redis performance and throughput
- There is a master-slave data consistency problem
Data disaster recovery
- The slave is the backup of the master
- The master is down, the slave can read but not write
- By default, after the master is down, the slave cannot be the master
- Sentinels can be used to achieve master-slave switching to achieve high availability
2. Configuration method:
Here is an example for everyone: one master and one slave (one master and one whistle)
Just now we downloaded Redis, found our Redis location, and then copied and pasted it
The default port number of our Redis is 6379, here we copy the slave server and give it an iconic name
Enter the slave server directory, change the port number and configuration
First open: redis.windows-service.conf file
After saving, open: redis.windows.conf file
After the change, continue to find: replicaof <masterip> <masterport>,
Paste here: slaveof 127.0.0.1 6379 6379 is the port number of the master server
Add and save changes
After saving, open the master server and slave server respectively under the folder
Enter the cmd under the master and slave folders respectively, and execute the redis-server redis.windows.conf command to start the service
3. Test master-slave
Do not shut down the server, minimize the black window
Enter the master and slave server folders again and use cmd to open the black window, and run the following commands respectively:
title client-6379
redis-cli -h 127.0.0.1 -p 6379 (connect node)
info replication (see information)
Pay attention to the port number
4. Read and write key values
We use the primary key to set the key value
Command: keys *
set name Rose
Main server:
From the server:
At this point, we are basically configured, let's use the RedisDesktopManager visualization tool to take a look
After completion, double-click the connection
In this way, what we add in the main node
At slave nodes, it is also updated.
At this point, this article is officially over. Welcome to pay attention to the wooden man. If it is not suitable for production, please like it!