Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the ways to start redis?

Shulou Source: shulou.com Published: 2022-06-01 18:49:57 09月26日 Update

Three startup modes of redis

1. Direct start

Go to the redis root directory and execute the command:

# add'&'to make redis run as a daemon

. / redis-server &

two。 Start by specifying a configuration file

You can specify a profile for redis service startup, such as / etc/redis/6379.conf

Enter the redis root directory and enter the command:

. / 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 the redis startup script to set up 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

These are the details of how to start redis, please pay attention to other related articles!

Tags: File location configuration port script service method command client client root code content background that is file name article more server directory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux Apple OPPO Reno vpn