Redis 启动或停止的一些常用命令方法

【停止服务】

redis-cli  shutdown
redis-cli -p 6379 shutdown
redis-cli -p 8888 shutdown

【启动命令】
rides 对应目录下执行命令

cd C:\Program Files\Redis 

redis-serve

【异常问题解决】
1、不能sava的问题
	删除原件dump_***.rdb文件
【多个服务的配置】
conf、data、log、run、scripts、sentinel  均可配置多个项目

1、conf 文件 、test.conf
# Example sentinel.conf
#
# SENTINELNAME ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE_SEN_01    # don't delete this line
#
#
daemonize yes
port 8001
bind 10.202.25.134
sentinel monitor ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 10.202.25.134 8080 2
dir "/app/redis/sentinel/ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE_SEN_01"
pidfile "/app/redis/run/ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE_SEN_01.pid"
loglevel notice
logfile "/app/redis/log/ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE_SEN_01.log"

# ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE
sentinel failover-timeout ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 60000
sentinel auth-pass ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE admin.123
sentinel config-epoch ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 0
sentinel leader-epoch ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 0
sentinel known-slave ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 10.202.25.135 8080
# Generated by CONFIG REWRITE
sentinel known-sentinel ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 10.202.25.135 8001 e8ba83135da60e05691c76548c13b7d12c873a2d
sentinel known-sentinel ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE 10.202.25.134 8002 fc56fd31b719ec8ab029adcbebfc9474e342a3a9
sentinel current-epoch 0
sentinel announce-ip "10.202.215.234"

2、run  目录的启动脚本  test.run

#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDISNAME="ASURA_OSMS_SERVER_CNSZ22_REDIS_CACHE_SEN_01"
EXEC=/app/redis/bin/redis-server
CLIEXEC=/app/redis/bin/redis-cli

PIDFILE=/app/redis/run/${REDISNAME}.pid
REDISCONF="/app/redis/conf/${REDISNAME}.conf"

REDISIP=$(grep "bind" $REDISCONF | cut -d " " -f 2 )
REDISPORT=$(grep "port" $REDISCONF | cut -d " " -f 2 )
# REDISPASS=$(grep "requirepass" $REDISCONF | cut -d " " -f 2 )

case "$1" in
    start|'')
        if [ -f $PIDFILE ]
        then
            echo "..."
            echo "$PIDFILE exists, process is already running or crashed"
            echo ""

        else
            echo "..."
            echo "Starting Redis server..."
            echo ""

            export LD_PRELOAD=/usr/lib64/connect_hack.so
            export DEFAULT_BIND_RULE_IPV4=$REDISIP
            $EXEC $REDISCONF --sentinel
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
            echo "..."
            echo "$PIDFILE does not exist, process is not running"
            echo ""
        else
            PID=$(cat $PIDFILE)
            echo "Stopping ..."
            $CLIEXEC -h $REDISIP -p $REDISPORT shutdown
            while [ -x /proc/${PID} ]
            do
                echo "..."
                echo "Waiting for Redis to shutdown ..."
                sleep 3
            done
            echo "..."
            echo "Redis stopped"
            echo ""
        fi
        ;;
    status)
        if [ ! -f $PIDFILE ]
        then
            echo "..."
            echo "$REDISNAME is stop"
            echo ""
        else
            echo "..."
            echo "$REDISNAME is running"
            $CLIEXEC -h $REDISIP -p $REDISPORT  info | grep -E "redis_mode|uptime_in_days|uptime_in_seconds"
            #$CLIEXEC -h $REDISIP -p $REDISPORT info 
            echo ""
         fi
         ;;

    *)
        #echo "..."
        #echo "Please use \"start\" | \"stop\" |as first argument"
        echo "..."
        echo $"Usage: $prog {start|stop|status}"
        echo ""
        exit 1
        ;;
esac



 

你可能感兴趣的:(Rides)