你的位置:首页 > 操作系统

[操作系统]Centos7 安装redis3.2.3 过程


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