码迷,mamicode.com
首页 > 其他好文 > 详细

Centos7 安装redis3.2.3 过程

时间:2016-08-23 16:14:06      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

1:安装wget: yum install wget
2:安装pip:
    1:sudo yum -y install epel-release
    2:sudo yum -y install python-pip
3:安装redis:
    1:wget --no-check-certificate http://download.redis.io/releases/redis-3.2.3.tar.gz
    2:tar xzf redis-3.2.3.tar.gz
    3:mv redis-3.2.3 usr/local/redis-3.2.3
    4:cd usr/loacl/redis-3.2.3
    5:make
    6:设置开机自启:
        1:设置redis.conf中daemonize为yes
        2:设置redis.conf中logfile为"/var/log/redis.log"
        2:编写开机自启动脚本
            vi /etc/init.d/redis
            redis content is:
"""


# chkconfig: 2345 10 90  
# description: Start and Stop redis   
 
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/redis-3.2.3/src/redis-server
REDIS_CLI=/usr/local/redis-3.2.3/src/redis-cli

PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis-3.2.3/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   
                if [ "$?"="0" ]   
                then   
                        echo "Redis is running..."  
                fi   
                ;;   
        stop)   
                if [ ! -f $PIDFILE ]   
                then   
                        echo "$PIDFILE exists, process is not running."  
                else  
                        PID=$(cat $PIDFILE)   
                        echo "Stopping..."  
                       $REDIS_CLI -p $REDISPORT  SHUTDOWN    
                        sleep 2  
                       while [ -x $PIDFILE ]   
                       do  
                                echo "Waiting for Redis to shutdown..."  
                               sleep 1  
                        done   
                        echo "Redis stopped"  
                fi   
                ;;   
        restart|force-reload)   
                ${0} stop   
                ${0} start   
                ;;   
        *)   
               echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2  
                exit 1  
esac

"""

        4:chmod +x /etc/init.d/redis
        5:/etc/init.d/redis start
        6:设置开机自启:sudo chkconfig redis on

Centos7 安装redis3.2.3 过程

标签:

原文地址:http://www.cnblogs.com/scarecrowpqs/p/5799365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!