1. 安装依赖包

yum -y install gcc*yum -y install tcl-8.5*

2. 解压缩

tar -zxf redis-3.2.8.tar.gzcd redis-3.2.8

3. 编译

make MALLOC=libc

4. 安装

make PREFIX=/usr/local/redis install

5. 修改配置文件

cp redis.conf /usr/local/redis/conf几项关键配置pidfile /var/run/redis.pid                   #进程文件logfile "/usr/local/redis/logs/redis.log"        #日志文件protected-mode no     #允许客户端从其他主机进行连接                      port 6379#服务端口号daemonize yes#后台启动databases 1#创建数据库数目#bind 127.0.0.1#监听所有地址

6. 创建服务脚本

cp redis_init_script /etc/init.d/redis 脚本内容如下:#!/bin/sh# chkconfig: 2345 80 90## Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem. REDISPORT=6379EXEC=/usr/local/redis/bin/redis-serverCLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis.pidCONF="/usr/local/redis/conf/redis.conf" start() {if [ -f $PIDFILE ]then        echo "$PIDFILE exists, process is already running or crashed"else        echo "Starting Redis server..."        $EXEC $CONFfi} stop() {if [ ! -f $PIDFILE ]then        echo "$PIDFILE does not exist, process is not running"else        PID=$(cat $PIDFILE)        echo "Stopping ..."        $CLIEXEC -p $REDISPORT shutdown        while [ -x /proc/${PID} ]        do            echo "Waiting for Redis to shutdown ..."            sleep 1        done        echo "Redis stopped"fi} restart() {stopstart} status() {RETVAL=`ps -ef | grep -v grep | grep redis-server | awk '{print $2}'`if [ ! -f "$PIDFILE" ] ; then        echo "redis is stoped."        exit 1fiif [ "$RETVAL" = "$(cat $PIDFILE)" ] ; then        echo "redis is running..."else        echo "redis is stoped."fi} case "$1" in    start)        start        ;;    stop)        stop        ;;    restart)        restart        ;;    status)        status        ;;    *)        echo $"Usage: $0 {start|stop|restart}"        ;;esac