Redis安装

2018-10-29  本文已影响3人  爱折腾的傻小子

Redis | phpredis

Redis 守护进程linux开机自启

redis启动 | (注意文档中存在错误 脚本代码需要加上开头项 #!/bin/sh )

#!/bin/sh 

# chkconfig:   2345 90 10
# description:  Redis is a persistent key-value database

PATH=/usr/local/src/redis/src
REDISPORT=6379
EXEC=/usr/local/src/redis/src/redis-server
REDIS_CLI=/usr/local/src/redis/src/redis-cli
#Redis密码
PASSWORD=bmS123456
PIDFILE=/var/run/redis.pid
CONF="/usr/local/src/redis/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
上一篇 下一篇

猜你喜欢

热点阅读