redis基础-windows

本文介绍如何在Windows 64位系统上安装和使用Redis,包括下载、安装成系统服务、启动和停止的方法,以及客户端访问测试命令。同时解决在Windows环境下使用Redis可能遇到的内存映射堆分配问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        Win64版的Redis由微软团队(MSOpenTech)开发,其源代码托管Github账号这里。目前,MSOpenTech给出的最新版本里已经不再支持Win32 Redis。

        Redis下载,地址:https://github.com/MSOpenTech/redis/releases,例如下载Redis-x64-2.8.2104.zip,下载完解压到系统盘(D盘)即可,比如解压到D:\redis64-2.8.2104。

        Redis安装,把Redis注册为系统服务进程,以方便管理和使用,但非必须,打开cmd,进入D:\redis64-2.8.2104目录,然后运行 :    

redis-server --service-install redis.windows.conf --loglevel verbose

        如果注册了,则可以运行以下命令启动

redis-server --service-start

        非注册的情况可以运行以下命令启动:

redis-server redis.windows.conf

        注册方式停止服务命令:

redis-server --service-stop

        非注册方式可以直接Ctrl+c退出

        移出注册的redis服务命令:

redis-server --service-uninstall

        客户端访问测试,cmd一个新的窗口,cd进入redis所在根目录(D:\redis64-2.8.2104),通过以下命令访问:

redis-cli -h 127.0.0.1 -p 6379

以上命令指定了主机地址和端口号(注意空格隔开),如果不指定的话(直接输入redis-cli命令),则使用默认的主机地址(127.0.0.1)和端口号(6379)。

        使用redis:

set sKey 'Redis start on win64'
append sKey ' ,I am CJ.'
get sKey
keys *

        Windows下使用redis会遇到的问题:

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.

Please see the documentation included with the binary distributions for more
details on the --maxheap flag.
Redis can not continue. Exiting.

         引起该问题的主要原因是maxheap设置的问题。手动设定maxheap小一些,不能太小,至少大于1MB,打开redis.windows.conf文件,找到maxheap配置文本处添加如下一行即可:

maxheap 4294967296
         此外heapdir参数的配置也很重要,可以设置为 D:\redis64-2.8.2104\heapdir。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值