乐趣区

redis-安装

1. 新建 redis 文件夹
mkdir /home/redis
2. 进入 redis 目录
cd /home/redis
3. 下载 redis-5.0.8
wget http://download.redis.io/rele…
4. 解压 redis
tar zxvf redis-5.0.8.tar.gz
5. 进入 redis-5.0.8
cd /home/reids/redis-5.0.8/src
6. 编译(编译前确定依据安装了 gcc,如果没有安装则 yum install gcc)
make
7. 配置 redis
8. 设置 redis 为开机启动
新建开机启动脚本
vi /etc/init.d/redis
输入开机脚本:

#chkconfig: 2345 10 90
# description: Start and Stop redis

# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDISPORT=6379
EXEC=/home/redis/redis-5.0.8/src/redis-server
CLIEXEC=/home/redis/redis-5.0.8/src/redis-cli

PIDFILE=/var/lib/redis/redis_${REDISPORT}.pid
#CONF="/etc/redis/${REDISPORT}.conf"
CONF="/home/redis/redis-5.0.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
        ;;
    restart)
        "$0" stop
        sleep 3
        "$0" start
        ;;
    *)
        echo "Please use start or stop or restart as first argument"
        ;;
esac

9. 添加 redis 服务
chkconfig –add redis
10. 设置为开机启动
chkconfig redis on
11. 启动服务
nohup service redis start

退出移动版