在win平台下编译Redis一般有两种方式:

1. 基于MS VC进行编译,生成原生可执行文件

该方式需要创建MSVC项目文件以及对Redis源码进行适当调整。 这里提供一个可行版本,由微软开放团队进行维护,目前版本是Redis 2.6, 有MS VC的朋友可以尝试一下: 猛击:https://github.com/MSOpenTech/redis

2. 基于Cygwin进行编译

Cygwin是运行在windows平台上的POSIX系统(例如unix,linux,bsd)模拟环境,为我们提供编译环境。

本文将以Cygwin方式进行Redis最新版本的编译,即2.8.3版,这里先说明一下编译环境:

Windows 7 64位 + Cygwin 64位(已安装好gcc 4.8.1 及 make环境)

下面进行详细描述:

1. 安装Cygwin(需要4~6G disk space)

其安装过程时间会较长,大家可以先去干一些喜欢做的事情,安装过程就省略了

2. 运行Cygwin,检查编辑译环境

$ gcc -v
...
Target: x86_64-pc-cygwin
...
Thread model: posix
gcc version 4.8.1 (GCC) $ make -v
GNU Make 4.0
Built for x86_64-pc-cygwin
...

3. 下载Redis,对Redis进行适当修改

下载:

$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar -zxvf redis-2.8.3.tar.gz
$ cd redis-2.8.3

若要顺利编译,需要对redis.h进行修改:

$ vi src/redis.h

在第一个#define前增加以下代码,解决"debug.c: 790:37: error: 'SA_ONSTACK' undeclared (first use in this function)"错误

/* Cygwin Fix */
#ifdef __CYGWIN__
#ifndef SA_ONSTACK
#define SA_ONSTACK 0x08000000
#endif
#endif

注:redis-2.8.3只需要进行上述修改即可顺利编译, redis-3.0.1 需要更新net.c文件,如下:

vi /deps/hiredis/net.c

在 #include "sds.h"后增加以下代码

/* Cygwin Fix */
#ifdef __CYGWIN__
#define TCP_KEEPCNT 8
#define TCP_KEEPINTVL 150
#define TCP_KEEPIDLE 14400
#endif

4. 编译与运行

先编译依赖包

$ cd deps
$ make lua hiredis linenoise
$ cd ..

然后编译主项目

