AAA在windows上部署Redis系统服务

来源:互联网 发布:滚压成型工艺软件 编辑:程序博客网 时间:2024/06/06 07:09

redis下载:https://github.com/MSOpenTech/redis/releases

我是直接下载Redis-x64-3.0.501.msi             Redis-x64-3.0.501.zip

也可以通过本文下载(包括zip版本、msi版和最新版的Redis Desktop Manager):http://download.csdn.net/detail/zhousenshan/9544118

这个zip包,同时在zip压缩包里面有一片文章Windows Service Documentation.docx

[html] view plain copy
  1. Running Redis as a Service  
  2. If you installed Redis using the MSI package, then Redis was already   
  3. installed as a Windows service. Nothing further to do. If you would   
  4. like to change its settings, you can update the redis.windows-service.  
  5. conf file and then restart the Redis service (Run -> services.msc ->  
  6.  Redis -> Restart).   
  7. If you did not install Redis using the MSI package, then you still  
  8.  run Redis as a Windows service by following these instructions:  


这是我采用msi包安装后的服务

右击属性选择这个服务的安装地址,打开它的安装地址,可以看到它里面的文件目录跟我们下载的zip包是一样的。


可以打开redis-cli.exe客户端包,进行简单的操作。目前多半采用Redis Desktop Manager这个桌面redis客户端软件进行操作,比较方便,redis默认数据库从db0到db15,一般进去默认使用db0数据库。

下面的这篇文章就是采用的命令行形式,个人感觉还是msi比较方便,下面的文章仅作参考

启动Redis

直接在上图的目录打开命令窗口,运行:

  1. redis-server redis.windows.conf

结果就悲剧了,提示:QForkMasterInit: system error caught. error code=0x000005af, message=VirtualAllocEx failed.: unknown error 。原因是内存分配的问题(如果你的电脑够强悍,可能不会出问题)。解决方法有两个,第一:启动的时候使用--maxmemory 命令限制Redis的内存:

  1. redis-server redis.windows.conf --maxmemory 200m

第二种方法就是修改配置文件redis.windows.conf :

  1. maxmemory 209715200

注意单位是字节,改完后如下:

之后再运行redis-server redis.windows.conf 就可以启动了:

但是问题又来了,关闭cmd窗口就会关闭Redis,难道服务器上要一直开着吗?这显然是不科学的,下面看怎么在服务器上部署。

部署Redis

其实Redis是可以安装成windows服务的,开机自启动,命令如下:

  1. redis-server --service-install redis.windows.conf

安装完之后,就可看到Redis已经作为windows服务了:

但是安装好之后,Redis并没有启动,启动命令如下:

  1. redis-server --service-start

停止命令:

  1. redis-server --service-stop

还可以安装多个实例

  1. redis-server --service-install service-name redisService1 port 10001
  2. redis-server --service-start service-name redisService1
  3. redis-server --service-install service-name redisService2 port 10002
  4. redis-server --service-start service-name redisService2
  5. redis-server --service-install service-name redisService3 port 10003
  6. redis-server --service-start service-name redisService3

卸载命令:

  1. redis-server --service-uninstall

最后提示一下:2.8版本的不支持32位系统,32位系统要去下载2.6版本的。2.6版本的无法像上面一样方便的部署,它提供一个叫RedisWatcher的程序来运行redis server,Redis停止后会自动重启。

另外推荐一个Redis可视化管理工具:Redis Desktop Manager,官网的下载地址被墙了,可以在我的网盘下载 v0.7.6版,放个截图:

原创粉丝点击