Get the App
SLTechnology News&Howtos  ›  Database  › 

How to set redis Boot self-boot

Shulou Source: shulou.com Published: 2022-06-01 16:18:13 10月21日 Update

How to set redis to boot automatically? I believe that many novice rookies have not yet learned this skill. Through the summary of this article, I hope you can learn this skill. The following materials are the steps for implementation.

Use the following method to pay attention to the path to the installation file and the path to the configuration file.

[root@localhost ~] # vi / etc/init.d/redis

Copy the following code into the script (note that you need to modify the installation path of redis, it is not clear to look it up by find)

(this code is the code for the redis root directory / utils/redis_init_script startup script)

#! / bin/sh# chkconfig: 2345 10 90 # description: Start and Stop redis REDISPORT=6379EXEC=/usr/local/bin/redis-serverCLIEXEC=/usr/local/bin/redis-serverPIDFILE=/var/run/redis_$ {REDISPORT} .pidCONF = "/ etc/redis/redis.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;; restart) "$0" stop sleep 3 "$0" start; *) echo "Please use start or stop or restart as first argument";; esac

Set permissions

[root@localhost ~] # chmod 777 / etc/init.d/redis

Set up boot boot

Chkconfig redis on

Start the test

Service start redis

After reading this article, have you learned how to set up redis to boot automatically? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.

Tags: Code skills paths files methods more articles scripts clarity content that is novice permissions root directory steps industry data information information channels faceted Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Shulou Tech Info MariaDB Docker