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

How to open redis

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces how to open redis, the article is very detailed, has a certain reference value, interested friends must read it!

How to open redis?

Redis start mode

1. direct start

Enter the redis root directory and execute the command:

#Add '&' to make redis run as a background program

./ redis-server &

2. Start by specifying a profile

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

Go to 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 `redis-cli` client connection, for example:

redis-cli -p 6380

3. Use redis startup script to set boot-up autoboot

The startup script redis_init_script is located in the/utils/directory of Redis. 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. #Port REDISPORT=6379 #Server location EXEC=/usr/local/bin/redis-server #Client location CLIEXEC=/usr/local/bin/redis-cli #PID file location of redis, need to modify PIDFILE=/var/run/redis_${REDISPORT}.pid #redis configuration file location, need to modify ${REDISPORT} to 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 operate as root user:

mkdir /etc/rediscp redis.conf /etc/redis/6379.conf

Copy the startup script to the directory/etc/init.d. In this example, the startup script is named redisd (usually ending with d to indicate that it is a background self-startup service).

cp redis_init_script /etc/init.d/redisd

chkconfig redisc on Error found: service redisc does not support chkconfig

Workaround: Modify the runlevel by adding the following comment at the beginning of the startup script:

#!/ bin/sh# chkconfig: 2345 90 10

Set it again

#Set it to boot from startup server chkconfig redisd on#Open service redisd start#Close service redisd stop The above is how to open all the contents of redis, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

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

Database

Wechat

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

12
Report