温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Redis On Windows安装记录

发布时间:2020-08-07 23:12:25 来源:ITPUB博客 阅读:161 作者:realkid4 栏目:关系型数据库

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>

 

 

 

 


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI