第一步:redis下载
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
第二步:解压
tar xzf redis-4.0.6.tar.gz
第三步:redis.conf修改
cd redis-4.0.6
vi redis.conf
设置密码:requirepass 123456 ----注释取消掉设置账号密码
注释掉: bind 127.0.0.1
daemonize no 改为daemonize yes — 修改为yes 后台启动
第四步:使用make命令进行编译
进入解压后的目录:[root@localhost redis]# cd redis-4.0.6
编译:[root@localhost redis-4.0.6]# make
如果报错:redis编译报致命错误:jemalloc/jemalloc.h:没有那个文件或目录
执行如下命令:[root@localhost redis-4.0.6]# make MALLOC=libc
make【编译安装时候如果出现:"make:*** No targets specified and no makefile found.Stop."这样的错误提示】
问题解决方案(二种方式)
第一、update最新版本系统软件
yum update
这个必须要执行后才可以安装我们的系统软件或者一键包
第二、编译缺失关联软件
yum install gcc build-essential
编译执行完毕之后,我们在执行./configure && make这类的执行命令就可以解决问题。
第五步:安装Redis
进入Redis下的src目录:[root@localhost redis-3.2.9]# cd src
安装:[root@localhost src]# make install
关闭防火墙【可以不关闭】
systemctl stop firewalld.service
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
第六步:启动Redis
[root@localhost src]# ./redis-server 或 ./redis-server /home/redis-4.0.6/redis.conf
注解:如果更改redis.con文件需要从新编译并启动
指定redis.conf文件重新启动:
[root@localhost redis-4.0.6]# src/redis-server redis.conf
启动Redis客户端
进入到src下,
[root@localhost src]# ./redis-cli -h 127.0.0.1 -p 6379 -a “123456”
-h:ip地址
-p:端口号
-a:密码
使用ping命令,查看客户端是否连接到Redis服务器
[root@localhost src]# ./redis-cli -h 127.0.0.1 -p 6379 -a “123456”
127.0.0.1:6379> ping
PONG
出现PONG,说明连接成功。
使用info命令 ,查看相关信息,如redis服务器,redis客户端信息等。
127.0.0.1:6379> info
停止redis
redis-cli shutdown 或者 kill redis进程的pid