Below is a install to get Redis installed on CentOS 7 for use as a buffer for Logstash. The install is fairly standard but some of the settings are specific for use as a Logstash buffer. This is particularly useful to place on the Logstash server that is writing logs to the buffer (detailed blog post coming later)

The install documented here is based on a fresh install of CentOS 7 x86_64 Minimal
http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso

When you build your CentOS server do not create a swap file, this is not needed for a properly configured Redis server.

First, make sure your CentOS install is up to date

sudo yum update
sudo yum upgrade -y

Install Redis

sudo yum install redis -y

Change the default settings.
Redis will listen on both localhost and all IP’d interfaces.

sudo sed -i -e 's|bind 127.0.0.1|bind 0.0.0.0|' /etc/redis.conf

Disable persistance

sudo sed -i -e 's|save 900 1|# save 900 1|' /etc/redis.conf
sudo sed -i -e 's|save 300 10|# save 300 10|' /etc/redis.conf
sudo sed -i -e 's|save 60 10000|# save 60 10000|' /etc/redis.conf

Set max memory usage to 40 GB. Change this number to meet your requirements, the idea is to size the buffer to be large enough for a typical Elasticsearch downtime timeframe, whether it is a couple hours or worst case of an entire 3 day weekend.

sudo sed -i -e 's|# maxmemory |maxmemory 40gb|' /etc/redis.conf

Set the max memory eviction policy so that Redis will evict log messages instead of running out of memory and crashing. Consider this a failsafe. It is possible to configure certain keys/lists to evict and others not if you have certain logs that are more important then others.

sudo sed -i -e 's|# maxmemory-policy noeviction|maxmemory-policy allkeys-lru|' /etc/redis.conf

Enable the Redis service to start on boot and then start it manually.

sudo systemctl enable redis
sudo systemctl restart redis

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu