windows redis 集群搭建(一)
Redis 是比較著名的nosql 了,可以拿來當數據用也可以當緩存用,由于他支持的數據類型比memcache多,當緩存也不錯,既然牽扯到緩存,大數據的情況下需要做集群處理,目前 redis也支持,不過還沒有發布release版本(目前穩定版最高是2.8.19),Redis 集群目前處于Alpha測試階段 ,所以想要用他的集群版本的,需要自己編譯處理下了,linux下的編譯比較簡單,windows下的比較繁瑣,在此做個簡單描述。
本文第一篇主要介紹redis在windows平臺下的編譯。
-
一、下載cygwin
cygwin是windows平臺上的posix系統模擬環境,具體的版本,請根據自己當前系統的版本來,我的系統是windows7 64位。
點擊下載最新的:setup-x86_64.exe
cygwin官網:http://www.cygwin.com/
-
二、下載最新版redis
redis的版本根據自己的需求來,因為我們要搭建集群,所以下載 3.0.0beta版
-
三、安裝cygwin
cygwin的安裝網上有不少圖解(猛擊:圖解教程),直接下一步就好,需要主要的一點是注意選擇好自己需要的包,如下圖:
你會看到Dvel下有許多入庫,其中只需要安裝5個就夠:
gcc: C complier upgrade helper gcc-core:C 編譯器 gcc-g++: C++ 編譯器 gdb:GNU 調試器 make:"make" 實用程序的 GNU 版本
具體如何安裝,自己百度腦補,不多說了,這個安裝時間較長,可以干點其他的了。
-
四、檢查編譯環境
$ gcc -v 使用內建 specs。 COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/lto-wrapper.exe 目標:x86_64-pc-cygwin 線程模型:posix gcc 版本 4.8.3 (GCC) $ make -v GNU Make 4.0 Built for x86_64-pc-cygwin
在cygwin的控制端上,看到gcc和make都安裝成功。
redis源碼的處理,編譯前,進入到redis的src目錄,在第一個#define前增加以下代碼。
/* Cygwin Fix */ #ifdef __CYGWIN__ #ifndef SA_ONSTACK #define SA_ONSTACK 0x08000000 #endif #endif
-
-
五、編譯
我們先看下redis源碼的目錄:
來,先編譯依賴包:
$ cd deps $ make lua hiredis linenoise
編譯源碼:
cd .. make && make install ...此處省略一萬字(祈禱吧)
佛祖保佑成功的話,你就就編譯成功了,開啟redis服務試下
$ redis-server.exe [3232] 30 Dec 15:40:05.171 # Warning: no config file specified, using the defaul t config. In order to specify a config file use redis-server /path/to/redis.conf [3232] 30 Dec 15:40:05.202 # Unable to set the max number of files limit to 1003 2 (Too many open files), setting the max clients configuration to 3088. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.9.50 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 3232 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [3232] 30 Dec 15:40:05.222 # Server started, Redis version 2.9.50 [3232] 30 Dec 15:40:05.222 * The server is now ready to accept connections on po rt 6379
以上就ok了,默認端口:6379
執行文件的位置:
$ cd /usr/local/bin wier@wier-PC /usr/local/bin $ ls -al 總用量 3380 drwxr-xr-x+ 1 wier None 0 十二 30 15:37 . drwxr-xr-x+ 1 wier None 0 十二 26 18:39 .. -rwxr-xr-x 1 wier None 350267 十二 30 15:37 redis-benchmark.exe -rwxr-xr-x 1 wier None 88725 十二 30 15:37 redis-check-aof.exe -rwxr-xr-x 1 wier None 118232 十二 30 15:37 redis-check-dump.exe -rwxr-xr-x 1 wier None 441669 十二 30 15:37 redis-cli.exe -rwxr-xr-x 1 wier None 2449805 十二 30 15:37 redis-server.exe
cygwin1.dll文件的位置:
$ cd /bin $ find . -maxdepth 1 -name "cygwin1.dll" ./cygwin1.dll
-
-
六、提取,使其在window下運行
目前是在cygwin下運行,我們要把他弄出來,在windows下運行
進入cygwin控制端口.
$ cd e: $ mkdir redis3.0 $ cp -r /usr/local/bin/* e:/redis3.0 $ cp -r /bin/cygwin1.dll e:/redis3.0
上面依次是進入e盤,創建redis3.0目錄,拷貝編譯后文件到redis3.0目錄。
在windows下可以看到
如此就可以在windows下執行了,現在可以把源碼下面的配置文件redis.conf拷貝到當前文件夾下,如此,可以隨意搭建自己的配置了。
redis命令:
#啟動 redis-server.exe redis.conf #本地客戶端進入 redis-cli.exe -h 127.0.0.1 -p 6379
來自:http://my.oschina.net/u/1859679/blog/362327