Redis对于Linux是官方支持的,安装和使用没有什么好说的,普通使用按照官方指导,5分钟以内就能搞定。详情请参考:
http://redis.io/download
但有时候又想在windows下折腾下Redis,可以从redis下载页面看到如下提示:
1.
Win64 Unofficial The Redis project does not directly support Windows,
2.
however the Microsoft Open Tech group develops and maintains
3.
an Windows port targeting Win64.
大意就是 Redis官方是不支持windows的,只是 Microsoft Open Tech group 在 GitHub上开发了一个Win64的版本,项目地址是:
https://github.com/MSOpenTech/redis
打开以后,可以直接使用浏览器下载,或者git克隆。
可以在项目主页右边找到 zip包下载地址: https://github.com/MSOpenTech/redis/archive/2.8.zip
下载解压,没什么好说的,在解压后的bin目录下有以下这些文件:
1.
redis-benchmark.exe #基准测试
2.
redis-check-aof.exe # aof
3.
redis-check-dump.exe # dump
4.
redis-cli.exe # 客户端
5.
redis-server.exe # 服务器
6.
redis.windows.conf # 配置文件
【换机器重新测试后已查明,如果不是Administrator用户,就会出各种问题,服务安装以后启动不了等等问题,应该可以修改服务的属性-->登录用户等选项来修正.】
【如果你安装的windows没有Administrator账户,请参考这篇文章:
Windows 7 启用超级管理员administrator账户的N种方法
】
网上参考了一些资料,发觉可以使用,也就没有深究,直接拿来主义:
启动脚本如下:
1.
redis-server redis.windows.conf
但是在cmd之中执行这行命令之后报错:
01.
D:\Develop\redis-
2.8
.
12
>redis-server.exe redis.windows.conf
02.
[
7736
]
10
Aug
21
:
39
:
42.974
#
03.
The Windows version of Redis allocates a large memory mapped file
for
sharing
04.
the heap with the forked process used in persistence operations. This file
05.
will be created in the current working directory or the directory specified by
06.
the
'dir'
directive in the .conf file. Windows is reporting that there is
07.
insufficient disk space available
for
this
file (Windows error
0x70
).
08.
09.
You may fix
this
problem by either reducing the size of the Redis heap with
10.
the --maxheap flag, or by starting redis from a working directory with
11.
sufficient space available
for
the Redis heap.
12.
13.
Please see the documentation included with the binary distributions
for
more
14.
details on the --maxheap flag.
15.
16.
Redis can not
continue
. Exiting.
根据提示,是 maxheap 标识有问题,打开配置文件 redis.windows.conf , 搜索 maxheap , 然后直接指定好内容即可.
1.
.......
2.
#
3.
# maxheap <bytes>
4.
maxheap
1024000000
5.
.......
01.
D:\Develop\redis-
2.8
.
12
>redis-server redis.windows.conf
02.
_._
03.
_.-``__
''
-._
04.
_.-`` `. `_.
''
-._ Redis
2.8
.
12
(
00000000
/
0
)
64
bit
05.
.-`` .-```. ```\/ _.,_
''
-._
06.
( ' , .-` | `, ) Running in stand alone mode
07.
|`-._`-...-` __...-.``-._|
'` _.-'
| Port:
6379
08.
| `-._ `._ / _.-' | PID:
6736
09.
`-._ `-._ `-./ _.-
' _.-'
10.
|`-._`-._ `-.__.-
' _.-'
_.-'|
11.
| `-._`-._ _.-
'_.-'
| http:
//redis.io
12.
`-._ `-._`-.__.-
'_.-'
_.-'
13.
|`-._`-._ `-.__.-
' _.-'
_.-'|
14.
| `-._`-._ _.-
'_.-'
|
15.
`-._ `-._`-.__.-
'_.-'
_.-'
16.
`-._ `-.__.-
' _.-'
17.
`-._ _.-'
18.
`-.__.-'
19.
20.
[
6736
]
10
Aug
22
:
01
:
22.247
# Server started, Redis version
2.8
.
12
21.
[
6736
]
10
Aug
22
:
01
:
22.248
* The server is now ready to accept connections on port
6379
然后可以使用自带的客户端工具进行测试。
双击打开 redis-cli.exe , 如果不报错,则连接上了本地服务器,然后测试,比如 set命令,get命令:
1.
127.0
.
0.1
:
6379
> set tiemao http:
//blog.csdn.net/renfufei
2.
OK
3.
127.0
.
0.1
:
6379
> get tiemao
5.
127.0
.
0.1
:
6379
>
如果需要帮助,可以在 cli窗口中输入 help查看,例如:
1.
127.0
.
0.1
:
6379
> help
2.
redis-cli
2.8
.
12
3.
Type:
"help @<group>"
to get a list of commands in <group>
4.
"help <command>"
for
help on <command>
5.
"help <tab>"
to get a list of possible help topics
6.
"quit"
to exit
7.
127.0
.
0.1
:
6379
> help
@string
备注说明:
1. 这个版本是Win64的,所以32位windows就不要折腾了。
2. 我的操作系统是Windows 7 64位旗舰版,运行内存16GB,用户不是Administrator,而是 hasee,所以设置了下 redis-server.exe 和redis-cli.exe 的属性中的兼容性权限(以管理员身份运行),如果你运行出错,可能需要设置一下这里。
3. 什么360啊,UAC啊,防火墙啊,该关的请关闭。。。
4. 如果有其他问题,欢迎留言或者评论, 这只是一个心血来潮时的折腾
接触了好久Redis但一直没在windows下使用,请轻拍。