前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >centos7安装redis

centos7安装redis

作者头像
庞小明
发布2018-03-08 13:55:21
1.6K0
发布2018-03-08 13:55:21
举报
文章被收录于专栏:pangguomingpangguoming

方法一:使用命令安装(前提是已经安装了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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-12-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档