有时候客户环境是windows系统,但是我们的项目又用redis,那么就需要下载windows版本的redis来安装使用。
下载地址: http://redis.io/download
下载解压后,打开Windows Service Documentation.docx,里面有详细的命令:
安装服务:
redis-server --service-install redis.windows.conf--loglevel verbose
卸载服务:
redis-server --service-uninstall
启动服务:
redis-server.exe --service-start
redis-server.exe --service-stop
关于启动服务这一步,有可能会报错:
The Windows version of Redis allocates a memory mapped heap for sharing with
the forked process used for persistence operations. In order to share this
memory, Windows allocates from the system paging file a portion equal to the
size of the Redis heap. At this time there is insufficient contiguous free
space available in the system paging file for this operation (Windows error
0x5AF). To work around this you may either increase the size of the system
paging file, or decrease the size of the Redis heap with the --maxheap flag.
Sometimes a reboot will defragment the system paging file sufficiently for
this operation to complete successfully.
出现这个错误,多半是由于没有在conf文件中配置maxheap导致。
在redis.windows.conf中找到 # maxheap <bytes>,在下面添加配置 maxheap xxxxxx
再启动,如果报no such file or directory, 则应该是没有创建heap文件的目录:
heapdir D:/temp/redis_heapdir/
创建目录即可。
另:建议按照文档指令来操作,否则可能会出现各种奇怪问题,比如启动报错、停止报错,但是实际上已经起来(停止)了。