先安装一些组件:

yum -y install gcc gcc-c++ libstdc++-devel

下载并安装:

# wget http://download.redis.io/releases/redis-2.8.19.tar.gz
# tar xzf redis-2.8..tar.gz
# cd redis-2.8.
# make && make install

如果有报错信息:

错误1:

[root@localhost redis-2.8.]# make && make install
cd src && make all
make[]: Entering directory `/data/software/redis-2.8./src'
CC adlist.o
In file included from adlist.c::
zmalloc.h::: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h::: error: #error "Newer version of jemalloc required"
make[]: *** [adlist.o] Error
make[]: Leaving directory `/data/software/redis-2.8./src'
make: *** [all] Error

解决方法:

# make MALLOC=libc
# make && make install

错误2:

[]  Jan ::46.366 # Server started, Redis version 2.8.19
[] Jan ::46.366 # WARNING overcommit_memory is set to ! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

根据提示可以编辑 /etc/sysctl.conf 文件,在文件底部添加如下内容:
vm.overcommit_memory = 1

然后执行 /sbin/sysctl vm.overcommit_memory=1,使之生效。

可以通过 /sbin/sysctl -p 来查看是否添加成功!

错误3:

[]  Jan ::14.324 # Server started, Redis version 2.8.
[] Jan ::14.324 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
[] Jan ::14.324 * DB loaded from disk: 0.000 seconds
[] Jan ::14.324 * The server is now ready to accept connections on port

限制了接收新 TCP 连接侦听队列的大小。对于一个经常处理新连接的高负载 web服务环境来说,默认的 128 太小了。大多数环境这个值建议增加到 1024 或者更多。
服务进程会自己限制侦听队列的大小(例如 sendmail(8) 或者 Apache),常常在它们的配置文件中有设置队列大小的选项。大的侦听队列对防止拒绝服务 DoS 攻击也会有所帮助。
我们可以通过来修改这个参数。

解决方法:

# echo  > /proc/sys/net/core/somaxconn

错误4:

[]  May ::22.059 # Server started, Redis version 2.8.
[] May ::22.059 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
[] May ::22.059 * DB loaded from disk: 0.000 seconds
[] May ::22.059 * The server is now ready to accept connections on port

解决方法:

# echo never > /sys/kernel/mm/transparent_hugepage/enabled

启动redis:

# redis-server /data/redis/redis.conf

测试设置:

# redis-cli
127.0.0.1:> set name redisdev
OK
127.0.0.1:> get name
"redisdev"

关闭redis:

# redis-cli shutdown

加入服务,并开机自启动:

# vim /etc/init.d/redis

添加以下脚本:

# chkconfig:
# description: service of redis for start and stop add by tomener PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis.pid
CONF="/data/redis/redis.conf"
AUTH="" case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed."
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE exists, process is not running."
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
sleep
while [ -x $PIDFILE ]
do
echo "Waiting for Redis to shutdown..."
sleep
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${} stop
${} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&
exit
esac
# chmod  /etc/init.d/redis
# /etc/init.d/redis start
# chkconfig --add redis
# chkconfig --level redis on #使用该命令能愉快的玩耍了
# service redis start|stop|restart

到此安装完成。那么您肯定会用到命令,附详细的命令大全。我也拿来参考用,防长时间忘记。

http://www.cnblogs.com/xsi640/p/3755133.html

