服务器我用 Linux程序员

手动安装redis-3.2.8的详细步骤

2017-03-30  本文已影响375人  Joepis

摘要: 原创出处 http://peijie2016.gitee.io 欢迎转载,保留摘要,谢谢!

CentOS6.7使用yum安装有时候没有比较新的版本,所以手动安装,下面记录一下步骤。

redis

下载最新版本

以3.2.8为例,附上地址:redis-3.2.8.tar.gz

解压,编译,安装redis

mkdir -p /opt/redis-3.2.8/bin
mkdir -p /opt/redis-3.2.8/log
mkdir -p /opt/redis-3.2.8/pid
mkdir -p /opt/redis-3.2.8/db

配置redis

pidfile /opt/redis-3.2.8/pid/redis.pid
logfile /opt/redis-3.2.8/log/redis.log
dir /opt/redis-3.2.8/db

其他配置就默认即可,有需要再自行修改

#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
PATH=/opt/redis-3.2.8/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/opt/redis-3.2.8/bin/redis-server
CLIEXEC=/opt/redis-3.2.8/bin/redis-cli
PIDFILE=/opt/redis-3.2.8/pid/redis.pid
CONF="/opt/redis-3.2.8/redis.conf"
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
        ;;
    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
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

相关使用

上一篇 下一篇

猜你喜欢

热点阅读