Install single node Redis

Keywords: Operation & Maintenance Redis Django Linux CentOS

Forward link http://www.python3.vip/tut/webdev/django/17/

  • Installing Redis on Linux

It is recommended to compile and install the source code, so that you can freely choose the Redis version to install.

For example, on centos 7, log in as root and execute the following commands to download, decompress, compile and install

wget http://download.redis.io/releases/redis-5.0.6.tar.gz
tar xzf redis-5.0.6.tar.gz
cd redis-5.0.6
make
make test
make install

Next, execute the command to configure and start Redis service

cd utils/ ; ./install_server.sh

In the process, there will be the following interactive prompts. Basically, you can enter all the way to confirm and use the default configuration.

Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

After execution, the Redis service will start listening on the default port 6379, and will start automatically every time it is turned on.

 

Redis saves memory data to disk by default. If redis is only used as a cache, performance will be affected.

We can modify the configuration file to disable saving data to disk as follows

Execute the command vim /etc/redis/6379.conf to open the configuration file, and find the following three lines in the file

save 900 1
save 300 10
save 60 10000

Add a comment to the front, and it will become the following

#save 900 1
#save 300 10
#save 60 10000

 

If you need to use this Redis service for non native programs (such as Django), you should change the address bound in the configuration file from 127.0.0.1 to 0.0.0.0

Locate the configuration file as follows

bind 127.0.0.1

Change to

bind 0.0.0.0

Of course, if you want to use Redis service for remote programs, don't forget to open the firewall and 6379 port {:. notice – info}

 

Finally, execute the following command to restart the Redis service so that the modified configuration takes effect.

service redis_6379 restart

Posted by Hepp on Sun, 17 May 2020 03:31:23 -0700