关于redis集群:redis-安装

37次阅读

共计 1179 个字符,预计需要花费 3 分钟才能阅读完成。

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

正文完
 0