Skip to content

Instantly share code, notes, and snippets.

@Epigene
Last active August 15, 2018 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Epigene/f5e63e30ab7f9680e5f4 to your computer and use it in GitHub Desktop.
Save Epigene/f5e63e30ab7f9680e5f4 to your computer and use it in GitHub Desktop.
Install Redis on your Production Ubuntu

Install deps

sudo apt-get update
sudo apt-get install -y build-essential tcl8.5

Get code

cd /tmp
wget http://download.redis.io/releases/redis-stable.tar.gz

unrar

tar xzf redis-stable.tar.gz
cd redis-stable

Build from source

make

make test

sudo make install

Setup deamon

cd utils
sudo ./install_server.sh # Choose a port

#=>
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

Restart service

sudo service redis_6379 stop
sudo service redis_6379 start

Test

redis-cli -p 6379
> ping

App setup

Since this redis is local, access it via
redis://localhost:6379/

Or just set in redis.yml

staging:
  redis: redis://localhost:6379/
production:
  redis: redis://localhost:6379/

Configuring Redis

For persistent queue, like for Sidekiq

sudo nano /etc/redis/6379.conf 
  # use Ctrl+W to search in nano  
  
  supervised systemd
  maxclients 1000
  databases 1
  # maxmemory <bytes>
  maxmemory-policy noeviction

For a LRU-expiring cache

sudo nano /etc/redis/6380.conf 
  # use Ctrl+W to search in nano  
  
  supervised systemd
  maxclients 1000
  databases 1
  maxmemory 500mb
  maxmemory-policy noeviction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment