Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the ways to start redis in Linux

Shulou Source: shulou.com Published: 2022-06-01 20:48:20 09月24日 Update

This article mainly explains "what are the ways to start redis in Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the ways to start redis in Linux?"

1. Boot directly to the redis root directory and execute the command: # plus the'& 'sign to make redis run as a background program

Nohup redis-server & 2. You can specify a configuration file for redis service startup by specifying the configuration file startup, for example, configure / etc/redis/6379.conf to enter the redis root directory, enter the command:

. / redis-server / etc/redis/6379.conf# if you change the port, you also need to specify the port when using the redis-cli client connection, for example:

Redis-cli-p 63803. Use the redis startup script to set the boot self-startup script redis_init_script is located in the / utils/ directory of Redis, and the redis_init_script script code is as follows:

#! / bin/sh # # Simple Redis init.d script conceived to work on Linux systems # as it does use of the / proc filesystem. # redis server listens to the port REDISPORT=6379 # server location EXEC=/usr/local/bin/redis-server # client location CLIEXEC=/usr/local/bin/redis-cli # redis PID file location, you need to modify the configuration file location of PIDFILE=/var/run/redis_$ {REDISPORT} .pid # redis Change ${REDISPORT} to the file name 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 copies the modified configuration file to the specified directory according to the startup script, and operates with the root user:

Mkdir / etc/redis cp redis.conf / etc/redis/6379.conf copies the startup script to the / etc/init.d directory. In this example, the startup script is named redisd (usually ending in d to indicate a background self-starting service).

Cp redis_init_script / etc/init.d/redisd is set to boot and self-startup is directly configured. Chkconfig redisd on found error: service redisd does not support chkconfig

As a workaround, modify the run level by adding the following comments at the beginning of the startup script:

#! / bin/sh # chkconfig: 2345 90 10 can be set again

# set to boot self-starting server chkconfig redisd on # turn on service service redisd start # disable service service redisd stop so far, I believe you have a deeper understanding of "what is the way to start redis in Linux", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Script service file configuration method location directory port content background command client client server root learning running practical deeper code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia Redmi Docker Huawei