windows redis 集群搭建(一)

  • 本文第一篇主要介绍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个就够:

 

?
1
2
3
4
gcc: C complier upgrade helper 
   gcc-core:C 编译器 gcc-g++:
   C++ 编译器 gdb:GNU 调试器 
   make: "make"  实用程序的 GNU 版本


具体如何安装,自己百度脑补,不多说了,这个安装时间较长,可以干点其他的了。


  •  四、检查编译环境  

?
1
2
3
4
5
6
7
8
9
10
11
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

   编译源码:    

?
1
2
3
cd  ..
make  &&  make  install
...此处省略一万字(祈祷吧)

   佛祖保佑成功的话,你就就编译成功了,开启redis服务试下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ 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

  执行文件的位置:

?
1
2
3
4
5
6
7
8
9
10
11
12
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文件的位置:

?
1
2
3
cd  /bin
find  . -maxdepth 1 -name  "cygwin1.dll"
. /cygwin1 .dll

  • 六、提取,使其在window下运行


目前是在cygwin下运行,我们要把他弄出来,在windows下运行

进入cygwin控制端口.

?
1
2
3
4
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命令:

?
1
2
3
4
#启动
redis-server.exe redis.conf
#本地客户端进入
redis-cli.exe -h 127.0.0.1 -p 6379

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值