zoukankan      html  css  js  c++  java
  • CenterOS中安装Redis及开机启动设置

    进入这个目录:
    cd /etc/init.d/
    在此目录下创建redis脚本
    vim redis
    把下边的内容拷贝到redis文件中,然后保存

    ###########################
    PATH=/usr/local/bin
    REDISPORT=6379
    #注意下边是你的路径,可能需要修改
    EXEC=/usr/local/bin/redis-server
    REDIS_CLI=/usr/local/bin/redis-cli
    #Redis密码
    PASSWORD=xxxx
    PIDFILE=/var/run/redis.pid
    #注意下边是你的路径,可能需要修改
    CONF="/usr/local/bin/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 does not exist, process is not running"
            else
                    PID=$(cat $PIDFILE)
                    echo "Stopping ..."
                    $REDIS_CLI -p $REDISPORT -a $PASSWORD SHUTDOWN
                    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
    ##############################

    设置脚本权限
    chmod +x /etc/init.d/redis
    设置开机启动
    sudo chkconfig redis on
    启动服务

    service redis start

    参考文章:
    http://www.cnblogs.com/piscesLoveCc/p/5757477.html

  • 相关阅读:
    C# 数据库连接字符串拼接
    C# 线程同步计数存在的问题
    字符串操作
    字符串位置
    6个基本函数
    占位符
    str转换成int
    python运算符6
    python运算符5
    python运算符4
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13310632.html
Copyright © 2011-2022 走看看