$ make && make install
...
$ redis-server
[7920] 21Dec16:49:07.336 # Warning: no config file specified, using the default config. Inorderto specify a config file use redis-server /path/to/redis.conf
[7920] 21Dec16:49:07.338 # Unable toset the maxnumberof files limitto10032 (Too many open files), setting the max clients configuration to3088.
_._
_.-``__ ''-._
_.-```. `_. ''-._ Redis 2.8.3 (00000000/0) 64bit
.-`` .-` `. ` `\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 7920
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[7920] 21Dec16:49:07.351 # Server started, Redis version2.8.3
[7920] 21Dec16:49:07.351 * The serverisnow ready to accept connections on port 6379
$ redis-server.exe
8172:C 16 May 17:51:01.316 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
8172:M 16 May 17:51:01.322 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
8172:M 16 May 17:51:01.322 # Redis can't set maximum open files to 10032 because of OS error: Too many open files.
8172:M 16 May 17:51:01.322 # Current maximum open files is 3200. maxclients has been reduced to 3168 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.1 (00000000/0) 64 bit
.-`` .-``. ``\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8172
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'`-._ _.-'
`-.__.-' 8172:M 16 May 17:51:01.404 # Server started, Redis version 3.0.1
8172:M 16 May 17:51:01.410 * DB loaded from disk: 0.006 seconds
8172:M 16 May 17:51:01.410 * The server is now ready to accept connections on port 6379

成功的话可以看到以上信息,可执行下文件默认安装到/usr/local/bin下。

5. 提取依赖库,使其可以在Cygwin之外运行

最后,若需要在Cygwin之外运行,还需要拷贝/bin下的cygwin1.dll文件,这里提供一个已打包好的版本(64位,对于32位的朋友只能说sorry了) 猛击:redis-2.8.3-win64.7z | redis-3.0.1-win64.7z

http://xxk.b3log.org/articles/2015/08/21/1440141912836.html

转载 http://my.oschina.net/maxid/blog/1

http://hacpai.com/article/144014475291886506

Windows Cygwin Redis 安装(转)的更多相关文章

  1. windows下Redis安装及利用java操作Redis

    一.windows下Redis安装 1.Redis下载 下载地址:https://github.com/MicrosoftArchive/redis 打开下载地址后,选择版本 然后选择压缩包 下载 R ...

  2. windows下redis安装和配置

    windows下redis安装和配置 redis介绍 Redis是一个开源,高级的键值存储和一个适用的解决方案,用于构建高性能,可扩展的Web应用程序. Redis有三个主要特点,使它优越于其它键值数 ...

  3. Windows下Redis安装配置和使用注意事项

    Windows下Redis安装配置和使用注意事项 一:下载 下载地址: https://github.com/microsoftarchive/redis/releases 文件介绍: 本文以3.2. ...

  4. windows下redis安装及配置

    1.简介: redis是一个高性能的key-value数据库:redis能读的速度为11万次/秒,写的速度是8.1万次/秒 redis支持丰富的数据类型:String, List, Hash(map) ...

  5. Windows下Redis安装及使用

    1.下载安装Redis(安装直接下一步就行,此步骤省略) Redis-x64-3.2.100.exe 2.Redis使用 安装目录如下: ①cmd启动redis: ②将redis安装为服务 此时如果安 ...

  6. Windows下Redis安装+可视化工具Redis Desktop Manager使用

    Redis是有名的NoSql数据库,一般Linux都会默认支持.但在Windows环境中,可能需要手动安装设置才能有效使用.这里就简单介绍一下Windows下Redis服务的安装方法,希望能够帮到你. ...

  7. windows下redis安装

    最近因公司项目原因,去了趟昆明出差,其中第一次接触安装redis,配置sentinel,学习到不少,但也都是皮毛而已,本随笔记下所学知识. 1.首先介绍下redis,来源自百度百科 redis是一个k ...

  8. windows下redis安装及应用

    一.下载安装Redis(windows版本) 1.下载地址:https://github.com/MicrosoftArchive/redis/releases 2.安装: 1)打开运行窗口,输出cm ...

  9. 1.windows下Redis安装

    参考文档:https://www.cnblogs.com/Leo_wl/p/6392196.html?utm_source=itdadao&utm_medium=referral Redis数 ...

随机推荐

  1. POJ 3100 & ZOJ 2818 & HDU 2740 Root of the Problem(数学)

    题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http ...

  2. DevExpress控件中LayoutControl的使用

    原文:DevExpress控件中LayoutControl的使用 C#开发中,软件布局设计,主要用TableLayoutPanel能很好地支持缩放功能,对自身的Label.TextBox等控件支持的很 ...

  3. web网站架构

    浅谈web网站架构演变过程   前言 我们以javaweb为例,来搭建一个简单的电商系统,看看这个系统可以如何一步步演变.   该系统具备的功能:   用户模块:用户注册和管理 商品模块:商品展示和管 ...

  4. 左右xcode的重构选项的一些理解

    Rename(重命名):对标示符进行重命名,以获得更好的代码可读性,这些标示符包含类,方法或者函数的名称. Extract(抽取):将你在XCode种选择的代码抽取到一个新的方法或函数中. Creat ...

  5. [ACM] HDU 3395 Special Fish (最大重量二分图匹配,KM算法)

    Special Fish Problem Description There is a kind of special fish in the East Lake where is closed to ...

  6. SQL 修改排序规则的问题 sql_latin1_general_cp1_ci_as

    在一个项目中遇到:用原来的数据库生成的脚本,然后部署到新的服务器上,数据库的SQL_Latin1_General_CP1_CI_AS 怎么查询出来汉字都是乱码了. 遂查解决方法. 需要执行这个 ALT ...

  7. 好玩的WPF第二弹:电子表字体显示时间+多彩呼吸灯特效button

    我们先来看看Quartz MS字体动态显示系统时间的效果,难度相较于上一篇也要简单很多. 首先是定义一个TextBlock例如以下. <Grid> <TextBlock Name=& ...

  8. 乐在其中设计模式(C#) - 建造者模式(Builder Pattern)

    原文:乐在其中设计模式(C#) - 建造者模式(Builder Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 建造者模式(Builder Pattern) 作者:webabc ...

  9. 排序算法门外汉理解-Shell排序

    #include <stdio.h> /* 希尔排序 基本思想:希尔排序又称为缩小增量排序,对简单插入排序的优化. (外部分组gap,组内部插入排序! ! ) 特点:一种不稳定的排序 */ ...

  10. 【Bible for kids】 儿童圣经 App

    [Bible for kids] 儿童圣经App 除了<The Bible>这个由YouVersion团队开发的全球下载量和安装数目第一的圣经类.安装量已逾1亿8千万的App之外,YouV ...