Windows installation Redis
background
Redis is very popular for its excellent performance. It has always been a software that developers cannot live without. I believe that those who are willing to click on this article have recently needed to
build various project running environments on Windows servers , including Redis because You may instruct others to install it in the future, so simply record the tutorial document in the form of a blog.
Install
This article only introduces the installation of Redis under Windows. For other methods and introduction to the use of Redis, please click the blue link to view: For
installation under Linux, see: Chapter 2 of Redis Technology.
For installation under Docker, see: Chapter 7 of Docker Technology.
-
Download address: github
requires a VPN. If you don’t have a VPN, you can download the resource attachments bound to this blog.
-
After installing the
downloaded.msi
image installation file, double-click to install. As shown below, just clicknext
ps
: If the installation location is not set manually, the default location is inC:\Program Files\Redis
the directory (will be used below).
Add it to the system environment variable, so that it can be used in cmd Connect through the local shell under the command
-
To access redis-cli,
you can double-click to open itC:\Program Files\Redis
in the directoryredis-cli.exe
, or you cancmd
open the command line and enterredis-cli -h 127.0.0.1
to access ( you need to check the box above and add it to the system environment variable )
Configuration
Start automatically at boot
In Windows, all running programs run as services,
so we only need to hand over the service to the system for hosting and the system will automatically restart.
- For service management,
Win+R
press the key combination to enter the running window, enterservices.msc
to enter the service management page, find Redis, and check whether the startup type
of the Redis service is automatic . Automatic means that it is handed over to the system for hosting. When the system restarts or starts, it will automatically start something like Spring. Inject the bean into Spring. The container automatically manages the bean life cycle (creation and destruction, etc.). ps: If the startup type is manual, double-click the service and reselect the startup type to automatic .
Supplement: Configure jar to start automatically in Windows
For some reasons, the jar package cannot be registered with the service after startup, so we cannot configure auto-start in the above way. Therefore, using the
Windows Scheduler to automatically execute Windows scripts to start the project has become the first choice. The steps are as follows
-
Prerequisite: To run the jar package, you need to install jdk and configure environment variables
-
Writing Windows startup scripts
.bat
chcp 65001
can avoid garbled content in the window display.chcp 65001 @title 运行时左上角的shell窗格名称 java -jar jar名称 pause
-
Find computer management
-
Create basic tasks
-
Set task name and description
-
Set task trigger conditions
-
Set task action
-
Specify task startup script/batch program
set password
Please choose temporary configuration or permanent configuration according to the actual situation such as whether your Redis service will be restarted.
temporary
The advantage of setting the password through redis-cli is that it takes effect without restarting, but the disadvantage is that it becomes invalid after restarting. I configured it like this before I needed to reconfigure it,
but because Windows restarts irregularly, I need to manually configure the password again after restarting. There are still some problems. Troublesome
-
In
redis-cli
Manual Settings
openredis-cli.exe
, enterCONFIG SET requirepass "密码"
-
Enter
auth 密码
to verify whether the password is successful
Permanent (recommended)
Setting the password under redis-cli has the opposite advantages and disadvantages than the temporary effective method. It
will also take effect after a restart. The disadvantage is that it must be restarted after configuration.
-
Check which configuration file is used when the Redis service starts.
When configuring the above configuration to start automatically, we can check in the service details which configuration file is used when the Redis service starts.
win+R->cmd->services.msc->Redis
We can see that the configuration file in the Redis installation directory is usedredis.windows-service.conf
. We need toredis.windows-service.conf
modify this file
ps: If there is no configuration file address here, then we can manually close it and open a shell in the Redis installation directory
./redis-server.exe --service-install redis.windows-service.conf
-
After finding the file, perform a global search and search
requirepass
to find the following area
-
After configuration, while still on the service page, restart the service and be
careful not to click on the wrong service, which will give you the illusion that the configuration file is configured but invalid!!!
-
rediis-cli
Verify whether it takes effect
Reference blog
https://blog.csdn.net/Itmastergo/article/details/131569908
https://blog.csdn.net/gmm313/article/details/129835401
https://blog.51cto.com/ios9/5374277