安装
1、检查是否安装了redis
[[email protected]location ~]# rpm -qa | grep redis
2、下载redis
官网地址:http://redis.io/ 我下的版本:redis-4.0.10.tar.gz
下载地址http://download.redis.io/releases/redis-4.0.10.tar.gz
3.创建文件夹
[[email protected]location ~]# mkdir /java
4. 解压
把下载的redis-4.0.10.tar.gz传输到java文件下
[[email protected]location ~]# cd /java
[[email protected] java]# tar xzf redis-4.0.10.tar.gz
[[email protected] java]# cd /java/redis-4.0.10
[[email protected] redis-4.0.10]# make
当出现下面错误是未安装c编译器报以下错误
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/java/redis-4.0.10/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/java/redis-4.0.10/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 `/java/redis-4.0.10/src'
make: *** [all] Error 2
5. 安装c编译器并编译
[[email protected] redis-4.0.10]# cd ~
[[email protected] ~]# yum -y install make gcc gcc-c++ ncurses-devel
[[email protected] ~]# cd /java/redis-4.0.10/src
[[email protected] src]# make test
CC Makefile.dep
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: *** [adlist.o] Error 1
解决“jemalloc/jemalloc.h:没有那个文件或目录“问题,在进行编译(因为上次编译失败,有残留的文件)
[[email protected] src]# cd /java/redis-4.0.10
[[email protected] redis-4.0.10]# make distclean
[[email protected] redis-4.0.10]# make && make install
出现以下配置成功:
6. 修改配置文件
[[email protected] redis-4.0.10]# cp redis.conf redis.conf.bak
[[email protected] redis-4.0.10]# vim redis.conf
将 daemonize 默认的 no 改成 yes ---> redis 服务后台运行
7. 启动服务
[[email protected] redis-4.0.10]# cd /usr/local/bin/
[[email protected] bin]# redis-server /java/redis-4.0.10/redis.conf
8. 启动客户端测试
[[email protected] bin]# redis-cli -p 6379
127.0.0.1:6379> set a 1
OK
127.0.0.1:6379> get a
"1"
127.0.0.1:6379>
参考链接:
https://www.cnblogs.com/jerrylz/p/5650213.html
https://www.linuxidc.com/Linux/2017-09/146894.htm
https://www.cnblogs.com/KunGe-13/p/8340309.html