下载

[Redis](wget http://download.redis.io/releases/redis-3.0.0.tar.gz “Redis”)

wget http://download.redis.io/releases/redis-3.0.0.tar.gz

安装

tar -zxvf redis-3.0.0.tar.gz
cd redis-3.0.0
make
mkdir -p /usr/local/redis
# 如果下列文件在根目录
cp redis-server /usr/local/redis
cp redis-benchmark /usr/local/redis
cp redis-cli /usr/local/redis
# 如果下列文件在src目录
cp src/redis-server /usr/local/redis
cp src/redis-benchmark /usr/local/redis
cp src/redis-cli /usr/local/redis
# 复制配置文件
cp redis.conf /usr/local/redis
cd /usr/local/redis

设置服务

vi /etc/init.d/redisd
添加一下内容:

#!/bin/bash
# chkconfig: 2345 50 80
# description: redis start ....

c_home=/usr/local/redis
pidfile=/var/run/redis.pid

start() {
    echo starting...
    cd ${c_home}
    ./redis-server redis.conf &
}

stop() {
    pid=$(cat $pidfile)
    echo stoping...
    kill -9 ${pid}
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit

设置服务:

$ chkconfig --add redisd
$ chkconfig redisd on

启动服务

service redisd start

验证:
ps -ef | grep redis
redis

文档更新时间: 2019-11-04 14:20   作者:Eddy