linux下安装redis的详细过程的更多相关文章

  1. Linux下安装redis的详细过程(redis版本为4.0.10)

    1.安装redis步骤 1.推荐进入到linux路径/usr/local/src 2.$ wget http://download.redis.io/releases/redis-4.0.10.tar ...

  2. linux 下安装redis以及php Redis扩展

    [php] view plaincopy在CODE上查看代码片派生到我的代码片 linux 下安装redis以及php Redis扩展 环境配置: centos6. nginx/ php/ mysql ...

  3. Linux 下安装 Redis server

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/defonds/article/details/30047611         本文简介了 Linu ...

  4. 在linux下安装配置rabbitMQ详细教程

    在linux下安装配置rabbitMQ详细教程 2017年12月20日 17:34:47 阅读数:7539 安装Erlang 由于RabbitMQ依赖Erlang, 所以需要先安装Erlang. Er ...

  5. Linux下安装Redis及搭建主从

    Linux下安装Redis 首先在官网下载对应版本的redis包,这里本人使用的是redis-4.0.8.tar.gz.   然后在服务器中存放redis包的路径下执行tar –vxf redis-4 ...

  6. mac mamp环境 和linux下 安装redis 和可视化工具 Redis Desktop Manager

    mac下安装 第一步:安装redis 1. brew install redis 2.启动服务/usr/local/opt/redis/bin/redis-server 3.配置redis密码访问 编 ...

  7. Linux 下安装redis

    记录一下linux下的安装步骤,还是比较复杂的 1. 下载redis-2.8.19.tar.gz: ftp传到linux01上: 解压: tar –zxvf redis-2.8.19.tar.gz 2 ...

  8. Linux下安装Redis以及遇到的问题

    参考链接:https://www.cnblogs.com/zdd-java/p/10288734.html https://www.cnblogs.com/uncleyong/p/9882843.ht ...

  9. Linux下安装redis 3.0及C语言中客户端实现demo

    1.获取安装文件 wget http://download.redis.io/redis-stable.tar.gz 2.解压文件 tar xzvf redis-stable.tar.gz 3.进入目 ...

随机推荐

  1. Atitit j2ee5 jee5 j2ee6 j2ee7 jee6 jee7 新特性

    Atitit j2ee5 jee5 j2ee6 j2ee7 jee6 jee7 新特性 Keyword Java ee5 ,Java ee6,Java ee7  j2ee5 jee5 j2ee6 j2 ...

  2. win2008 强制删除故障集群配置

    在正常删除Cluster 节点之后,再添加节点时,报“节点已经加入群集”,无法加入,注册表信息删除后可正常移除Cluster服务,如下: win2008故障转移群集无法退出节点时 删除注册表中这两个后 ...

  3. 常用Math 方法

    /** * * @authors Your Name (you@example.org) * @date 2016-11-18 11:26:44 * @version $Id$ */ Math.pow ...

  4. 每天一个linux命令(35):ln 命令

    ln是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同步的链接.当我们需要在不同的目录,用到相同的文件时,我们不需要在每一个需要的目录下都放一个必须相同的文件,我们只要在 ...

  5. Linux下MakeFile初探

    make是linux下的编译命令,用于编译和生成Linux下的可执行文件.这个命令处理的对象是Makefile,makefile等.由于make的强大解析能力,makefile文件的编写也变得极为简单 ...

  6. 快速入门系列--MySQL

    一直说要好好复习一下Mysql都木有时间,终于赶上最近新购买了阿里云,决定使用CentOS去试试.NET Core等相关的开发,于是决定好好的回顾下这部分知识,由于Mysql的数据库引擎是插件式的,对 ...

  7. Windows 系统下Git安装图解

    简单来说Git是一个免费的.开源的版本控制软件,从功能上讲,跟我们比较熟悉的Subversion(SVN)这类版本控制软件没什么两样.由于工作的需求,需要在WinXP下安装git配合团队完成相应的工作 ...

  8. WPF自定义控件与样式(5)-Calendar/DatePicker日期控件自定义样式及扩展

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: 日历控 ...

  9. 【转】中间代码opcode的执行

    原文链接:http://www.orlion.ga/941/ 原文:http://www.nowamagic.net/librarys/veda/detail/1543 假如我们现在使用的是CLI模式 ...

  10. 分享一个 C# Winfrom 下的 OutlookBar 控件的使用

    最近在上网的时候,发现了这个C# 下的 OutlookBar 控件,看了一下感觉还真不错,特此记录一下. using System; using System.Drawing; using Syste ...