Centos7安装redis详细

第一步: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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值