標籤:blog http ar io os 使用 sp for strong
Windows下安裝並設定Redis分類: Redis2014-08-10 22:19 3012人閱讀 評論(2) 收藏 舉報Residwindows安裝設定問題
作者: 鐵錨
日期: 2014年8月10日
Redis對於Linux是官方支援的,安裝和使用沒有什麼好說的,普通使用按照官方指導,5分鐘以內就能搞定。詳情請參考:
http://redis.io/download
但有時候又想在windows下折騰下Redis,可以從redis下載頁面看到如下提示:
[plain] view plaincopy
- 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
下載解壓,沒什麼好說的,在解壓後的bin目錄下有以下這些檔案:
[plain] view plaincopy
- 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種方法 】
網上參考了一些資料,發覺可以使用,也就沒有深究,直接拿來主義:
啟動指令碼如下:
[plain] view plaincopy
- redis-server redis.windows.conf
可以將其儲存為檔案
startup.bat ; 下次就可以直接啟動了。
但是在cmd之中執行這行命令之後報錯:
[plain] view plaincopy
- 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 , 然後直接指定好內容即可.
[plain] view plaincopy
- .......
- #
- # maxheap <bytes>
- maxheap 1024000000
- .......
然後再次啟動,OK,成功.
[plain] view plaincopy
- 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命令:
[plain] view plaincopy
- 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查看,例如:
[plain] view plaincopy
- 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
[plain] view plaincopy
- redis-server.exe --service-install redis.windows.conf --loglevel verbose
uninstall-service.bat
[plain] view plaincopy
- redis-server --service-uninstall
startup.bat
[plain] view plaincopy
- redis-server.exe redis.windows.conf
我在這個群裡,該群有大量高手潛伏,歡迎加入: 點選連結加入群【redis兩千人總群】
Windows下安裝並設定Redis