下面的内容是基于redis 5.0.5 如果是其他版本,请查看官方文档。https://redis.io/download

1.1.1. 一、linux下安装。

1、下载、解压、编译Redis。

$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz
$ tar xzf redis-5.0.5.tar.gz
$ cd redis-5.0.5
$ make

2、进入到解压后的src目录,通过如下命令启动Redis:

$ src/redis-server

3、使用内置的客户端与Redis进行交互。

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

redis提供了一个web页面,是在线的redis客户端和服务器,可以体验一下redis的各种命令。地址: http://try.redis.io/

4、安装过程中的错误:

  • 在VMware中安装redis时出现了gcc未找到错误。

解决方案:

首先确保root登录,如果是$标识则表示是普通用户登录;#表示是root用户。然后进行安装 安装命令:

yum -y install gcc automake autoconf libtool make

  • zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录。

解决方法,使用libc:make MALLOC=libc

发生的原因:在redis的解压包下有个README文件,打开这个文件有下面一段话。

Allocator
---------

Selecting a non-default memory allocator when building Redis is done by setting
the `MALLOC` environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

    % make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

    % make MALLOC=jemalloc

Verbose build
-------------

说的是关于分配器allocator, 默认情况下,Redis使用jemalloc编译和链接的, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。但是如果你没有jemalloc 而只有 libc 当然 make 出错。如果有MALLOC 这个 环境变量,会有用这个环境变量的 去建立Redis。

results matching ""

    No results matching ""