1.redis-windows
最近在做一個搶拍模塊,由於過於平凡的insert與update I/O受不了,故只好把東西放內存里,等拍賣結束了,在寫入磁盤.
至於為什么要用window呢? 因為服務器上的就是window的,沒的選.
一打開官網就看到一些不怎么開心的東西.
Win64 Unofficial The Redis project does not directly support Windows, however the Microsoft Open Tech group develops and maintains an Windows port targeting Win64. Clone Other downloads are available on GitHub, Historical downloads are available on Google Code.
Scripts and other automatic downloads can easily access the tarball of the latest Redis stable version athttp://download.redis.io/redis-stable.tar.gz. The source code of the latest stable release is always browsable here, use the file src/version.h in order to extract the version in an automatic way.
但我去下載下來之后發現跟它本身那個沒啥區別,該咋樣,還咋樣, 而且讓我惡心的是它的描述文件讓我很蛋疼,:
Where to find complete Redis documentation? ------------------------------------------- This README is just a fast "quick start" document. You can find more detailed documentation at http://redis.io Building Redis -------------- Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD. We support big endian and little endian architectures. It may compile on Solaris derived systems (for instance SmartOS) but our support for this platform is "best effort" and Redis is not guaranteed to work as well as in Linux, OSX, and *BSD there. It is as simple as: % make You can run a 32 bit Redis binary using: % make 32bit After building Redis is a good idea to test it, using: % make test Fixing problems building 32 bit binaries ...
算了,反正官方也說了它是非官方,不影響我使用就是了,我們也不該那么吊!
下載完后, 我們照着它的文檔做:
How to build Redis using Visual Studio
You can use the free Visual Studio Express 2013 for Windows Desktop edition available athttp://www.microsoft.com/en-us/download/details.aspx?id=40787.
Open the solution file msvs\redisserver.sln in Visual Studio 2013, select a build configuration (Debug or Release) and target (Win32 or x64) then build.
This should create the following executables in the msvs\$(Target)\$(Configuration) folder:
- redis-server.exe
- redis-benchmark.exe
- redis-cli.exe
- redis-check-dump.exe
- redis-check-aof.exe
編譯我選擇 release-64bit 的版本,如下:
找到他的輸出目錄一般是在 msvs\x64\Release 目錄下, 把其他一下非exe 的文件全干掉, 剩下如下幾個:
然后我們把我們下載下來的那個壓縮包中的redis.conf 拿出來,放在我們生產的目錄中,用命令打開:
F:\redis-2.8>redis-server.exe redis.conf [9668] 17 Sep 17:08:31.549 # 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 'heapdir' 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 moving the heap file to a local drive with sufficient space. Please see the documentation included with the binary distributions for more details on the --maxheap and --heapdir flags. Redis can not continue. Exiting.
根據提示,是 maxheap 標識有問題, 這個是因為位置文件中少了個配置:
我們在 redis.conf 頭部加入一行
maxheap 1024000000
如:
# Redis configuration file example # Note on units: when memory size is needed, it is possible to specify # it in the usual form of 1k 5GB 4M and so forth: # # 1k => 1000 bytes # 1kb => 1024 bytes # 1m => 1000000 bytes # 1mb => 1024*1024 bytes # 1g => 1000000000 bytes # 1gb => 1024*1024*1024 bytes # # units are case insensitive so 1GB 1Gb 1gB are all the same. ################################## INCLUDES ################################### # Include one or more other config files here. This is useful if you # have a standard template that goes to all Redis server but also need # to customize a few per-server settings. Include files can include # other files, so use this wisely. # # Notice option "include" won't be rewritten by command "CONFIG REWRITE" # from admin or Redis Sentinel. Since Redis always uses the last processed # line as value of a configuration directive, you'd better put includes # at the beginning of this file to avoid overwriting config change at runtime. # # If instead you are interested in using includes to override configuration # options, it is better to use include as the last line. # # include /path/to/local.conf # include /path/to/other.conf ################################ GENERAL ##################################### maxheap 1024000000 # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize no ...
然后再次啟動:
F:\redis-2.8>redis-server.exe redis.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.16 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 9316 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [9316] 17 Sep 17:38:27.776 # Server started, Redis version 2.8.16 [9316] 17 Sep 17:38:27.776 * The server is now ready to accept connections on po rt 6379
雙擊打開 redis-cli.exe , 如果不報錯,則連接上了本地服務器,然后測試,比如 set命令,get命令:
很明顯, 哥成功了, 也祝大家好運
注意:
1. 這個版本是Win64的,所以32位windows就不要折騰了。
2. 我的操作系統是Windows 7 64位旗艦版,運行內存16GB,用戶 是Administrator ,如果你不是,可能需要設置下 redis-server.exe 和redis-cli.exe 的屬性中的兼容性權限(以管理員身份運行) .
3. 什么360啊,UAC啊,防火牆啊,該關的請關閉。。。
如果你懶得親自動手,可以點這里 : 點擊下載