Solve the problem that redis cannot be started with the system

Time:2020-1-14

Resolve serverDebian 9The pagoda surface plate comes with itRedisIt cannot be automatically started with the system after restart.

Supplementary installation

  • Pagoda panelRedisInstallation path in/www/server/redis
  • stayredisInstallation directorysrcTwo files in the folderredis-serverredis-cliThe servers and clients of redis.
  • Need to entersrcDirectory, executingmake install, these two files will be copied to/usr/local/binCatalog,/usr/local/binDefined in the environment variable $path of the system, so that the terminal can execute in any pathredis-serverandredis-cliNow.
  • Open SSH
cd /www/server/redis/src
make install
  • open/www/server/redis/utils/redis_init_script
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

### BEGIN INIT INFO
# Provides:     redis_6379
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Redis data structure server
# Description:          Redis data structure server. See https://redis.io
### END INIT INFO

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.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
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac
  • confThe set path is/etc/redis/, putredisCopy the redis.conf file in the installation directory to/etc/redis/6379.conf
  • Restart on the panelRedis

Recommended Today

Process analysis of login and logout based on spring security

This article mainly introduces the process analysis of login and logout function based on spring security. The example code is introduced in detail, which has certain reference learning value for everyone’s study or work. Friends in need can refer to it 1. Introducing Maven dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> 2. The security configuration class describes […]