下载并安装
环境:centos7 64位,新安装的虚拟机
$ wget http://download.redis.io/releases/redis-3.2.1.tar.gz
$ tar xzf redis-3.2.1.gz
$ cd redis-3.2.1
编译
$ make
错误1: /bin/sh: cc: command not found
[redis@localhost redis-3.2.1]$ make
cd src && make all
make[1]: Entering directory `/home/redis/Desktop/redis-3.2.1/src'
CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/home/redis/Desktop/redis-3.2.1/src'
make: *** [all] Error 2
==这是一台新部署的linux环境,缺少C语言环境,所以需要安装gcc==
[redis@localhost redis-3.2.1]$ sudo yum install gcc
# 一直Y,出现Complete!表示安装成功
Dependency Updated:
glibc.x86_64 0:2.17-106.el7_2.8 glibc-common.x86_64 0:2.17-106.el7_2.8
Complete!
继续编译:
[redis@localhost redis-3.2.1]$ make
cd src && make all
make[1]: Entering directory `/home/redis/Desktop/redis-3.2.1/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 `/home/redis/Desktop/redis-3.2.1/src'
make: *** [all] Error 2
错误2:error: jemalloc/jemalloc.h: No such file or directory
redis 环境变量 ==MALLOC== 默认的是 MALLOC=jemalloc, 我们的虚拟机中可能没有 jemalloc所以需要改为 libc
- 解决:修改分配器,使用下面的命令
make MALLOC=libc
然后,根据提示执行make或make test,发现又出问题了,
错误3: You need tcl 8.5 or newer in order to run the Redis test
可能是版本太高导致的吧,没办法,强迫症,有新的稳定版的的出现,肯定会去用新的。
[redis@localhost redis-3.2.1]$ make test ,
cd src && make test
make[1]: Entering directory `/home/redis/Desktop/redis-3.2.1/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/home/redis/Desktop/redis-3.2.1/src'
make: *** [test] Error 2
- 解决:升级 tcl 喽
按顺序,分别执行以下命令
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
sudo tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
make test
如果,不想在执行make操作时,出现这么多问题,先执行make test检测当前环境,提前解决这些问题也不错。
# make test
...# 经过漫长的检测,出现如下文字,则表示环境没问题,可以安装了
\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory `/home/redis/Desktop/redis-3.2.1/src'
如果make test正常,但是还会出现一些奇葩问题,可以考虑重新解压,重新安装
执行完make命令后,进入 src目录执行启动命令
$ ./redis-server # 启动服务
再打开一个窗口,执行
$ ./redis-cli #启动客户端
查看进程
- 检测redis进程
ps -ef|grep redis
- 检测端口
netstat -lntp | grep 6379