centos7安装redis3.2.5

安装redis

1官方介绍

Installation

Download, extract and compile Redis with:

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

The binaries that are now compiled are available in the src directory. Run Redis with:

$ src/redis-server

You can interact with Redis using the built-in client:

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
2 我的安装流程
2.1下载http://redis.io/见官网
2.2解压、编译(make)
[root@localhost ~]# tar xzf redis-3.2.5.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg  redis-3.2.5  redis-3.2.5.tar.gz 
[root@localhost ~]# cd redis-3.2.5
[root@localhost redis-3.2.5]# make

2.2.1最小化安装的centos,默认没装gcc。

会有如下错误:   安装gcc即可  [root@localhost redis-3.2.5]#yum install -y gcc  

[root@localhost redis-3.2.5]# make
cd src && make all
make[1]: Entering directory `/root/redis-3.2.5/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/root/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/root/redis-3.2.5/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb   -I../deps/geohash-int -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua geohash-int jemalloc)
make[2]: Entering directory `/root/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/root/redis-3.2.5/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/root/redis-3.2.5/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/root/redis-3.2.5/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/root/redis-3.2.5/src'
make: *** [all] Error 2
[root@localhost redis-3.2.5]# 

2.2.2会出现如下错误:

[root@localhost redis-3.2.5]# make
cd src && make all
make[1]: Entering directory `/root/redis-3.2.5/src'
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
                               ^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/redis-3.2.5/src'
make: *** [all] Error 2

解决方法:[root@localhost redis-3.2.5]# 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

2.2.3会出现如下错误:

其他可能问题:

如果提示couldn’t execute tcl : no such file or dicrectory,请自行安装tcl;

如果提示#error "Newer version of jemalloc required",请执行make distclean,然后再make

2.3 make install

[root@localhost ~]# cd /usr/local/bin
[root@localhost bin]# ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server

会安装到 系统默认路径/usr/local/bin下。当然,也可以自行拷贝他们到该路径!

2.4 安装结果验证

[root@localhost bin]# redis-server -v
Redis server v=3.2.5 sha=00000000:0 malloc=libc bits=64 build=a980a4204e401fc7
[root@localhost bin]# pwd
/usr/local/bin
[root@localhost bin]# 

 2.5 启动

 ./redis-server redis.conf

原文地址:https://www.cnblogs.com/felixzh/p/6068085.html