天天看点

CentOS7/RHEL7安装Redis

方法一:使用命令安装(前提是已经安装了EPEL)

EPEL,即Extra Packages for Enterprise Linux的简称,是为企业级Linux提供的一组高质量的额外软件包,包括但不限于Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux (OEL)

自动安装epel:

yum -y install epel-release

手动安装epel:

或者

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

rpm -vih epel-release-7-2.noarch.rpm

更新包缓存

此时我们发现/etc/yum.repos.d/下多了两个epel的repo文件

ll /etc/yum.repos.d/

更新元数据缓存:

yum clean all && yum makecache

1、安装redis

yum -y install redis

2、启动服务

<b>说明:启动服务前修改/etc/redis.conf文件的bing地址(默认127.0.0.1) 否则 远程电脑无法连接</b>

systemctl start redis.service

方法二:编译安装

# wget http://download.redis.io/releases/redis-2.8.17.tar.gz

# tar -zxvf redis-2.8.17.tar.gz

# cd redis-2.8.17

# make

# make install

设置配置文件路径:

# mkdir -p /etc/redis &amp;&amp; cp redis.conf /etc/redis

修改配置文件:

# vim /etc/redis/redis.conf

修改为: daemonize yes

启动Redis:

# /usr/local/bin/redis-server /etc/redis/redis.conf

#关闭服务

redis-cli shutdown

或者在cli中执行shutdown

redis 127.0.0.1:6379&gt; shutdown

清除缓存

redis-cli flushall

更多文档请参考软件包内的“README”文件。

查看状态 :

# ss -nlp|grep redis

关于ss命令,参考这里。

# ps -ef | grep redis

本文转自 yntmdr 51CTO博客,原文链接:http://blog.51cto.com/yntmdr/1619416,如需转载请自行联系原作者

继续阅读