方法一:使用命令安装(前提是已经安装了EPEL)。
 
安装redis:
 
yum -y install redis
 
启动/停止/重启 Redis
 启动服务:
 1
 systemctl start redis.service
 停止服务:
 
systemctl stop redis.service
 
重启服务:

systemctl restart redis.service
 
检查状态:

[root@idoseek ~]# systemctl status redis.service
 redis.service - Redis persistent key-value database
    Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled)
    Active: active (running) since 二 2014-10-21 21:37:22 EDT; 5h 26min ago
  Main PID: 30413 (redis-server)
    CGroup: /system.slice/redis.service
            └─30413 /usr/bin/redis-server 127.0.0.1:6379
  
 10月 21 21:37:22 idoseek.com systemd[1]: Started Redis persistent key-value database.
 
随系统启动服务:

[root@idoseek ~]# systemctl enable redis.service
 ln -s '/usr/lib/systemd/system/redis.service' '/etc/systemd/system/multi-user.target.wants/redis.service'
 
关闭随机启动:

[root@idoseek ~]# systemctl disable redis.service
 rm '/etc/systemd/system/mult(www.111cn.net)i-user.target.wants/redis.service'
 
方法二:编译安装
 
下载安装编译:

# wget http://download.redis.io/releases/redis-2.8.17.tar.gz
 # tar xzf redis-2.8.17.tar.gz
 # cd redis-2.8.17
 # make
 # make install
 
设置配置文件路径:

# mkdir -p /etc/redis && 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> shutdown
 
清除缓存

redis-cli flushall
 
更多文档请参考软件包内的“README”文件。
 查看状态 :
 
# ss -nlp|grep redis
 
或者
 
# ps -ef | grep redis
 
下面介绍为PHP添加redis插件。
 
从官网下载最新的拓展,地址:http://pecl.php.net/package/redis或者https://github.com/phpredis/phpredis
 
#wget http://pecl.php.net/get/redis-2.2.5.tgz
 #phpize
 #./configure --prefix=/opt/redis --enable-redis --with-php-config=/opt/php/bin/php-config
 #make && make install
 
把拓展添加至php.ini,重启php-fpm:
 
service php-fpm restart
from:http://www.111cn.net/sys/CentOS/85292.htm

错误描述

安装Redis 2.8.18时报错

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2

原因分析

在README 有这个一段话。

Allocator  
---------

Selecting a non-default memory allocator when building Redis is done by setting  
the `MALLOC` environment variable. Redis is compiled and linked against libc  
malloc by default, with the exception of jemalloc being the default on Linux  
systems. This default was picked because jemalloc has proven to have fewer  
fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

说关于分配器allocator, 如果有MALLOC  这个 环境变量, 会有用这个环境变量的 去建立Redis。

而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。

但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数。

解决办法

make MALLOC=libc

centos7安装redis的更多相关文章

  1. CentOS7 安装Redis Cluster集群

    上一篇中已经讲到了如何安装单击版Redis,这一篇我们来说下如何安装Cluster,关于哨兵模式这里我就不写文章安装了,有兴趣的同学可以自己去研究,哨兵模式可以在主从模式下在创建三台机器的哨兵集群监控 ...

  2. CentOS7安装redis数据库及php-redis扩展

    redis 首先把redis安装到服务器中 1.wget http://download.redis.io/redis-stable.tar.gz 下载redis源码 2. tar xvzf redi ...

  3. [ 搭建Redis本地服务器实践系列一 ] :图解CentOS7安装Redis

    上一章 [ 搭建Redis本地服务器实践系列 ] :序言 作为开场白介绍了下为什么要写这个系列,从这个章节我们就开始真正的进入正题,开始搭建我们本地的Redis服务器.那么关于Redis的基本概念,什 ...

  4. centos7 安装redis服务及phpredis扩展

    闲话少说 服务器版本:centos7.6 64位 软件包:https://pan.baidu.com/s/1Gb4iz5mqLqNVWvvZdBiOMQ 提取码: xrhx 一.安装redis 放在/ ...

  5. vmware安装centos7 安装redis windows7访问redis

    1.在windows7中安装vmware 2.在vmware中安装centos7 3.禁用centos7自带的firewalld.service 4.安装iptables防火墙 5.安装Redis 3 ...

  6. CentOS7 安装Redis和PHP-redis扩展

    aemonize yes Redis是一个key-value存储系统,属于我们常说的NoSQL.它遵守BSD协议.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的AP ...

  7. Centos7 安装redis

    1.下载redis安装包 wget http://download.redis.io/releases/redis-4.0.9.tar.gz 2.检查及下载gcc gcc -v yum -y inst ...

  8. Centos7 安装 Redis

    关闭防火墙:systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启 ...

  9. Centos7安装Redis 3.2.8

    关闭防火墙和SELinx 关闭防火墙 [root@node1 ~]# systemctl stop firewalld 开启防火墙 [root@node1 ~]# systemctl enable f ...

随机推荐

  1. svn小设置

    由于每次提交代码或者更新代码都需要输入密码,太不方便,今天请教了高手设置一下svn,问题解决... 流程如下  TortoiseSVN --> Settings -->  Network ...

  2. Supervisor重新加载配置

    Supervisor重新加载配置启动新的进程 liaojie 发布于 1年前,共有 0 条评论 一.添加好配置文件后 二.更新新的配置到supervisord supervisorctl update ...

  3. 【转】The import javax.servlet cannot be resolved

    转载地址:http://www.2cto.com/kf/201212/176868.html 今天将别人的项目导入eclipse之后,出现了“The import javax.servlet cann ...

  4. 将光标放到input内容的最后

    在使用setSelectionRange方法的时候一定要加setTimeout,否则无效,代码 var num = $('#input_phone').val().length; setTimeout ...

  5. Bootstrap 3 Datepicker 使用过程

    最近在创建记录的时候,需要用到日历的功能.本身是使用的bootstrap布局的,所以就找到Datepicker,看了一下用起来还是挺方便的.下面就是使用过程. 依赖的资源 jQuery Moment. ...

  6. 使用AFNetWorking读取JSON出现NSCocoaErrorDomain Code=3840的解决方法

    最近在使用AFNetworkWorking读取JSON时,出现了NSCocoaErrorDomain Code=3840的错误.这种错误应该是服务器端返回JSON格式不对造成的.通过Google搜到这 ...

  7. sql中文日期格式转换(xxxx年x月x日)

    ) set @dd='2014年10月1日' select replace(replace( replace(@dd,'日',''),'月','-'),'年','-') 别人的方法 )='2012年1 ...

  8. python-正则表达式基础

    转载作者:AstralWind 1. 正则表达式基础 1.1. 简单介绍 正则表达式并不是Python的一部分.正则表达式是用于处理字符串的强大工具,拥有自己独特的语法以及一个独立的处理引擎,效率上可 ...

  9. sublime text 配置 builder [build system]

    有时候需要用运行一段 PHP 代码,比如测试某个函数返回值等等,如果启动 Http Server,再打开浏览器,那黄花菜都凉了.我们可以在 Sublime Text 3 中创建 PHP 的 build ...

  10. php数据类型及转换