编译安装REDIS Alex

官方下载地址:http://download.redis.io/releases/ (可能需要FQ)

一、yum 安装redis

  在centos上需要安装epel源

1.1: 查看yum参考的redis版本

1 yum list redis
2 Loaded plugins: fastestmirror
3 Loading mirror speeds from cached hostfile
4 Installed Packages
5 redis.x86_64                                     3.2.12-2.el7

1.2: 安装redis

1 yum install redis -y
2 systemctl start redis && systemctl enable redis

二、编译安装redis

  下载最新的release版本的redis源码包:http://download.redis.io/releases/ 

    此处选的是5.03版

2.1:编译安装命令:

    官方的安装命令:https://redis.io/download (可能需要FQ)

1 [17:56:23 root@ansible src]$pwd
2 /usr/local/src

2.2:解压刚刚下载的源码包到当前目录:

1 tar xf redis-5.0.3.tar.gz

2.3:开始安装

1 cd redis-5.0.3
2 make PREFIX=/usr/local/redis install

#此处可能报错,可能是因为没安装这些

1 yum -y install gcc gcc-c++ libstdc++-devel

如报错下图的问题,需要执行这行命令:

1 make MALLOC=libc

 原因分析:

在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

说关于分配器allocator, 如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。

而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。

但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数

2.4 :前台启动redis:

1 /usr/local/redis/bin/redis-server  /usr/local/redis/etc/redis.conf

 2.5: 解决当前的警告提示

    

------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------- 博客均为个人笔记,无所追求,仅供参考~~~ QQ--2382990774
原文地址:https://www.cnblogs.com/alexlv/p/14459876.html