What are the three startup modes of redis?
Editor to share with you what are the three ways to start redis. I hope you will get something after reading this article. Let's discuss it together.
There are three ways to start redis: direct startup, boot self-startup using redis startup script, and startup through a specified configuration file.
1. Start directly
Redis-server
Add a'& 'sign to make redis run redis-server as a daemon &
2. Start by specifying the configuration file
You can specify a profile for redis service startup, such as / etc/redis/6379.conf
Redis-server / etc/redis/6379.conf
# if you change the port, you also need to specify the port when you use the `redis- cli` client to connect, for example:
Redis-cli-p 6380
3. Use redis startup script to set boot self-startup
The 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
According to the startup script, copy the modified configuration file to the specified directory and use the root user to do the operation:
Mkdir / etc/rediscp redis.conf / etc/redis/6379.conf
Copy 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
Set to boot self-startup, directly configure to enable self-boot 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
Just set it again.
# set to boot self-starting server chkconfig redisd on# open service service redisd start# close service service redisd stop after reading this article, I believe you have a certain understanding of "what are the three startup modes of redis". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!