1.下载redis
官网链接:https://redis.io/download
[root@localhost packages]# wget https://github.com/antirez/redis/archive/unstable.tar.gz
2.解压下载好的tar.gz文件到指定目录
[root@localhost packages]# tar -zxvf redis-4.0.11.tar.gz -C /usr/
3.编译安装
[root@localhost packages]# yum -y install cmake gcc-c++
[root@localhost packages]# cd /usr/redis-4.0.11/
[root@localhost redis-4.0.11]# make
cd src && make all
make[1]: 进入目录“/usr/redis-4.0.11/src”
CC Makefile.dep
make[1]: 离开目录“/usr/redis-4.0.11/src”
make[1]: 进入目录“/usr/redis-4.0.11/src”
CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录
#include <jemalloc/jemalloc.h>
^
编译中断。
make[1]: *** [adlist.o] 错误 1
make[1]: 离开目录“/usr/redis-4.0.11/src”
make: *** [all] 错误 2
[root@localhost redis-4.0.11]# make MALLOC=libc
4.启动Redis服务
[root@localhost redis-4.0.11]# src/redis-server
5.连接Redis
[root@localhost redis-4.0.11]# src/redis-cli
127.0.0.1:6379>
6.配置允许远程访问Redis
a.打开redis配置文件
[root@localhost redis-4.0.11]# vim redis.conf
b.搜索 bind 127.0.0.1
image.pngc.注释掉 bind 127.0.0.1
image.pngd.设置连接密码
image.png7.配置Redis以守护进程方式启动
a.打开redis配置文件
[root@localhost redis-4.0.11]# vim redis.conf
b.将 daemonize no 改为 daemonize yes
image.pngc.保存并重启Redis服务
[root@localhost redis-4.0.11]# src/redis-server redis.conf
26841:C 09 Sep 16:18:48.012 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
26841:C 09 Sep 16:18:48.012 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=26841, just started
26841:C 09 Sep 16:18:48.012 # Configuration loaded
8.使用密码登陆Redis
[root@localhost redis-4.0.11]# src/redis-cli
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379>
网友评论