Mind Flow Productions

Systems & Productivity

Installing and understanding Redis

YouTube video?

https://www.fullstackpython.com/blog/install-redis-use-python-3-ubuntu-1604.html

Install Redis outside of any virtualenv

prepare Ubuntu: $ sudo apt-get update $ sudo apt-get upgrade

install redis: $ sudo apt-get install redis-server OR $ sudo apt-get install redis-server redis-tools

enable redis to start on system boot. Also restart once: $ sudo systemctl enable redis-server.service

start the redis server: $ redis-server

start in background: $ redis-server —daemonize yes

command line util: $ redis-cli $ > ping $ > shutdown $ > quit or exit

check if the process started or not: $ ps aux | grep redis-server

Or add to bash_profile: alias redis-server=’redis-server —daemonize yes’ Then you get daemonize every time you type redis-server to your command line. You can also add a password the same way (dev only!) alias redis-server=’redis-server —requirepass devpassword —daemonize yes’

Or load this directly from python using subprocess: subprocess.Popen([‘redis-server’, ‘—requirepass devpassword’, ‘—daemonize’, ‘yes’]) OR is it: subprocess.Popen([‘redis-server’, ‘—requirepass’, ‘devpassword’, ‘—daemonize’, ‘yes’]) then to shutdown use: subprocess.Popen([‘redis-cli’, ‘shutdown’])

Also set config properly See docs

security https://www.digitalocean.com/community/tutorials/how-to-secure-your-redis-installation-on-ubuntu-14-04 https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04

from console after redis server started: WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

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.