Redis 安装为 Windows 服务开机后台自启
方法:使用自带的命令安装(推荐)
Redis 的 Windows 版本通常自带了安装服务的命令。
-
以管理员身份运行 CMD
- 在开始菜单搜索 cmd,右键点击"命令提示符",选择 "以管理员身份运行"。
-
进入 Redis 目录
-
输入你的 Redis 所在路径(根据你日志中的路径):
cd /d D:\dev\Redis-x64-3.2.100
-
-
执行安装服务命令
-
你需要指定配置文件(redis.windows.conf 或 redis.windows-service.conf)。通常建议使用 redis.windows-service.conf,因为它是专门为服务模式优化的。
-
输入以下命令:
redis-server --service-install redis.windows-service.conf --loglevel verbose
-
-
启动服务
-
安装成功后,服务不会自动马上启动,你需要手动启动它一次:
redis-server --service-start -
或者在 Windows 的"服务"管理界面中找到 Redis 点击启动。
-
设置完成! 以后电脑开机,Redis 就会自动在后台启动了。
常用管理命令
以后如果需要停止或卸载服务,可以使用以下命令(同样需要在 Redis 目录下以管理员身份运行):
-
停止服务:
redis-server --service-stop -
卸载服务:
redis-server --service-uninstall
可视化工具
推荐:Another Redis Desktop Manager