Windows下安裝並設置Redis

Windows下安裝並設置Redis

Redis對於Linux是官方支持的,安裝和使用沒有什麼好說的,普通使用按照官方指導,5分鐘以內就能搞定。詳情請參考:

http://redis.io/download

但有時候又想在windows下折騰下Redis,可以從redis下載頁面看到如下提示(在頁面中搜索 "windows"):

Win64	Unofficial	The Redis project does not directly support Windows,
	however the Microsoft Open Tech group develops and maintains
	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

(注意: dist文件改變了下載地址: https://github.com/MSOpenTech/redis/releases )

在 Release 頁面中,可以找到 msi 安裝文件以及 .zip 文件(而且有3.0的beta版,請下拉查找)。

下載解壓,沒什麼好說的,在解壓後的bin目錄下有以下這些文件:

redis-benchmark.exe         #基準測試
redis-check-aof.exe         # aof
redis-check-dump.exe        # dump
redis-cli.exe               # 客戶端
redis-server.exe            # 伺服器
redis.windows.conf          # 配置文件

當然,還有一個 RedisService.docx 文件,看似是一些啟動和安裝服務的說明文檔,但是照著他的指示來,你就會死的很慘,莫名其妙的死了,不知道原因。

【換機器重新測試後已查明,如果不是Administrator用戶,就會出各種問題,服務安裝以後啟動不了等等問題,應該可以修改服務的屬性-->登錄用戶等選項來修正.】

【如果你安裝的windows沒有Administrator賬戶,請參考這篇文章:

Windows 7 啟用超級管理員administrator賬戶的N種方法

網上參考了一些資料,發覺可以使用,也就沒有深究,直接拿來主義:

啟動腳本如下:

redis-server  redis.windows.conf

可以將其保存為文件 startup.bat ; 下次就可以直接啟動了。

但是在cmd之中執行這行命令之後報錯:

D:\Develop\redis-2.8.12>redis-server.exe redis.windows.conf
[7736] 10 Aug 21:39:42.974 #
The Windows version of Redis allocates a large memory mapped file for sharing
the heap with the forked process used in persistence operations. This file
will be created in the current working directory or the directory specified by
the ‘dir‘ directive in the .conf file. Windows is reporting that there is
insufficient disk space available for this file (Windows error 0x70).

You may fix this problem by either reducing the size of the Redis heap with
the --maxheap flag, or by starting redis from a working directory with
sufficient space available for the Redis heap.

Please see the documentation included with the binary distributions for more
details on the --maxheap flag.

Redis can not continue. Exiting.

根據提示,是 maxheap 標識有問題,打開配置文件 redis.windows.conf ,搜索 maxheap , 然後直接指定好內容即可.

.......
#
# maxheap <bytes>
maxheap 1024000000
.......

然後再次啟動,OK,成功.

D:\Develop\redis-2.8.12>redis-server  redis.windows.conf
                _._
           _.-``__ ‘‘-._
      _.-``    `.  `_.  ‘‘-._           Redis 2.8.12 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ‘‘-._
 (    ‘      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|‘` _.-‘|     Port: 6379
 |    `-._   `._    /     _.-‘    |     PID: 6736
  `-._    `-._  `-./  _.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |           http://redis.io
  `-._    `-._`-.__.-‘_.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |
  `-._    `-._`-.__.-‘_.-‘    _.-‘
      `-._    `-.__.-‘    _.-‘
          `-._        _.-‘
              `-.__.-‘

[6736] 10 Aug 22:01:22.247 # Server started, Redis version 2.8.12
[6736] 10 Aug 22:01:22.248 * The server is now ready to accept connections on port 6379

然後可以使用自帶的客戶端工具進行測試。

雙擊打開 redis-cli.exe , 如果不報錯,則連接上了本地伺服器,然後測試,比如 set命令,get命令:

127.0.0.1:6379> set tiemao http://blog.csdn.net/renfufei
OK
127.0.0.1:6379> get tiemao
"http://blog.csdn.net/renfufei"
127.0.0.1:6379>

這應該很好理解,連接上了本機的6379埠。

如果需要幫助,可以在 cli窗口中輸入 help查看,例如:

127.0.0.1:6379> help
redis-cli 2.8.12
Type: "help @<group>" to get a list of commands in <group>
      "help <command>" for help on <command>
      "help <tab>" to get a list of possible help topics
      "quit" to exit
127.0.0.1:6379> help @string

根據提示,可以輸入 help 空格 然後敲tab鍵,可以像命令提示一樣告訴你可以有哪些幫助分組,多敲幾個 tab 試試?
備註說明:

1. 這個版本是Win64的,所以32位windows就不要折騰了。

2. 我的操作系統是Windows 7 64位旗艦版,運行內存16GB,用戶不是Administrator,而是 hasee,所以設置了下 redis-server.exe 和redis-cli.exe 的屬性中的兼容性許可權(以管理員身份運行),如果你運行出錯,可能需要設置一下這裡。

3. 什麼360啊,UAC啊,防火牆啊,該關的請關閉。。。

4. 如果有其他問題,歡迎留言或者評論, 這只是一個心血來潮時的折騰
接觸了好久Redis但一直沒在windows下使用,請輕拍。

附加幾個 bat 批處理腳本,請根據需要靈活配置

service-install.bat

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

uninstall-service.bat

redis-server --service-uninstall

startup.bat

redis-server.exe redis.windows.conf

原文地址:https://www.cnblogs.com/sjy18039225956/p/9199596.html

时间: 2024-08-24 11:52:45

Windows下安裝並設置Redis的相关文章

Windows 10安裝在USB外接硬碟(使用命令模式)

微軟公司已經在2015年7月29日發佈Windows 10正式版,這個版本在使用介面上就像是Windows 7加上Windows 8的組合, 開始鍵與功能列回來了.微軟提供Windows 7與Windows 8或8.1的使用者,可以在一年內免費升級為Windows 10:本文說 明使命令提示模式,將Windows 10安裝在USB外接硬碟的方法: 這個方法需要使用Windows光碟映像檔,映像檔的下載詳見:Windows 10正式版下載.這個方法安裝的系統為傳統的BIOS 主機板MBR硬碟的模式

想用Java開發GAE, 如何建構開發環境, Part1: 安裝及設定Google Plugin

在雲端的時代若想要用最小的成本, 運用雲端來兼具快速佈署.自動平衡負載.高可用性, 高可塑性, Google App Engine (GAE)似乎是一個符合經濟及效益的雲端PaaS平台. 站在Google巨人的肩膀上, 架設雲端的諸多系統上的問題似乎都可以不用煩惱, 營運及開發人員只要專心把服務及產品做好就可以水到渠成. 由於這個例子以Eclipse Java EE來開發 GAE上的應用程式, 重點將擺在環境的安裝與設定, 並以一個事先寫好的Google Data的測試程式來做最終的結果驗證.

在linux環境下安裝jprofiler_linux_8_0_2.sh

1.安装jprofiler_linux_8_0_2.sh chmod+x jprofiler_linux_8_0_2.sh ./jprofiler_linux_8_0_2.sh –c 安装过程略..几乎Enter到底(也可在图形界面下安装不加-c选项,则为图形安装) 2.编辑/etc/profile exportLD_LIBRARY_PATH=/opt/jprofiler8/bin/linux-x64 exportLD_LIBRARY_PATH source/etc/profile 3编辑sta

Windows下安装igbinary、memcache、redis

Windows下安装igbinary.memcache.redis,igbinary是比json.serializer都要快的新的PHP扩展.memcache也是PHP扩展,但是memcached就是C++写的第三方扩展啦,redis和nosql等关系,自己百度吧 Windows,请到http://windows.php.net/去下载! 最后感谢http://my.oschina.net/cart/提供的解决方案! 首先,phpnfo();打印出你本地PHP的信息,比如我的是: PHP Ver

scientific linux 6.x 下安裝 chrome

scientific linux 6.x 不再支援 chrome,連上 google 網站直接下載 chrome 的 rpm 檔案裝,會顯示缺少相依性套件,就算安裝了這些缺的套件,還是會再顯示缺其它套件,陷入一個無窮迴圈! 於是有人寫了安裝 chrome 的 shell script,真是佛心來著!! How to install Google Chrome 28+ on RHEL/CentOS 6 or 7 How to install Google Chrome 28+ on RHEL/Ce

Linux下安裝Oracle database內核參數設置

參考:1529864.1 ************************************************** RAM                                  Swap Space Between 1 GB and 2 GB       1.5 times the size of RAM Between 2 GB and 16 GB      Equal to the size of RAM More than 16 GB                

【Python】Windows, Linux/UNIX, Mac OS X 下安裝 Python

下載地址:https://www.python.org/downloads/ 下載對應系統.對應位數的版本即可. [Windows] 一般選擇"Windows x86-64 executable installer",即 64 位兼容 32 位的可執行安裝程序. 打開安裝程序,先勾選"Add Python X.X to PATH",代表安裝時將 Python 對應版本目錄添加到 PATH 系統環境變量中,再選擇"Customize installation

window下安裝redis服務

一.下载windows版本的Redis github下载地址:https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100   二.将压缩包解压到D盘根目录下,目录名字叫redis,redis包含的文件如下图 三.编辑redis.windows.conf文件 可以看到 bind 127.0.0.1 port 6379 equirepass foobared  这个选项是在连接redis服务器时,需要输入这个密码,默认的配置文

Windows 2019 安裝 VMware tools

1.VMware Workstation 安裝 VMware Tools(類似微軟 Hyper-V 的增強型驅動) 2.D:\setup.exe 3. 4.選擇 SetupX64.exe 5. 6. 7.選擇完整安裝,下一步 8.開始安裝 9. 10.習慣性動作,重啟 10.1.重啟過程與啟動過程,略. 11.安裝完成后,會有一個VM的圖標 12.設備管理器沒有感歎號,任務完成. 原文地址:http://blog.51cto.com/happynews/2154287