Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods to start redis under Linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about the ways to start redis under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. Direct start

Go to the redis root directory and execute the command: # add'&'to make redis run as a daemon

Nohup redis-server & 2. Start by specifying a configuration file

You can specify a configuration file for redis service startup, for example, configure / etc/redis/6379.conf to 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 using the redis-cli client connection, for example:

Redis-cli-p 63803. 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 port REDISPORT=6379# server location EXEC=/usr/local/bin/redis-server# client location PID file location of CLIEXEC=/usr/local/bin/redis-cli#redis, 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-startup server chkconfig redisd on# open service service redisd start# close service service redisd stop thank you for reading! This is the end of this article on "what are the ways to start redis under Linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report