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

The method of starting redis in linux Environment

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces the linux environment to start redis method, has a certain reference value, need friends can refer to the next. I hope you will have a lot of success after reading this article. Let's take a look at it together.

Start redis

redis executable description:

redis-server: redis server

redis-cli: redis command-line client

redis-benchmark: redis performance testing tool

redis-check-aof: aof file repair tool

redis-check-dump: rdb file checking tool

1, Direct start

Run redis-server directly to start redis

Redis server uses port 6379 by default. You can customize the port number by using the--port parameter:

redis-server --port 6380

If a warning appears:

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.

To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Overuse memory set to 0! Background saving may fail in low memory environments. To fix this, add an entry 'vm.overcommit_memory = 1' to/etc/sysctl.conf and restart (or run the command 'sysctl vm.overcommit_memory= 1') to make it take effect.

Follow this tip, warning to exclude.

2. Start redis through initialization script

The utils folder of the redis source directory contains an initialization script file called redis-init_script

step

(1) Configure initialization scripts.

First copy the initialization script to/etc/init.d directory, the file name is redis_port number (redis_6379), and then modify the variable value of REPORT in line 6 of the script to the same port number (ubuntu).

If centos or redhat, use the following script (port number modified as appropriate)

#chkconfig: 2345 90 10#description: Redis is a persistent key-value databasePATH=/usr/local/bin:/sbin:/usr/bin:/binREDISPORT=6379EXEC=/usr/local/bin/redis-serverREDIS_CLI=/usr/local/bin/redis-cliPIDFILE=/var/run/redis_6379.pidCONF="/etc/redis/6379.conf"case "$1" instart)if [ -f $PIDFILE ]thenecho "$PIDFILE exists, process is already running or crashed"elseecho "Starting Redis server... "$EXEC $CONFfiif [ "$? "="0" ]thenecho "Redis is running... "fi;;stop)if [ ! -f $PIDFILE ]thenecho "$PIDFILE does not exist, process is not running"elsePID=$(cat $PIDFILE)echo "Stopping ... "$REDIS_CLI -p $REDISPORT SHUTDOWNwhile [ -x ${PIDFILE} ]doecho "Waiting for Redis to shutdown ... "sleep 1doneecho "Redis stopped"fi;;restart|force-reload)${0} stop${0} start;;*)echo "Usage: /etc/init.d/redis_6379 {start|stop|restart|force-reload}" >&2exit 1esac

(2) Create the required folders

/etc/redis stores redis configuration files

The requested URL/var/redis/was not found on this server.

(3) Modify the configuration file

Copy the configuration file template to the/etc/redis directory, named with a port number (e.g."6379.conf")

Configuration and description to be modified:

daemonize yes: causes redis to run in daemon mode

pidfile /var/run/redis_port number.pid: Set redis pid file location

port port number: set the port number redis listens on

dir /var/redis/port number: Set persistent file storage location

Set up boot service:

sudo update-rc.d redis_port defaults //tells the system to automatically execute the redis_port script when it starts. (ubuntu)

Thank you for reading this article carefully, hope Xiaobian share linux environment to start redis method content is helpful to everyone, but also hope that everyone more support, pay attention to industry information channels, encounter problems to find, detailed solutions waiting for you to learn!

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