Home  >  Article  >  Database  >  RedHat Linux下Redis安装

RedHat Linux下Redis安装

WBOY
WBOYOriginal
2016-06-07 16:00:191066browse

我用的Linux系统是:RedHat [root@infa ~]# wget http://download.redis.io/releases/redis-2.8.12.tar.gz tar xzf redis-2.8.1

我用的Linux系统是:RedHat

[root@infa ~]# wget

RedHat Linux下Redis安装

tar xzf redis-2.8.12.tar.gz

[root@infa ~]# tar xzf redis-2.8.12.tar.gz

[root@infa ~]# cd redis-2.8.12

[root@infa redis-2.8.12]# ls

00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README  redis.conf  runtest  runtest-sentinel  sentinel.conf  src  tests  utils

[root@infa redis-2.8.12]# make

但是这样子编译会报错,貌似是因为系统的原因;

报错如下:

解决方法,就是加上编译参数设置,如下:

[root@infa redis-2.8.12]# make CFLAGS="-march=i686"

RedHat Linux下Redis安装

编译成功;

启动并运行redis:

[root@infa redis-2.8.12]# src/redis-server

RedHat Linux下Redis安装

打开另外一个终端运行,redis客户端

RedHat Linux下Redis安装

[root@infa redis-2.8.12]# src/redis-cli

127.0.0.1:6379> set name chenzhou

OK

127.0.0.1:6379> get name

"chenzhou"

127.0.0.1:6379>

RedHat Linux下Redis安装

附2:把Redis作为Linux服务开机启动
这里只提供一种最简单的方式,最好的是通过编写开机启动脚本来做。
如果要开机启动redis,我们需要把redis设置为daemon后台启动(如果不设置为后台启动,则linux启动后图形界面会卡在一个空白的页面),而redis只有1个启动参数,就是redis的配置文件路径。redis的默认配置文件redis.conf位于redis的安装目录下。我们可以把该文件copy到/etc目录下
Shell代码 
1[root@localhost redis-2.6.14]# cp redis.conf /etc/ 
redis的默认配置文件中daemonize参数的值为no,代表为非后台启动,所以我们需要把该参数的值修改为yes。至于其它的参数在这里就不详细说了,具体可以参见:
修改完daemonize参数之后,redis就能够通过daemon方式启动了,那么下一步就是把redis加入到linux开机启动服务配置中了,具体步骤如下:
使用VI编辑器打开Linux开机启动服务配置文件/etc/rc.local,并在其中加入下面的一行代码:
Shell代码 
2/usr/local/redis-2.6.14/src/redis-server /etc/redis.conf 
编辑完后保存,然后重启系统就OK了。
停止Redis服务:
Shell代码 
3src/redis-cli shutdown

Ubuntu 14.04下Redis安装及简单测试

Redis集群明细文档

Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis

Redis系列-安装部署维护篇

CentOS 6.3安装Redis

Redis安装部署学习笔记

Redis配置文件redis.conf 详解

Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里

本文永久更新链接地址

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn