Redis On Windows安装记录
Redis是目前比较流行的内存非关系型数据库解决方案,依托高性能、复制特性和面向问题的数据结构,越来越多被作为系统核心组件采纳应用。大部分应用环境,Redis是基于Linux体系环境的,但是也提供了Windows环境安装方案。
本篇主要介绍安装Redis On Windows方法,提供给需要的朋友待查。
1、 环境和介质
首先,我们从Redis官网https://redis.io/上,是不能找到Windows版本的Redis介质的。但是,在GitHub上,能找到对应的旧版Redis On Windows介质,网址:ttps://github.com/MSOpenTech/redis/releases。
笔者下载的是64位3.2版本,介质名称:Redis-x64-3.2.100.zip。注意:和其他软件一样,Redis也提供了安装exe/mis版本和zip解压缩版。对于用户而言,exe版本安装比较简单,本篇集中在zip版本介绍上。
2、 安装配置
解压zip文件,到指定的安装目录上。
--放在对应目录上
C:\>cd redis
C:\Redis>dir
驱动器 C 中的卷没有标签。
卷的序列号是 360A-018F
C:\Redis 的目录
2018/07/16 22:03 <DIR> .
2018/07/16 22:03 <DIR> ..
2016/07/01 16:27 1,024 EventLog.dll
2016/07/01 16:07 12,509 Redis on Windows Release Notes.docx
2016/07/01 16:07 16,727 Redis on Windows.docx
(篇幅原因,有省略……)
2016/07/01 16:07 48,212 redis.windows-service.conf
2016/07/01 16:07 48,201 redis.windows.conf
2016/07/01 09:17 14,265 Windows Service Documentation.docx
14 个文件 22,470,282 字节
2 个目录 30,208,651,264 可用字节
默认情况下的运行参数,是需要我们进行简单调整的。注意:如果是投产环境,就需要仔细斟酌。
主要调整文件是redis.windows.conf,其中以key-value方式进行数据组织。我们调整两个参数,一个是内存使用大小,另一个是验证模式。
# maxmemory <bytes>
maxmemory 1073741824
# requirepass foobared
requirepass test
3、启动和测试实验
如果需要,可以在环境配置文件PATH中增加Redis目录。通过command命令行,执行启动服务器命令。
C:\Users\51ibm>redis-server.exe redis.windows.conf
Invalid argument during startup: Failed to open the .conf file: redis.windows.conf CWD=C:\Users\51ibm
需要切换到安装目录进行执行,否则不能找到对应配置文件。
C:\Users\51ibm>cd c:/redis
c:\Redis>redis-server.exe redis.windows.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.100 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 9392
[9392] 16 Jul 22:17:26.870 # Server started, Redis version 3.2.100
[9392] 16 Jul 22:17:26.871 * The server is now ready to accept connections on port 6379
服务器启动后,在特定端口(默认端口6379)等待连接。Redis提供了标准命令行访问工具redis-cli.exe,用来进行访问。
C:\Users\51ibm>redis-cli.exe
127.0.0.1:6379> info
NOAUTH Authentication required.
127.0.0.1:6379> auth test
OK
127.0.0.1:6379> info
# Memory
used_memory:690096
maxmemory:1073741824
(篇幅原因,有省略……)
在Windows环境上,如果关闭后台的命令窗口,服务器自动关闭。
[9392] 16 Jul 22:19:52.594 # User requested shutdown...
[9392] 16 Jul 22:19:52.594 * Saving the final RDB snapshot before exiting.
[9392] 16 Jul 22:19:52.680 * DB saved on disk
[9392] 16 Jul 22:19:52.680 # Redis is now ready to exit, bye bye...
4、安装启动服务
在Windows上,类似服务最好以操作系统服务Service的方式进行管理。可以通过专门命令行进行配置。
c:\Redis>redis-server --service-install redis.windows.conf --loglevel verbose
[9236] 16 Jul 22:22:54.376 # Granting read/write access to 'NT AUTHORITY\NetworkService' on: "c:\Red
is" "c:\Redis\"
[9236] 16 Jul 22:22:54.377 # Redis successfully installed as a service.
c:\Redis>
启动服务后,系统可以正常访问。
127.0.0.1:6379> auth test
OK
127.0.0.1:6379> set name Tom
OK
127.0.0.1:6379> get name
"Tom"
127.0.0.1:6379>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。